Sign in to follow this  
cntz

Placement of model on top of other model

Recommended Posts

Hi everybody, My problem is as follows: Given initial orientation and normal vectors and target orientation and normal vectors, I want to be able to transform the initial vectors to the target vectors. Assume that the orientation and normal vectors are orthogonal. My current, non working, solution's pseduo-code: 1. Let N,O be the initial normal and orientation vectors respectivly, Let N',O' be the TARGET normal and orientation vectors respectivly. 2. NormalRotationAxis = CrossProduct(N,N') 3. Normalize(NormalRotationAxis) 4. AngleBetweenNormals = GetAngle(N,N') 5. targetN = Rotate N AngleBetweenNormals degress about NormalRotationAxis axis 6. newOrientation = Rotate O AngleBetweenNormals degress about NormalRotationAxis axis 7. AngleBetweenOrientations = GetAngle(newOrientation,O') 8. targetO = Rotate newOrientation AngleBetweenOrientations degrees about targetN. At the end of this code targetN = N' but targetO != O'. I can't figure out why. As you can see, i'm taking a 2 step approach. First Match normals, then find out how much to rotate about the matched normal or match the orientations. Is this approach wrong? Is there an easier approach? If there's nothing wrong with this i'll post a more detailed implementation. Thanks! Y.

Share this post


Link to post
Share on other sites
well if the normal is changing, and O can only rotate around it. Depending on how you compute the angle, you're going to get wonky results. You need to project O into the plane of N' before computing the angle from O to O'.. since it is the angle in this plane that you will be looking for (if i understood you method right). If these are 3d vectors And you rotate O about N' to reach O' I dont see how it ever would since N to N' is rotated about an arbitary axis. It is this axis (at least) that O must rotate about, if not it's own unique axis.

In other words, If you did the same procedure for O as you did for N, and did not make the rotation of O dependent on N', then they both would produce the correct results (since N to N' is correct).

NRotation.FromCrossResult(Cross(N, N'));
newN = NRotation * N; //this works so far for you

So just do

ORotation.FromCrossResult(Cross(O, O'));
newO = ORotation * O;


Good luck, hopefully that was remotely helpful.

The only reason I can think of that you'd need to do this is if you wanted to interpolate to the final position, then you can scale NRotation by the interpolation value to compute intermediate N and O's.

How ever, if you simply want to compute the final transform, i dont see why you'd need the incremental change.

Since you already know N', is newN = N' not sufficient?
It would also be very easy to compute the final transformation based only off N' and O'.

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

Sign in to follow this