| v . w |
cos theta =______
||v|| ||w||
Where V and W are vectors. Vector V<%a,%b> and Vector W<%c,%d>. The top part of the equation is called Dot Product in which (%a*%c) + (%b*%d)..... X values multiplied together added to the Y values multiplied together. The bottum part is the magnitudes of the vectors multiplied together which can be found by pythagorean theorem. Find the absolute value of the entire equation. Flip it to ArcCosine and BOOM! you got yourself an angle. Just thought I would explain the equation to anyone who didn't already know it.
So what I need is a simple function Angles(%a,%b,%c,%d)
Here is what I am thinking
function Angles(%a,%b,%c,%d)
{
%dot1=%a*%c;
%dot2=%b*%d;
%product=%dot1+%dot2;
%dotproduct=mAbs(%product);
%asquared=mPow(%a,2);
%bsquared=mPow(%b,2);
%magvector1=mSqrt(%asquared*%bsquared);
%csquared=mPow(%c,2);
%dsquared=mPow(%d,2);
%magvector2=mSqrt(%csquared*%dsquared);
%bottumpart=%magvector1*%magvector2;
%runningoutofvariablenames=%dotproduct/%bottumpart;
%theta=mAcos(%runningoutofvariablenames);
%theta1=%theta*180/3.14159265;
echo(%theta1);
}
I keep getting 0 degrees on all angles. HELP D: