Re: [c# .net 2005] problem with moving start of world

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Piotrek Alchemik" <p.pietruszka@xxxxxxxxx> wrote in message
news:1138136286.948773.29550@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> i have small problem with creating my small project. I need to simulate
> some kind of arm. I am doing this by create few separate cubes, and
> trying to connect them in one point.
> I declare the cubes:
[clip]
> The problem i'm trying to solve is that when i rotate using yAngle, the
> first cube rotate exactly around the z line, which is created at the
> bottom of my first cube. The second one is located at the top of first
> one, but unfortunetly is rotating at the point, where started the first
> cube.
> Maybe can somebody help me solving my problems? Any idea how to move
> point 0,0,0 for second cube and force her to rotate around that point?

First, note that combining matrices through multiplication is not
commutative, unlike scalar multiplication. That is, the order by which you
multiply the matrices will effect the results. For example, rotation *
translation will produce a different result than translation * rotation -
it's the difference between moving an object then rotating it around its new
location, versus rotating an object around its original location then moving
it. Simply switching the order of the multiplication may take care of your
problem, though I'm not sure of the exact results you are looking for so it
may be more than that.

If you want to rotate around a specific point in space independent of the
final translation, then you need to translate the object so the center of
rotation is the origin, rotate it, translate it back to its origin, then
translate it to the desired location. An easy shortcut for this would be to
use the Matrix.AffineTransformation method, which lets you specify a
rotation center, a translation, a quaternion specifying the rotation, and a
scaling factor. If you look in the documentation for this function you'll
find the series of transformations I described above documented.

If you are going to be rendering a hierarchy of objects that are dependent
upon each other, you might want to check out the MatrixStack and Frame
classes as well.

--
Robert Dunlop
The X-Zone
http://www.directxzone.com/
Microsoft DirectX MVP
-------------
The opinions expressed in this message are my own personal views and do not
reflect the official views of the Microsoft Corporation.
The MVP program does not constitute employment or contractual obligation
with Microsoft.



.



Relevant Pages

  • rotating the vertices of a cube/triangle into position
    ... rotate the vertices before they are placed into the vertex buffer. ... and a particular set of rotation parameters? ... How do I rotate a cube around its center? ... I have done some rotation ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Graphic transforms
    ... rotation is not about the desired rotation point. ... before rotating since scaling is on two different axis, ... one must apply scale, then rotate, then translation. ...
    (microsoft.public.dotnet.languages.vc)
  • Having problems solving a 3D transformation matrix equation.
    ... center - a translation matrix, no rotation ... then translates everything by eyepoint. ... So, given old center, old rotate, old eyepoint, and NEW center, I need ...
    (sci.math)
  • Rubiks cube - rotation of the centres
    ... some of the squares have writing on ... I got this cube in a mixed up state. ... I've now completed the cube and also worked out how to rotate the ... rotation if there is only one other centre to be rotated. ...
    (rec.puzzles)
  • Re: Properly combining a Rotation and Translation matrix? (linear algebra)
    ... Vector3 containing a translation I wish to perform, ... defining a rotation I wish to perform. ... Suppose you want to rotate an object about a point. ... Lets suppose our object is simply a triangle made up by the points ...
    (sci.math)