# Unexpected results using Vector3.Angle()

Hi there,

I realize there must be a misunderstanding on my part in the maths behind how angles are calculated between vectors so I thought I’d ask here.
Before I begin: this is a 2d problem:

I have an origin (8.9,2.3)
and three points

• (4,2)
• (-11.5,0)
• (4,1.6)

my goal is to find which points are struck first when sweeping a ray counterclockwise from the origin.

In the visual example provided, you can see that (4,2) should be struck first, followed by (4, 1.6) and finally (-11.5,0) - but I am getting counter intuitive results using Vector3.Angle to find the angle between these points

According to all sources I’ve used, (-11.5, 0) lies on a ray 2.9 degrees ccw from (4.2) and (4,1.6) lies on a ray 4.62 degrees ccw from 4.2 (using (8.9,2.3) as our origin)

• WolframAlpha query:

VectorAngle[{4-8.9,2-2.3},{4-8.9,1.6-2.3}]
in degrees

4.627 deg

• WolframAlpha query:

VectorAngle[{4-8.9,2-2.3},{-11.5-8.9,0-2.3}]
in degrees

2.929 deg

My question is this: Why?

Based on the visual example provided I would have expected different results.

Ah thank you!

Wouldn’t you know it? Spend hours working on an issue only to find the answer 20 mins after posting the question! I’ve realize that the answer to my question was that I was using points rather than directions in my Vector3.cross call (to determine direction). Something that I entirely failed to mention because I didn’t think the issue resided there!

Vector3 cross = Vector3.Cross(direction1,direction2);
int sign = 0;
if(cross.z>sign){
sign = 1;
}
else{
sign = -1;
}

Although this doesn’t explain why wolfram alpha returns said results… Any Math people care to explain?