Essentials of Interactive Computer Graphics: Concepts and Implementation Chapter 9: Combining Transformation Operators Chapter 9 K.
Download
Report
Transcript Essentials of Interactive Computer Graphics: Concepts and Implementation Chapter 9: Combining Transformation Operators Chapter 9 K.
Essentials of Interactive Computer Graphics: Concepts and Implementation
Chapter 9:
Combining
Transformation
Operators
Chapter 9
K. Sung, P. Shirley, S. Baer
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
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation
Translate Then Scale
Given vertex:
Translate then Scale:
If
Then
And
Chapter 9
K. Sung, P. Shirley, S. Baer
Essentials of Interactive Computer Graphics: Concepts and Implementation
Example:
Chapter 9
K. Sung, P. Shirley, S. Baer
Essentials of Interactive Computer Graphics: Concepts and Implementation
K. Sung, P. Shirley, S. Baer
Concatenate:
Compact Representation
Computation Efficiency
Cost to concatenate
Worthwhile if uses operator many times
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
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation
K. Sung, P. Shirley, S. Baer
Example: Order of operation
For:
If
and
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!!
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation
Inverse Transform: Undo
Chapter 9
K. Sung, P. Shirley, S. Baer
Essentials of Interactive Computer Graphics: Concepts and Implementation
For example:
Chapter 9
K. Sung, P. Shirley, S. Baer
Essentials of Interactive Computer Graphics: Concepts and Implementation
Inverse of:
To undo (inverse):
If:
Then
Or:
Chapter 9
K. Sung, P. Shirley, S. Baer
Essentials of Interactive Computer Graphics: Concepts and Implementation
Inverse of:
Chapter 9
K. Sung, P. Shirley, S. Baer
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) …
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 rectangle
by S(3,0.5) with
a fixed anchor (Vc)
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation
Pivoted Scaling:
Scaling with respect to
Pivot position:
E.g., scale rectangle
with respect to
pt=(1,5)
Chapter 9
K. Sung, P. Shirley, S. Baer
Essentials of Interactive Computer Graphics: Concepts and Implementation
K. Sung, P. Shirley, S. Baer
Rotation with Arbitrary Pivot
Pivot position:
E.g., rotate rectangle
with respect to
top-right corner (pr)
pt=(3,8)
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
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
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
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
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation
K. Sung, P. Shirley, S. Baer
Tut 9.4: Pivoted Scale/Rotate
Implements:
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation
Tut 9.4: … details …
Label C computes:
Chapter 9
K. Sung, P. Shirley, S. Baer
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
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
Chapter 9
Essentials of Interactive Computer Graphics: Concepts and Implementation
Lib9: D3D_DrawHelper
Chapter 9
K. Sung, P. Shirley, S. Baer
Essentials of Interactive Computer Graphics: Concepts and Implementation
Lib9: XformInfo class
Set/Get:
Scale/Translate/Rotate
Pivot
SetupModelStack():
Calls DrawHelper’s
AccumulateModelTransform()
Chapter 9
K. Sung, P. Shirley, S. Baer
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
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
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()
Chapter 9