mesure angle between 3 points

   11095   6   2
User Avatar
Member
120 posts
Joined: June 2008
Offline
hi,
before, happy new year..

i have perhaps a simple question, but for me, it's not..

i try to measure angle between 3 points.
My problem is i don't know where start..
i find acos function, and trigonometric function.. But there is no informations on this..
Please, someone can explain me very very slowly how create this?
Thank you very much for all help.

Sorry for my english..

Best regards
User Avatar
Member
577 posts
Joined: Nov. 2005
Offline
angle in radians is acos(dot(v1, v2))
v1 and v2 are the normalized edgevectors that define the angle
User Avatar
Member
21 posts
Joined: Feb. 2012
Offline
I'm not really a math guy, so here's my artists explanation.

The first thing you want to do is get the two vectors that form the edges of the angle you are measuring. A vector can be found by subtracting one points position from another one. The direction the vector is pointing is dependent on the subtraction order of operations. So for example:

A - B points from B to A.
B - A points from A to B.

When doing this for points in 3D space you need to subtract all of the X/Y/Z positions to get a 3D vector. So that looks like this:

Bx - Ax
By - Ay
Bz - Az

Then you make a vector out of those 3 floats. This is pretty easy in Houdini because you can add a float vector 3 parameter to just about any node. After this you can plug in these vectors into the formula above. You have to account for Houdini's syntax which can be a little weird, so I've attached an example .hip file where I'm finding the angle between the edges 0->1 and 0->2

Here is some explanation of the syntax used in my example. Look at the “measure_angle” node to see the values and formulas.

point(“../single_triangle”, 1, “P”, 0) - point(“../single_triangle”, 0, “P”, 0)
This subtracts the X position of point 1 from the X position of point 0. You can read more about point() here http://www.sidefx.com/docs/houdini12.0/expressions/point [sidefx.com]. I do this for X, Y and Z in my example to get the vectors from 0->1 and 0->2.

acos(dot(normalize(vector3(ch(“vec_p0_p1x”), ch(“vec_p0_p1y”), ch(“vec_p0_p1z”))), normalize(vector3(ch(“vec_p0_p2x”), ch(“vec_p0_p2y”), ch(“vec_p0_p2z”)))))
This looks like a lot, but what I've done is what sanostol posted above, acos(dot(v1, v2)) where v1 and v2 are normalized vectors. I'm referencing the channels where I stored the output of the vectors to make the expression smaller and easier to read.
Edited by - Jan. 4, 2013 18:38:11

Attachments:
measure_angle.hip (58.8 KB)

User Avatar
Member
4729 posts
Joined: Feb. 2012
Offline
Hi,

You can also use this VOP to do it for you:
http://www.orbolt.com/asset/animatrix::angleBetween::1.00 [orbolt.com]

It's open source if you want to know how it works.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
120 posts
Joined: June 2008
Offline
hi, thank you very much for your help..
for this moment, i want try orbolt.. it seem best way for me…
but now, i must find how it work..
i created a vopsop node.. but where i connect?
I search..
thank you very much.
Best regard

i say you when i succeed
User Avatar
Member
120 posts
Joined: June 2008
Offline
to mattv,
Thank you very much for your file.. it’s really perfect for me..
now, i want check your file for learn..

very thank you.

Best regard and see you.
User Avatar
Member
4729 posts
Joined: Feb. 2012
Offline
Hi,

It's very easy. Just provide 2 vectors calculated from your 3 points. Assuming they are like this:



then (B-A) for the first input, (C-A) for the second input.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
  • Quick Links