Created
August 3, 2015 22:06
-
-
Save JokerMartini/26c356f5761fcdac087d to your computer and use it in GitHub Desktop.
Maxscript: finds the angle between two vectors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Option 1 | |
fn GetVectorsAngle v1 v2 = | |
( | |
theAngle = acos(dot (normalize v1) (normalize v2)) | |
) | |
vA = obj2.pos - obj1.pos -- vector between two objects | |
vA = obj3.pos - obj1.pos -- vector between two objects | |
GetVectorsAngle vA vB | |
-- Option 2 | |
v1 = [4,3,0] - [0,3,10] | |
v2 = [3,0,0] - [0,2,10] | |
v1 = [4,0] | |
v2 = [3,-2] | |
nv1 = normalize v1 | |
nv2 = normalize v2 | |
dotProduct = (nv1.x * nv2.x) + (nv1.y * nv2.y) | |
acos dotProduct | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment