Heyo!
I am trying to set up a popnet that will kill points based on the angle at which that point has struck a collision object.
What I /think/ I need to do is to take the normal (N) of the closest point on hit and compare it to the direction that the point was moving in 3d space when it detected the hit (v)
I've been reading that I can use the dot function to get the angle, but my basic knowledge of math hasn't been enough for me to understand many concepts when trying to jump right into something like this.
I would appreciate anyone who could let me know if I have the right idea and just need to learn some math, or if I would need a different approach.
Also, clarification on how the popcollisiondetect attributes 'hitnml' and 'hitv' work would be great. I would like to be able to use hitnml as the (N) value of the collider a point hits, and 'hitv' as the (v) of the point on collision, but I'm unsure if that's actually how they work. The wording in the documentation seemed a little vague.
Thank you for reading, I'll clarify anything as needed and appreciate any help.
-Kevin
Finding the angle at which a point is hitting a surface
1081 3 1-
- drivebyfruity
- Member
- 6 posts
- Joined: 4月 2021
- オフライン
-
- animatrix_
- Member
- 5100 posts
- Joined: 2月 2012
- オフライン
Hi,
You can compute the angle between 2 vectors in VEX robustly like this:
You can use v@hitnml and @v rather than v@hitv as you want the velocity of the particle not the hit geometry:
You can compute the angle between 2 vectors in VEX robustly like this:
float computeAngleBetweenVectors ( vector v0; vector v1 ) { vector v0n = normalize ( v0 ); vector v1n = normalize ( v1 ); return degrees ( atan2 ( length ( cross ( v0n, v1n ) ), dot ( v0n, v1n ) ) ); }
You can use v@hitnml and @v rather than v@hitv as you want the velocity of the particle not the hit geometry:
computeAngleBetweenVectors ( v@hitnml, @v );
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
-
- RGaal
- Member
- 143 posts
- Joined: 6月 2024
- オフライン
-
- animatrix_
- Member
- 5100 posts
- Joined: 2月 2012
- オフライン
RGaal
Isn't it easier to just use acos(dot(v1,v2))?
The atan2 method accounts for the sign of the cross product, which allows it to distinguish between angles greater than 180 degrees.
It's more robust than the acos(dot) method, especially when the vectors are nearly parallel where acos(dot) might run into issues with numerical precision when the dot product is close to 1 or -1.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
-
- Quick Links


