# rotate to normal

Hi . . . I’m trying to use GEO instancing to replace the Copy SOP and what I want to do is be able to pull normals from geometry and use that data to rotate instances to the normals. I’ve tried using a SOPto CHOP to grab the normals and then scaling from -1, 1 to -179, 179 . . . it is kind of close, but not right. I’m sure there’s some math I’m missing to make the proper conversion, any ideas ?

Hey Jeff,
I’ve run into similar problem. Have you managed to figure it out?
I’ve made this scene - I want to rotate the instanced geometry to face the centre. Had a few weak attempts but the maths is beyond me.
rotateInstanceToNormal.1.toe (8.04 KB)

Hi Tom,

No, I haven’t gotten anything to work yet. I did some research and tried a few things in the Point SOP, but no luck. Seems like it should be a fairly straightforward transform, but beyond my current knowledge.

Jeff

I think you’ll need the object CHOP to calc the rotation, but it seems to be broken in the latest experimental

Hmm, yeah that does seems like a good direction. But as you say it appears to be broken, from what I’ve found the second input to the object CHOP is inop.

Played around a bit here. I think the main crux of the problem is that any rotate parameter for an object or instance is concerned with the rotation about that particular axis, where as when you grab the normals from the points of a SOP you are getting the vector components of each normal.

So here’s what I was trying to do in the attached file:

For each rotation parameter you need the angle to rotate it about that axis. So in the expression CHOP I am finding the angle between a normalized ‘reference’ vector and a vector with the two components of the normal that are not the axis I am rotating about ( setting the axial component to 0). This should give the angle of rotation about each axis.

I am still not getting the exact correct result, but I know there are a few things loose that need to be figured out, and maybe I’m still missing something…

Firstly, I think in order to work you need to set the transform order for the instances so that rotate happens first, because I believe the instance transforms happen about the overall COMP’s pivot, right? I haven’t played with the rotational orders, but this may also be something that needs to be adjusted.

The main conflict that I think is going on is that when rotating about an axis, you have to choose what ‘zero’ is. The way I’m doing it is choosing a sort of ‘bearing’ reference vector for each axis, but I’m just not sure which ones will make everything match up. For instance if you are rotating about the Y-axis, your bearing vector can be (0,0,1) or (1,0,0).

Anyways, I think I’m on the right path, as the instances seem to have more order to their rotations, even though not going directly along the normals yet. Anybody from on high know what we’re missing?

Seems like the object CHOP is pretty useful, and it doesn’t seem broken for me, but perhaps we should put in an RFE for instance rotations using normal vectors or some such thing. Or perhaps if there were some new expressions that mimicked the vorigin() or vrorgin() methods for instances instead of object/components?
10-0316_Rotate Normals Messing_001.toe (7.89 KB)

Hey, I saw in another post that object CHOP is broken in the latest experimental, but has been fixed for the next experimental release. I’m looking forward to getting home tonight and playing about with this scene but I guess it wont work for me until the new release comes out…

Hey TP.

Yeah, I don’t know, I played with the Object CHOP for a second and it didn’t seem broken using 5167, but it seems you can only compare locations of COMP objects with names, and not instances.

I am not using the Object CHOP in the file I posted previously, just some expression stuff with the normals. Still not sure if it’s right, because I think my order of rotation is wrong as well.

Let us know if you find anything!

object CHOP works again, here’s the solution
rotateInstanceToNormal_AK.toe (8.49 KB)

Great, thanks ! Just what I needed.

Jeff

Likewise, great post Achim.
Tom

I’m working on the same thing.
I can’t get the rotateInstanceToNormal_AK.toe file to open in the most recent version of Touch: it encounters a fatal error. Want to tell me how you solved it?

Thanks.

That crash will be fixed in build 6107 or later. Thanks for pointing it out.

There was also an error in the Object CHOP when using two input CHOPs.
This has now been fixed in the next release.
In the previous example, all donuts now individually face outwards, and are not
affected by the current frame.
Sorry bout that.

Rob.

achim

you rock. i was just facing this problem and your solve worked perfectly. thank you !

best,

scott

thank you sir

excellent! exactly what i was looking for… i had gotten as far as pulling the normals out and Math CHOPping the range and it was looking all wonky. Thanks so much!