Site Stability Read more... ×

# Angle Calculation

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

## 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 on other sites
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 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 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 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.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 15
• 21
• 26
• 11