Presentation is loading. Please wait.

Presentation is loading. Please wait.

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 7 Geometric Transformation.

Similar presentations


Presentation on theme: "Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 7 Geometric Transformation."— Presentation transcript:

1 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 7 Geometric Transformation

2 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 2 Objectives F To describe transformations related to 3D graphics F To construct 3D affine transforms including translation, rotation, scaling, shearing, and reflections F To understand and apply transformation matrices F To apply transforms in scene graphs F To construct and apply composite transformations F To apply transforms in constructing geometries

3 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 3 Affine Transformation In homogeneous coordinates 3D affine transformation

4 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 4 Matrix Classes Matrix3f Matrix3d Matrix4f Matrix4d GMatrix void add(Matrix4d m1) void sub(Matrix4d m1) void mul(Matrix4d m1) void invert() void add(Matrix4d m1, Matrix4d m2) void sub(Matrix4d m1, Matrix4d m2) void mul(Matrix4d m1, Matrix4d m2) void invert(Matrix4d m1) void transpose() void mul(double scalar) double determinant() Source Run

5 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 5 Transform3D Class Translation Scale void set(Vector3d trans) void set(Vector3f trans) void setTranslation(Vector3d trans) void setTranslation(Vector3f trans) void set(double scale) void setScale(double scale) void setScale(Vector3d scales)

6 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 6 Reflection and Shear Reflection Shear

7 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 7 3D Rotation About z-axis Set a general rotation in Transform3D void set(AxisAngle4d r)

8 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 8 Quaternion and 3D Rotation A rotation defined by quaternion operations θ is the angle of rotation and u defines the axis of rotation through the origin A point represented as a pure quaternion

9 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 9 Euler Angles F Use three rotations about the coordinate axes F Different Names: –(elevation, azimuth, tilt) –(roll, pitch, yaw) –(precession, nutation, spin) –(heading, altitude, bank) F Transform3D method void setEuler(Vector3d eulerAngles)

10 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 10 Quaternion to Euler Angle Conversion public static Vector3d quatToEuler(Quat4d q1) { double sqw = q1.w*q1.w; double sqx = q1.x*q1.x; double sqy = q1.y*q1.y; double sqz = q1.z*q1.z; double heading = Math.atan2(2.0 * (q1.x*q1.y + q1.z*q1.w),(sqx - sqy - sqz + sqw)); double bank = Math.atan2(2.0 * (q1.y*q1.z + q1.x*q1.w),(-sqx - sqy + sqz + sqw)); double attitude = Math.asin(-2.0 * (q1.x*q1.z - q1.y*q1.w)); return new Vector3d(bank, attitude, heading); } SourceRun

11 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 11 TransformGroup Node SourceRun

12 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 12 Composite Transforms Source Run A useful pattern

13 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 13 Transform3D methods void transform(Point3d p) void transform(Point3d p, Point3d pOut) void transform(Point3f p) void transform(Point3f p, Point3f pOut) void transform(Vector3d v) void transform(Vector3d v, Vector3d vOut) void transform(Vector3f v) void transform(Vector3f v, Vector3f vOut) void transform(Vector4d v) void transform(Vector4d v, Vector4d vOut) void transform(Vector4f v) void transform(Vector4f v, Vector4f vOut)

14 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 14 Shape Construction Extrusion: Extend a 2D shape to 3D Source Run Source Rotation: For example, constructing a torus

15 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 15 Transformation and Shared Branch Source Run


Download ppt "Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 7 Geometric Transformation."

Similar presentations


Ads by Google