Jump to content

How to get Y rotation from point normal?


otto

Recommended Posts

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
Link to comment
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
Link to comment
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?

Link to comment
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
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...