Angle between two 3D vectors expressed as phi and theta

Started by
17 comments, last by asad_82 12 years, 11 months ago
I am interested in finding angle between two 3D vectors A = [a1, a2, z3] and N = [n1 n2 n3]
Typically the angle can be found as: angle = acos(A . N / (|A| |N|) )

But I am interested in the representation of this angle in spherical coordinates i.e. I want to know theta and phi angle separately ...... spherical coordinates of the angle found above.

The vector N is the normal vector and represents the normal at each point on a 3D sphere found as:
[x y z] = sphere

q = sqrt( x^2 + y^2 + z^2)
Nx = x / q
Ny = y / q
Nz = z / q

N = [Nx Ny Nz] ..... lets say for one point on the 3D sphere for clarity

And the vector A is the light vector whose angle should be found w.r.t to the normal and expressed as theta and phi (spherical coordinates) not just one angle value in 3D.
I am using matlab for this stuff so I am dealing with points on the sphere not some kind of meshes.

I would be thankful if anyone on the group can tell me what needs to be done.

Looking for feedback.....

Asad
Advertisement
An angle is only what you described (the arc-cosine of the normalized inner product). It seems to me that what you want to do is something like applying a rotation that will make the normal be (0,0,1) and see where the light vector ends up. However, that's still ill specified: The angle between the normal and the light is well defined, but the other one requires having a full reference frame, not just a normal vector.
If my understanding of your problem is correct then first you need to know what axis theta and phi are rotating about. You want to look down each axis in turn (and thus make the problem into a 2d one), work out that angle. Then I guess you will need to rotate both the next axis AND the original vector around the first axis and by the angle you worked out. Now you look down your new, rotated axis and flattern the vectors so they're 2d on a plane perpendicular to the axis your now looking down. Now its in 2d you can work out the next angle.

Hopefully that makes sense but I have my doubts.

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.

>

>An angle is only what you described (the arc-cosine of the normalized inner product). It seems to me that what you want to do is something like applying a rotation that will make the normal be (0,0,1) and see where >the light vector ends up. However, that's still ill specified: The angle between the normal and the light is well defined, but the other one requires having a full reference frame, not just a normal vector.
>


Thanks for the reply

But I didnt understand what you mean by the reference frame.
The normal vector of a point on the sphere is the reference about which I have to measure the theta angle and the projection of the normal on the surface that you can call a tangent is the other vector about which the Phi angle needs to be measured.

What I want to do is to fetch a value of BRDF (Bidirectional reflectance distribution function) for a given theta_In and phi_In and theta_View and Phi_view for rendering a sphere.
I have one light source and its direction and the viewer direction.

For simplicity lets just find the local angle of the light vector with the normal vector of a point on the sphere.
This evaluation should give me angle in the form of theta_In and phi_In for indexing in the BRDF for fetching data.
I am working with actual BRDF data and just want to render a sphere using that.

The figure of angles I need to measure is also attached for clarity.

Regards
Asad


The foot of the image you just posted explains the problem I raised: You need a tangent vector t with respect to which the phi angles will be measured.
>

>The foot of the image you just posted explains the problem I raised: You need a tangent vector t with respect to which the phi angles will be measured.
>



Yes thats true I need a tangent vector.
Can you please tell me how to get the tangent for each point on the sphere given the normal vectors at each point as described earlier?
And how will I get the desired angles after that?

[color="#1C2837"]Is this method of getting tangent correct?
[color=#1C2837][size=2]

[color=#1C2837][size=2]given Normal = N = (n1,n2,n3)

V' = ( 0,-n3, y ) if n1 is the smallest
( -n3, 0, n1 ) if n2 is the smallest
( -n2, n1, 0 ) if n3 is the smallest


[color=#1C2837][size=2]V = normalize(V')
W = N x V
[color=#1C2837][size=2]

[color=#1C2837][size=2]Asad
[color=#1C2837][size=2]

[color=#1C2837][size=2]
This all sounds very overcomplicated - what is the end result of what you're trying to achieve?

BDRF look-up? What lighting effect is it?

Cheers, Paul.

>[quote name='alvaro' timestamp='1304101848' post='4804514']
>The foot of the image you just posted explains the problem I raised: You need a tangent vector t with respect to which the phi angles will be measured.
>



Yes thats true I need a tangent vector.
Can you please tell me how to get the tangent for each point on the sphere given the normal vectors at each point as described earlier?[/quote]
No, I can't. There are many many ways of assigning a tangent for each point on the sphere (in Math such an assignment is called a foliation).

If your BRDF is isotropic, you don't really need to compute phi at all (only the difference between phi of the light vector and phi of the eye vector, which doesn't require a reference tangent vector). If your BRDF is anisotropic, which reference tangent vector you use matters, and then it's part of the description of the material.

And how will I get the desired angles after that?[/quote]
You change coordinates so the surface is now tangent to z=0 and you can then ignore the z coordinate and compute angles in 2D.

[color="#1C2837"]
Is this method of getting tangent correct?
[color="#1C2837"]
[color="#1C2837"]given Normal = N = (n1,n2,n3)

V' = ( 0,-n3, y ) if n1 is the smallest
( -n3, 0, n1 ) if n2 is the smallest
( -n2, n1, 0 ) if n3 is the smallest


[color="#1C2837"]V = normalize(V')
W = N x V
[color="#1C2837"][/quote]
[color="#1C2837"]Assuming by "y" you mean "n2" in the case where n1 is the smallest, this does result in a selection of a tangent vector everywhere, but it has discontinuities, which would probably result in visual artifacts if you had an anisotropic BRDF. You can't find a way to assign a reference tangent vector so no discontinuities appear, since every continuous 1D foliation on the sphere has a singularity. This is a fundamental obstruction of reality, not an issue with your computation.
[color="#1C2837"]

[color="#1C2837"]As wildbunny just said, you should just tell us what you are trying to achieve.
[color="#1C2837"]

[color="#1C2837"]
[quote name='alvaro' timestamp='1304167149' post='4804736']

Thanks for your reply Alvaro and Wildbunny. I am grateful that you followed the post.

I want to render a sphere using actual BRDF data from MERL (http://www.merl.com/brdf/).
I want to do it for a single light source.

To render the BRDF from MERL i need to index into the BRDF data. For that purpose I need to calculate local theta_IN, phi_IN and local theta_VIEW, phi_VIEW at each point on the sphere.
Although the MERL data is isotropic but still I want to have all the above four angles calculated.

Now the question is how to calculate theta and phi for light and view locally at each point on the sphere w.r.t to the normal at the point and the tangent / binormal?


I hope I have been very clear and precise of what I want to do.

Looking forward for some answers?

Asad

No, I can't. There are many many ways of assigning a tangent for each point on the sphere (in Math such an assignment is called a foliation).


Why "foliation" and not just "vector field?"

(I see that you can "almost" go from one to the other and back -- you definitely can locally, with the leaves as integral curves of your vector field -- but I'm not sure they're isomorphic?)


[color="#1C2837"]You can't find a way to assign a reference tangent vector so no discontinuities appear, since every continuous 1D foliation on the sphere has a singularity.


This is familiar to me if you replace "1D foliation" with "vector field;" then this is the version of the Hairy Ball Theorem I know... I guess a "singularity" in the case of a 1d foliation would be a place where one of your leaves drops a dimension (Here your leaves are (the images of) curves, and, at the points corresponding to vanishing vector fields, these degenerate into points?).

This topic is closed to new replies.

Advertisement