330 likes | 466 Views
3D Transformation. Transformation. A transformation is an operation that transforms or changes a shape . There are several basic ways you can change a shape: Translation (moving it) Rotation (turning it round) Scaling (making it bigger or smaller). Shear (changing the main shape).
E N D
Anil Verma, IOE Pulchowk Transformation • A transformation is an operation that transforms or changes a shape . • There are several basic ways you can change a shape: • Translation (moving it) • Rotation (turning it round) • Scaling (making it bigger or smaller). • Shear (changing the main shape). • Reflection (mirroring the shape about axis). • Transforming an object means transforming all of its points
Anil Verma, IOE Pulchowk 3D Transformation Same as 2D. Add z-axis and z-coordinate. Use 4X4 homogenous matrix. In part I, we discussed translation, rotation and scaling.
Anil Verma, IOE Pulchowk 3D Translation
Anil Verma, IOE Pulchowk 3D Scaling (relative to the origin point) x, y and z values multiplied by scaling factors sx, sy and sz
Anil Verma, IOE Pulchowk 3D Scaling (relative to the origin point)
Anil Verma, IOE Pulchowk 3D Scaling (relative to fixed point) Fixed point
Anil Verma, IOE Pulchowk 3D Scaling (relative to fixed point) • Scaling with a Selected Fixed Position y y y y x x x x z z z z Original position Translate Scaling Inverse Translate
Anil Verma, IOE Pulchowk 3D Scaling (relative to fixed point) • for general scaling (relative to fixed point F) • where
Anil Verma, IOE Pulchowk 3D Rotation • Coordinate-Axes Rotations • X-axis rotation • Y-axis rotation • Z-axis rotation • General 3D Rotations • Rotation about an axis that is parallel to one of the coordinate axes • Rotation about an arbitrary axis
Anil Verma, IOE Pulchowk 3D Rotation – (z-axis) • Rotating around the z axis:
Anil Verma, IOE Pulchowk 3D Rotation – (x-axis) • Rotation around the X axis:
Anil Verma, IOE Pulchowk 3D Rotation – (y-axis) • Rotation around the Y axis:
Anil Verma, IOE Pulchowk General 3D Rotations • Rotation about an Axis that is Parallel to One of the Coordinate Axes • Translate the object so that the rotation axis coincides with the parallel coordinate axis • Perform the specified rotation about that axis • Translate the object so that the rotation axis is moved back to its original position
Anil Verma, IOE Pulchowk General 3D Rotations • Rotation about an Arbitrary Axis • Basic Idea • Translate (x1, y1, z1) to the origin • Rotate (x’2, y’2, z’2) on to the z axis • Rotate the object around the z-axis • Rotate the axis to the original orientation • Translate the rotation axis to the original position y T (x2,y2,z2) R (x1,y1,z1) R-1 x T-1 z
Anil Verma, IOE Pulchowk y (x2,y2,z2) (x1,y1,z1) x z ArbitraryAxis Rotation • Step 1. Translation
Anil Verma, IOE Pulchowk ArbitraryAxis Rotation • Step 2. Establish [ TR ]xx axis y (0,b,c) (a,b,c) Projected Point x z Rotated Point
Anil Verma, IOE Pulchowk ArbitraryAxis Rotation • Step 3. Rotate about y axis by y (a,b,c) l Projected Point d x (a,0,d) Rotated Point z
Anil Verma, IOE Pulchowk ArbitraryAxis Rotation • Step 4. Rotate about z axis by the desired angle y l x z
Anil Verma, IOE Pulchowk ArbitraryAxis Rotation • Step 5. Apply the reverse transformation to place the axis back in its initial position y l l x z
Anil Verma, IOE Pulchowk Example Ex) Find the new coordinates of a unit cube 90º-rotated about an axis defined by its endpoints A(2,1,0) and B(3,3,1). A Unit Cube
Anil Verma, IOE Pulchowk y B’(1,2,1) x z Example • Step1. Translate point A to the origin A’(0,0,0)
Anil Verma, IOE Pulchowk Example • Step 2. Rotate axis A’B’ about the x axis by and angle , until it lies on the xz plane. y Projected point (0,2,1) B’(1,2,1) l x z B”(1,0,5)
Anil Verma, IOE Pulchowk Example • Step 3. Rotate axis A’B’’ about the y axis by and angle , until it coincides with the z axis. y l x (0,0,6) B”(1,0, 5) z
Anil Verma, IOE Pulchowk Example • Step 4. Rotate the cube 90° about the z axis Finally, the concatenated rotation matrix about the arbitrary axis AB becomes,
Anil Verma, IOE Pulchowk Example
Anil Verma, IOE Pulchowk Example • Multiplying [TR]AB by the point matrix of the original cube
Anil Verma, IOE Pulchowk 3D Reflection • Reflection Relative to the xy Plane • [Do also Reflection Relative to the yz,zx Plane...] y y z x z x
Anil Verma, IOE Pulchowk 3D Shear Z-axis shear Where a and b are the shear factors for x and y respectively. Do, X-axis and Y-axis shear.