otto Posted April 15, 2018 Share Posted April 15, 2018 Hi! I have a simple setup where a set of points are facing the camera. I would like to get the points rotation around the y axis so that I can give them different attribute values based on that. How can I calculate this value? angle.hipnc Quote Link to comment Share on other sites More sharing options...
Noobini Posted April 16, 2018 Share Posted April 16, 2018 i tinkered a bit here...you can use attribrandomize to adjust the variance...but it's not answering your question directly tho... (i animated the camera) angle_mod.hipnc Quote Link to comment Share on other sites More sharing options...
otto Posted April 16, 2018 Author Share Posted April 16, 2018 Thanks Noobini, randomness is great. But yes, I would like to know how many degrees the point needed to rotate around the y axis to aim towards the camera, compared to its initial value. Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted April 16, 2018 Share Posted April 16, 2018 (edited) 44 minutes ago, otto said: Thanks Noobini, randomness is great. But yes, I would like to know how many degrees the point needed to rotate around the y axis to aim towards the camera, compared to its initial value. Use a Point Wrangle, and for each point calculate the vector that goes from the camera to each point, normalize it, calculate the dot product of this vector and the normalized « aim » vector of the camera (I don’t know what kind of setup you have, if the camera will move etc... but it should be easy to compute or to create), and use the arccosine trigo function to get the angle (should be Y if the aim vector and the « target » vector toward each points are in the horizontal plane) Hope this helps Edited April 16, 2018 by StepbyStepVFX 1 Quote Link to comment Share on other sites More sharing options...
otto Posted April 17, 2018 Author Share Posted April 17, 2018 Thanks for the pointers, @StepbyStepVFX. My knowledge of VEX isn't great, but I'll give it a go. Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted April 17, 2018 Share Posted April 17, 2018 I will try to open your file and post a result when i can access my computer (when will there be a houdini version for iPad ??? :-) 1 Quote Link to comment Share on other sites More sharing options...
galagast Posted April 17, 2018 Share Posted April 17, 2018 Hi, I've attached a file where I added a point attribute called "angle", the computation is based on a forward direction. Is this what you were after? H16.5.438 Apprentice angle_v2.hipnc 1 1 Quote Link to comment Share on other sites More sharing options...
otto Posted April 17, 2018 Author Share Posted April 17, 2018 (edited) Thank you so much @galagast! This was exactly what I wanted. I did a small change, I connected the input normal of the point, before it was aimed towards the camera, and connected that to the dot product node and it works like a charm. Thanks for the time, to both of you. Yes, would it be great with iPad support, @StepbyStepVFX, we could bring Houdini with us everywhere Edited April 17, 2018 by otto Quote Link to comment Share on other sites More sharing options...
otto Posted April 18, 2018 Author Share Posted April 18, 2018 Hello again I have another newbie question. Is it possible to get negative values for the angles as well? The dot product and arccosine calculation seems to only give positive values. In my setup I have a bunch of points with normals all pointing in one direction. I run them through the calculation described above by @StepbyStepVFX and @galagast aiming the normals towards the camera and calculation the angle. If you look at the image I first posted and the center value is zero (as the original normal is pointing directly towards the camera), I am now getting positive values that increase towards the edges of the image on both side. I was sort of expecting one of the sides to be negative, as the angles are opposite compared to the original normal. Is it possible to get negative values as well? Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted April 19, 2018 Share Posted April 19, 2018 7 hours ago, otto said: Hello again I have another newbie question. Is it possible to get negative values for the angles as well? The dot product and arccosine calculation seems to only give positive values. In my setup I have a bunch of points with normals all pointing in one direction. I run them through the calculation described above by @StepbyStepVFX and @galagast aiming the normals towards the camera and calculation the angle. If you look at the image I first posted and the center value is zero (as the original normal is pointing directly towards the camera), I am now getting positive values that increase towards the edges of the image on both side. I was sort of expecting one of the sides to be negative, as the angles are opposite compared to the original normal. Is it possible to get negative values as well? Indeed, arcosine cannot know if your angle is x or 2*Pi - x, as both of them have same cosine. To work fully, you will need to build an up-vector, make a cross product between your up-vector and your « aim vector » (direction where camera is pointing), and make a new dot product between this new vector and the vector « camera-point » (as before). If they are in the same direction, dot product should be positive, and hence the arcosine gives you the right angle, if this is negative, then you have to take 2*Pi - arcosine. Just review if I am not mistaken myself in trigonometry before implementing that, I doing it quickly wihtout verification :-) 1 Quote Link to comment Share on other sites More sharing options...
otto Posted April 19, 2018 Author Share Posted April 19, 2018 You are a star, @StepbyStepVFX! That worked, thanks! 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.