1
$\begingroup$

I am new to Transformation of 3D objects by matrices, but I think I understand it quite good at this point but I have a problem which I do not understand.

Let's say I have an object with some vertices describing all the points in 3D. They are vectors of type Float, so $p \in \mathbb{R}^3$ is a point in 3D.
I know that I can translate, rotate and scale the object with a 4x4 Matrix. I read on another site that I can transform this object with respect to the global or local coordinate system.
Lets say $T1, T2, Ry$ are three 4x4 Matrices. $T1,T2$ are translations and $Ry$ is a rotation around the y-axis.

If I multiply from right to left: $T1*T2*Ry*M$ where $M$ is the matrix representing the object and I use column-major in my matrix, I calculate the Transformation with respect to the global coordinate system, which I want.

Problem: The problem is that there are 2 possible ways that I thought of to create a rotation around the center of the object with respect to the global coordinate system. They seem equal to me, but one works and the second doesn't.

Let $move, center \in R^3$ be 2 vectors, where $move$ represents the movement of the object in 3D space. I basically store all of the translation in this vector. $center$ is the center of the object. I need to calculate it, translate it by center back to the origin, rotate it, and translate it back. This way I rotate always around the center of the object independently of how much I move the object. So my calculation looks like this:

myObjekt.setTransformation(Translation(myObjekt.getTransformation().translation())
            * Translation(center) 
            * RotationY(angle) 
            * Translation(center).invert()
            * myObjekt.getTransform().getRotation());

What I do is, starting from bottom to top, I take the matrix from my object and take only the rotation part. This way I remove the translation and my object will be at $(0,0,0)$ in the matrix. Then I move it $-center$ (negative vector or invert() works the same way), which results in the object being right at the origin with its center.

Then I rotate around some angle and move the object back by center. Since the object needs to be placed back at the position where it was, I take with Translation(myObjekt.getTransformation().translation() only the translation part of the matrix from my object and create a translation matrix based on the translation vector. Then I set this Matrix as my new Matrix and am done.
This Doesn't seem to work, because the objects start drifting in circles away from me.
But if I change it to:

myObjekt.setTransform(Translation(move + center)
    * RotationY(angle)
    * Translation(move + center).invert()
    * myObjekt.getTransform());

it seems to Work.

The only thing I changed is I move the object with the center to the origin instead of removing all the translation I have done from the Matrix. In my opinion this shouldn't matter, because move = myObjekt.getTransformation().translation(), but it does and I don't understand why.

$\endgroup$
  • $\begingroup$ Welcome to math.SE! It seems like German or a related language may be your native language -- keep in mind that capitalization rules between English and German are very different, and that "object" and "vector" are spelled with "c" in English (as opposed to "k" in German) -- also the pronoun "I" is always capitalized, and "be", although it sounds the same as "bee", is spelled differently, with only one "e", not two. $\endgroup$ – bazookabear Mar 17 '17 at 13:23
  • $\begingroup$ Hi, jeah i am from Germany. Thanks for the edit. $\endgroup$ – Chibu Mar 17 '17 at 15:33
  • $\begingroup$ Der deutsche/europäische "j" Laut ist mit einem "y" auf Englisch geschrieben, d.h. "yeah" ist die richtige Buchschreibung. Bitte merken Sie Sich, das man das Pronomen "I" immer großschreibt. $\endgroup$ – bazookabear Mar 17 '17 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.