Jump to content
• Advertisement

Angle Calculation

This topic is 2626 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

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

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

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

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

Share on other sites

• Advertisement
• Advertisement

• Popular Contributors

1. 1
2. 2
Rutin
22
3. 3
4. 4
khawk
14
5. 5
• Advertisement

• 13
• 26
• 10
• 11
• 44
• Forum Statistics

• Total Topics
633743
• Total Posts
3013643
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!