Forked from JokerMartini/Finding Angle Between Two Vectors | .ms
Created
June 16, 2017 06:45
-
-
Save jaforsgren/1b6a4b97c34b5239b76c8c046e11f018 to your computer and use it in GitHub Desktop.
Maxscript: finds the angle between two vectors
This file contains 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