Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S....
-
Upload
damon-hubbard -
Category
Documents
-
view
226 -
download
0
description
Transcript of Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S....
![Page 1: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/1.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Chapter 9: Combining Transformation Operators
![Page 2: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/2.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
This Chapter: we will learn How and Costs of combine operators Inverse Operators Pivoted Scale/Rotate Programming Support
UWBGL
![Page 3: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/3.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Given vertex: Translate then Scale: If
Then
And
Translate Then Scale
![Page 4: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/4.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Example:
![Page 5: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/5.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Compact Representation
Computation Efficiency Cost to concatenate Worthwhile if uses operator many times
Concatenate:
![Page 6: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/6.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
!Warning! Order of operation Recall …
So, if
Then, in general
![Page 7: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/7.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Example: Order of operation For: If and
![Page 8: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/8.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Reminder … Transforms Va
Translation (T) followed by Scale (S)
Vertex is to the left of the operators!!
In our case (row vectors): the following is undefined!!
![Page 9: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/9.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Inverse Transform: Undo
![Page 10: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/10.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
For example:
![Page 11: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/11.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
To undo (inverse):
If:
Then
Or:
Inverse of:
![Page 12: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/12.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Inverse of:
![Page 13: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/13.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
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) …
![Page 14: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/14.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Combining Translation and Scaling
Translate before scale to align vertex with origin “anchor” the vertex
E.g., scale rectangleby S(3,0.5) witha fixed anchor (Vc)
![Page 15: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/15.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Pivoted Scaling: Scaling with respect to
Pivot position:
E.g., scale rectanglewith respect topt=(1,5)
![Page 16: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/16.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Rotation with Arbitrary Pivot Pivot position:
E.g., rotate rectanglewith respect totop-right corner (pr)pt=(3,8)
![Page 17: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/17.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Tut 9.1: Simple Concatenation
Label B + C: Ma = S T Label D: loads Ma to MW All vertex goes through
V MW MV MP Rectangle transform by:
V Ma
![Page 18: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/18.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Tut 9.2: Order or concatenation
GUI Check box controls m_bTranslateFirst
Label B: Ma=ST or Ma=TS
![Page 19: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/19.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
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
![Page 20: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/20.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Tut 9.3: Working with Matrix Stack
Label C: Top of Stack <- ST Label D: Top of Stack <- TS Label E: MW<- Top of Stack
![Page 21: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/21.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Tut 9.4: Pivoted Scale/Rotate Implements:
![Page 22: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/22.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Tut 9.4: … details …
Label C computes:
![Page 23: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/23.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
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
![Page 24: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/24.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Lib9: Drawing with MatrixStack
DrawHelper: Defines the Stack behavior
D3D_DrawHelper Defines D3D Matrix Stack
![Page 25: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/25.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Lib9: D3D_DrawHelper
![Page 26: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/26.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Lib9: XformInfo class Set/Get:
Scale/Translate/Rotate Pivot
SetupModelStack(): Calls DrawHelper’s
AccumulateModelTransform()
![Page 27: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/27.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Tut 9.6: Using XformInfo Identical to 9.5 … using XformInfo
![Page 28: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/28.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Tut 9.7: XformInfoControl CXformInfoControls class (MFC
Dialog) Replace onto main
TutorialDlg With a placeholder
![Page 29: Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 9 Chapter 9: Combining Transformation Operators.](https://reader034.fdocuments.net/reader034/viewer/2022051105/5a4d1b8b7f8b9ab0599befbd/html5/thumbnails/29.jpg)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer
Using CXformInfoControl CModel must support
Label B: GetSelectedXform() SetSelectedXform()
CXformInfoControl Access model’s selected xform From theApp->GetModel().Get/Set selectedXform()