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
mesure angle between 3 points
11034 6 2- supermac
- Member
- 120 posts
- Joined: 6月 2008
- Offline
- sanostol
- Member
- 577 posts
- Joined: 11月 2005
- Offline
- mattv
- Member
- 21 posts
- Joined: 2月 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.
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 - 2013年1月4日 18:38:11
- animatrix_
- Member
- 4703 posts
- Joined: 2月 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.
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
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
- supermac
- Member
- 120 posts
- Joined: 6月 2008
- Offline
- supermac
- Member
- 120 posts
- Joined: 6月 2008
- Offline
- animatrix_
- Member
- 4703 posts
- Joined: 2月 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.
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
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