Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jaforsgren/1b6a4b97c34b5239b76c8c046e11f018 to your computer and use it in GitHub Desktop.
Save jaforsgren/1b6a4b97c34b5239b76c8c046e11f018 to your computer and use it in GitHub Desktop.
Maxscript: finds the angle between two vectors
-- 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