Rotate 3D Object On the Spot RRS feed

  • Question

  • Hi all,
            I would like to know how I can rotate a 3d object on its own axis. It is a 3d Cube. Everytime I try - it keeps rotating about a point outside itself - in a circle. I tried setting the center of the rotation but it doesnt work.


    Monday, February 9, 2009 10:53 PM

All replies

  • Thanks for the links. Unfortunately it doesnt contain the solution I was looking for. Is there some sort of algorithm for calculating the centre?
    Tuesday, February 10, 2009 2:04 PM
  • OK. Before the following code is executed I transform the 3d model in the viewport

            Dim myNumx As Integer = tx.Text 
            Dim myNumy As Integer = ty.Text 
            Dim myNumz As Integer = tz.Text 
            Dim myNumAngel As Integer = ta.Text 
            Dim XV As New Vector3D(myNumx, myNumy, myNumz) 
            Dim AAR As New AxisAngleRotation3D(XV, myNumAngel) 
            Dim myRotateTransformTry As New RotateTransform3D(AAR) 
            myRotateTransformTry.CenterX = V.Children.Item(0).Transform.Value.OffsetX 
            myRotateTransformTry.CenterY = V.Children.Item(0).Transform.Value.OffsetY 
            myRotateTransformTry.CenterZ = V.Children.Item(0).Transform.Value.OffsetZ 
    V.Children.Item(0).Transform = myRotateTransformTry


    Tuesday, February 10, 2009 2:11 PM
  • As you can see, I tried setting the center of the rotation to the new coordinates of the 3d object after its transformed.
    Tuesday, February 10, 2009 2:14 PM
  • Hi,

    Please download my article which is related to cube


    here i have bind x axis,y axis and z axis of cube to the slider.

    Just above binding I have given all offset to zero. so that here in my example only x axis used to rotate in center, but not other 2 axis.

    <TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0"/> 

    now you just update OffsetY="-0.5"

    <TranslateTransform3D OffsetX="0" OffsetY="-0.5" OffsetZ="0"/> 

    so that all x,y and z axis will rotate in center.

    I hope this will help you :)

    Prasad - www.beautifulmind.blog.co.in
    • Proposed as answer by prasad22 Thursday, February 12, 2009 6:30 PM
    Thursday, February 12, 2009 6:30 PM
  • Yes. Thank you for your article. I would like to do what you are proposing using code.
    Thursday, February 12, 2009 7:53 PM