Jump to content
otto

How to get Y rotation from point normal?

Recommended Posts

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? 

Capture.JPG

angle.hipnc

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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 by StepbyStepVFX
  • Thanks 1

Share this post


Link to post
Share on other sites

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 :P

Edited by otto

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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 :-)

  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×