Jump to content
  • Advertisement
Sign in to follow this  
cntz

Placement of model on top of other model

This topic is 3461 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!