0

Anybody can explain about appendRotation, appendTranslation functions of Matrix3D with clear example?

ketan
  • 19,129
  • 42
  • 60
  • 98
user
  • 165
  • 1
  • 11
  • possible duplicate of [Can anyone recommend some Transformation Matrix tutorials for dummies?](http://stackoverflow.com/questions/2697611/can-anyone-recommend-some-transformation-matrix-tutorials-for-dummies) – Vesper Jul 03 '15 at 12:46

1 Answers1

0

The manual on Matrix3D

Performing complex 3D transformations

Basically, the explanation will derive to transformation of a three-dimensional orthogonal basis in a 3D space with a fixed basis. Each transformation can be viewed as a composition of transformations, and can be (technically) split into a sequence of scale, rotation and translation transformations. The order of the sequence matters.

Each "simple" transformation, be it rotation, scale, translation or perspective, is described by a 4x4 matrix known in AS3 as Matrix3D. You can refer to Matrix for 2D transformation, because the underlying principle is the same. There is also the "zero transformation" matrix, also known as "identity matrix", that describes transformation where nothing moves anywhere, and it looks like this:

[1,0,0,0]
[0,1,0,0]
[0,0,1,0]
[0,0,0,1]

So, when you need to create a transformation, you start with this matrix, then you start multiplying it rightwards with various matrices describing intended steps.

appendTranslation multiplies the matrix with a translation matrix, that looks like this, where x,y,z are the parameters:

[1,0,0,x]
[0,1,0,y]
[0,0,1,z]
[0,0,0,1]

appendScale's matrix looks like this:

[xScale,0,     0,     0]
[0,     yScale,0,     0]
[0,     0,     zScale,0]
[0,     0,     0,     1]

appendRotation creates a matrix that describes rotation around axis vector that starts from the pivotPoint position in the transformed object's coordinate system. The transformation is so that the pivot point and all the points that are on the axis vector remain in place, while others are rotated degrees counterclockwise, if looking down the axis from the pivot point. The actual examples are too heavy to calculate by hand, but a simple rotation matrix around an axis can be built, they look like this (cos and sin stand for Math.cos(angle) and Math.sin(angle) respectively):

Rotation around X axis:

[1,0,  0,   0]
[0,cos,-sin,0]
[0,sin,cos, 0]
[0,0,  0,   1]

Rotation around Y axis:

[cos,0,-sin,0]
[0,  1,0,   0]
[sin,0,cos, 0]
[0,  0,0,   1]

Rotation around Z axis:

[cos,-sin,0,0]
[sin,cos, 0,0]
[0,  0,   1,0]
[0,  0,   0,1]

After you add all the desired matrices via appendXXX functions, your matrix will contain values that correspond to the complete transformation.

This topis requires additional reading, and a lot of it, here are some links to books and tutorials on 3D transformations.

Community
  • 1
  • 1
Vesper
  • 18,599
  • 6
  • 39
  • 61