Download presentation
Presentation is loading. Please wait.
Published byDamon Hubbard Modified over 9 years ago
1
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators
2
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 This Chapter: we will learn How and Costs of combine operators Inverse Operators Pivoted Scale/Rotate Programming Support UWBGL
3
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Given vertex: Translate then Scale: If Then And Translate Then Scale
4
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Example:
5
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Compact Representation Computation Efficiency Cost to concatenate Worthwhile if uses operator many times Concatenate:
6
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 !Warning! Order of operation Recall … So, if Then, in general
7
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Example: Order of operation For: If and
8
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Reminder … Transforms V a Translation (T) followed by Scale (S) Vertex is to the left of the operators!! In our case (row vectors): the following is undefined!!
9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Inverse Transform: Undo
10
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 For example:
11
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 To undo (inverse): If: Then Or: Inverse of:
12
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Inverse of:
13
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Inverse of concatenated operator Apply the inverse in reverse order! In general: Inverse is not unique E.g., R(θ), inverse can be R(-θ) or R(-θ+360), or R(- θ+270) …
14
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Combining Translation and Scaling Translate before scale to align vertex with origin “anchor” the vertex E.g., scale rectangle by S(3,0.5) with a fixed anchor (V c )
15
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Pivoted Scaling: Scaling with respect to Pivot position: E.g., scale rectangle with respect to pt=(1,5)
16
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Rotation with Arbitrary Pivot Pivot position: E.g., rotate rectangle with respect to top-right corner (pr) pt=(3,8)
17
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Tut 9.1: Simple Concatenation Label B + C: M a = S T Label D: loads M a to M W All vertex goes through V M W M V M P Rectangle transform by: V M a
18
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Tut 9.2: Order or concatenation GUI Check box controls m_bTranslateFirst Label B: M a =ST or M a =TS
19
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Matrix Stack: Push-down stack of matrices Graphics API support for concatenation of transform operators (matrices) Operations supported Push Pop Concatenation Translate/scale/rotate Load/Store
20
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Tut 9.3: Working with Matrix Stack Label C: Top of Stack <- ST Label D: Top of Stack <- TS Label E: M W <- Top of Stack
21
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Tut 9.4: Pivoted Scale/Rotate Implements:
22
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Tut 9.4: … details … Label C computes:
23
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Tut 9.5: Transform Primitives Label C1/C2: push/pop Label D: set up transform for Drawing rectangle 1 Label F: set up transform for Drawing rectangle 2
24
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Lib9: Drawing with MatrixStack DrawHelper: Defines the Stack behavior D3D_DrawHelper Defines D3D Matrix Stack
25
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Lib9: D3D_DrawHelper
26
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Lib9: XformInfo class Set/Get: Scale/Translate/Rotate Pivot SetupModelStack(): Calls DrawHelper’s AccumulateModelTransform()
27
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Tut 9.6: Using XformInfo Identical to 9.5 … using XformInfo
28
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Tut 9.7: XformInfoControl CXformInfoControls class (MFC Dialog) Replace onto main TutorialDlg With a placeholder
29
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Using CXformInfoControl CModel must support Label B: GetSelectedXform() SetSelectedXform() CXformInfoControl Access model’s selected xform From theApp->GetModel().Get/Set selectedXform()
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.