Alain2131 Posted August 16, 2020 Share Posted August 16, 2020 (edited) Hi there ! The title might not be clear much, so let me try to explain. I'm trying to compute the angle of each points inside of a hole in a geometry. By searching a bit, I found float angle = degrees(acos(dot(normal_pt, nn_pt)));, which works, but there is an issue with my specific case. The blue angles are fine (simply by luck, coming from the shape of the hole), but the red ones are incorrect. Instead, I want to get the orange angle. That's pretty easy, I can do 360-angle. But the issue is when. How do I detect those issues, to be able to apply the fix ? Alternatively, I tried using the Measure SOP to compute this all for me, but I didn't find how to use it in this manner. But knowing Houdini, there probably is some node or VEX function that can compute this for me already =P Thanks ! getHoleAngles.hipnc Edited August 16, 2020 by Alain2131 Quote Link to comment Share on other sites More sharing options...
Aizatulin Posted August 16, 2020 Share Posted August 16, 2020 (edited) Hi, acos(dot(v1,v2)) is always getting the smallest angle between two vectors. If you want to get orange angles, you have to add an orientation information like a point normal. With the normal and the first edge you can construct a plane, to determine, if the second vector is on the positive or negative side. getHoleAngles_mod.hipnc @edit: I am not sure, if this solution works in every case, because it probably depends if the hole is on the left or right side <- but this should work because the angle will change aswell .... Edited August 16, 2020 by Aizatulin 3 1 Quote Link to comment Share on other sites More sharing options...
eimk Posted August 16, 2020 Share Posted August 16, 2020 Another way to do this is to construct a matrix from the point normal and your two vectors, then find the determinant of the matrix and use it and the dot product to find the angle. vector N = point(0, "N", P0); float dot = dot(v0, v1); matrix3 mat = set(v0.x, v1.x, N.x, v0.y, v1.y, N.y, v0.z, v1.z, N.z); float det = determinant(mat); return (360 + degrees(atan2(det, dot))) % 360; getHoleAngles.hipnc 2 1 Quote Link to comment Share on other sites More sharing options...
Alain2131 Posted August 16, 2020 Author Share Posted August 16, 2020 Hi @Aizatulin, that works like a charm ! To be honest, I tried to figure out the logic of it, but I guess my intuition and understanding will develop as I use it in various situation. Right now, I'm having trouble wrapping my head around it, even if it's just a simple dot product -_-' @eimk, thanks for the alternative method ! I'll have to take a look at it later, and figure out that determinant thing Thanks to you both again, I appreciate it ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.