First every vector in the plane can be mapped to the 2 by 2 square centered at the origin by dividing both components of the vector by the magnitude of the larger of the two components. So (3,6), the larger of the two components is 6 so divide both components by 6 and get (1/2,1), which is a point on the square. For (-5,-2) the magnitude of the larger component is 5 so divide both by 5 and get (-1,-2/5) which is the corresponding point on the square.
To find the angle between 2 square normalized vectors find the distance around the square to get from one coordinate to another. In this case from (1/2,1) you have to go left 1+1/2 and then down 1 and 2/5 to get -2.9 because you're going counterclockwise. From the other vector it would be 2.9 clockwise.
It's an algorithm rather than a direct math quantity to find the square angle because of the complications first in finding the normalized square vector, that you have to divide by the largest component which is hard to put as a formula, and then in finding a formula for the distance around the square without using modular arithmetic or absolute values etc..., but it is nice that the angles around always add to 8, squangle(a,b)+squangle(b,c)=squangle(a,c) and counterclockwise comparison is always a negative angle, etc...
**Note
I thought at first there would be a sort of distortion from the corners but there really isn't, consider the square angle between (0,1) and (1,0) and between (1,1) and (1,-1) are both 2 even though one consists of just a straight line and the other goes around a corner. Any two vectors that the angle between them would ordinarily be 90 degrees the square angle is 2, 30 degrees 2/3 etc... This relationship makes it possible to use the algorithm to find the square angle, then convert to the regular angle without having to ever use a trigonometric function like cosine. I think a proof of that could be start anywhere as a normalized square vector, add the square angle to itself as many times as will fit in 8, that has to map exactly to an angle of a certain number of degrees added to itself as many times as it goes into 360 because either way you went all the way around.
No comments:
Post a Comment