Jump to content
  • Advertisement
Sign in to follow this  
marcus12

Angle Calculation

This topic is 2444 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,
I want to find the angle between the ray of Light (Red) and the Normal (Blue) at different point of contact as shown
in figure.

From the figure the two points of the Black LINE are (700.0f, 500.0f) and (700.0f, 300.0f). The logic I am THINKING is to get the slope of the

Black line with two points ie m = y1-y2/(x1-x2) in this case its infinity

using this get the equation of line perpendicular to BLACK, which can be taken as the NORMAL to the black line.

The RED line which is ray of light is represented using vector with 1) Origin 2) Direction

I am confused in how to get the angle between the Normal (Blue) and the ray (RED) ie the angle 'A' as shown in figure


All suggestions are welcome

Share this post


Link to post
Share on other sites
Advertisement
If you have two normalized direction vectors a and b, you can computer the angle between them using the dot product. See http://en.wikipedia.org/wiki/Dot_product#Geometric_interpretation .

Share this post


Link to post
Share on other sites
You seem to just need a this formula for the angle between two vectors:

angle(v,w) = acos(dot_product(v,w))

Share this post


Link to post
Share on other sites

You seem to just need a this formula for the angle between two vectors:

angle(v,w) = acos(dot_product(v,w))



Ok..If one of the vector is the RAY of light (Red) .

Then how to represent the NORMAL ( blue) line as a vector? given only two points representing the BLACK line as shown in figure

Share this post


Link to post
Share on other sites

[quote name='alvaro' timestamp='1318088057' post='4870513']
You seem to just need a this formula for the angle between two vectors:

angle(v,w) = acos(dot_product(v,w))



Ok..If one of the vector is the RAY of light (Red) .

Then how to represent the NORMAL ( blue) line as a vector? given only two points representing the BLACK line as shown in figure
[/quote]

Subtract the two points to get a vector along the black line. Then swap the coordinates and change the sign of one of them to get a perpendicular vector.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!