In C# I have the following code:
Vector2.Dot(ref tmpDirection, ref direction, out result);
This returns a float between -1 and 1. I am curious how to get this same functionality in Objective-C. I know you can calculate the dot product of two vectors like so:
CGPoint point1 = CGPointMake(10, 10);
CGPoint point2 = CGPointMake(20, 20);
float dotProduct = point1.x * point2.x + point1.y + point2.y;
What I do not understand is what the C# function does to make the result between -1 and 1 as normal dot product math can result in any number.
All you need to do to get this normalized from [-1,1] is to divide by the product of the magnitudes: