Upload
others
View
6
Download
0
Embed Size (px)
Citation preview
COMPUTER GRAPHICS COURSE
Georgios Papaioannou โ 2016
Transformations
ABOUT TRANSFORMATIONS
โข They are operators on vectors and points of a corresponding vector or affine space
โข They alter the coordinates of shape vertices
โข They are basic building blocks of geometric design:
โ Help us manipulate shapes to produce new ones
โ Help us express relations between coordinate systems in a virtual world
Transformations
Affine Transformations
โข An affine transformation ฮฆ on an affine space is a transformation that preserve affine combinations
โข For shapes in ๐ผ2 and ๐ผ3 this is an important property:
โข To transform a shape we only need to transform its defining vertices
๐ฉ =
๐=0
๐
๐๐๐ฉ๐ โนฮฆ ๐ฉ =
๐=0
๐
๐๐ฮฆ(๐ฉ๐)
Affine Transformations on Vertices
โข Example:
โข The midpoint of the transformed endpoints is the transformed midpoint
โ Similarly, all transformed points on the line segment can be linearly interpolated form the transformed endpoints
ฮฆ(๐ฉ1)
ฮฆ(๐ฉ0)
๐ฉ1
๐ฉ0
ฮฆ
ฮฆ
Affine Transformations in 2D and 3D
โข Mappings of the form ฮฆ ๐ฉ = ๐ โ ๐ฉ + ๐ญ are affine transformations in ๐ผ2 and ๐ผ3
โข 2D:
โ ๐ is a 2X2 matrix and
โ ๐ญ is an offset vector in matric column form: ๐ญ = ๐ก๐ฅ ๐ก๐ฆ๐
โข 3D:
โ ๐ is a 3X3 matrix and
โ ๐ญ is an offset vector in matric column form: ๐ญ = ๐ก๐ฅ ๐ก๐ฆ ๐ก๐ง๐
Linear Transformations
โข Linear transformations are affine transformations with the following properties:
โ Preserve additivity: ฮฆ ๐ฉ + ๐ช = ฮฆ ๐ฉ +ฮฆ ๐ช
โ Preserve scalar multiplication: ฮฆ ๐๐ฉ = cฮฆ ๐ฉ
โข Important:
โ The affine transformation ฮฆ ๐ฉ = ๐ โ ๐ฉ + ๐ญ is not linear (why?)
โ But the transformation ฮฆ ๐ฉ = ๐ โ ๐ฉ is!
2D TRANSFORMATIONS
Geometric Transformations in 2D
โข The 4 common transformations that are used in computer graphics are:
โ Translation
โ Rotation
โ Scaling
โ Shearing
โข All of the above transformations are invertible, i.e. given ฮฆ ๐ฉ , there always exists the inverse transformation ฮฆโ1 ๐ฉ :
๐ฉโฒ = ฮฆ ๐ฉ โบ ๐ฉ = ฮฆโ1 ๐ฉโฒ
,
,
T( )
R( )
S( )
Sh( )
sx sy
sx sy
p Ip t
p R p
p S p
p Sh p
2D Translation
โข Moves a point on the plane
Y
X
๐ฉโฒ = ๐๐ฉ + ิฆ๐ญ = ๐ฉ + ิฆ๐ญ
๐ก๐ฅ
๐ก๐ฆ
(๐๐ฅ, ๐๐ฆ)
(๐๐ฅ + ๐ก๐ฅ, ๐๐ฆ + ๐ก๐ฆ)
2D Scaling
โข When ๐ ๐ฅ = ๐ ๐ฆ, then the scaling is isotropic
(preserves angles)Y
X
(2, 2)
(2, 5)
(3, 7)
(4, 5)
(4, 2)
Y
X
(4, 1)
(4, 2.5)
(6, 3.5)
(8, 2.5)
(8, 1)
๐๐ ๐ฅ,๐ ๐ฆ =๐ ๐ฅ 00 ๐ ๐ฆ
๐ฉโฒ = ๐๐ ๐ฅ,๐ ๐ฆ๐ฉ
2D Rotation
โข Rotates a point around the origin by angle ฮธ
cos cos cos sin sin cos sin
sin cos sin sin cos sin cos
x l l x y
y l l x y
,x y p
,x yp
Y
X
l
lฮธ
ฯ
๐๐ =cos ๐ โ sin ๐sin ๐ cos ๐
๐ฉโฒ = ๐๐๐ฉ
2D Rotation - Examples
Rotations are always relative to the coordinate system origin!
2D Shearing
โข Skews the shape by translating a point in one axis proportionally to its coordinate on the other axis
X
(6, 2)(8, 2)
(10, 4) (12, 4)
Y
X
(2, 2) (4, 2)
(2, 4) (4, 4)
Y
(2, 6)
(2, 8) (4, 10)
(4, 12)Y
X
b=2 ฮฑ=2
๐๐ก๐ฅ,๐ =1 ๐0 1
๐ฉโฒ = ๐๐ก๐ฅ,๐๐ฉ
๐๐ก๐ฆ,๐ =1 0๐ 1
๐ฉโฒ = ๐๐ก๐ฆ,๐๐ฉ
Composite Transformations
โข Useful transformations in computer graphics and visualization rarely consist of a single basic affine transformation
โข Transformation composition is the stacking of operators (function composition):
โข We can efficiently compute composite linear transformations
ฮฆ โ ฮ ๐ฉ = ฮฆ(ฮ ๐ฉ )
Composite Linear Transformations (1)
โข A useful property of linear transformations is that a composite transformation can be expressed as matrix multiplication:
โข In graphics, it allows the efficient computation of multiple composite transformations
ฮฆ โ ฮ ๐ฉ = ๐ฝ โ ๐ช โ ๐ฉ
โข Example:
Composite Linear Transformations (2)
๐ 45o ๐1,2 ๐ฉ = ๐45o๐1,2๐ฉ
โข Transformations are not commutative in general!
Composite Linear Transformations (3)
๐45o๐1,2๐ฉ โ ๐45o๐1,2๐ฉ
Composite Linear Transformations (4)
โข Unfortunately, translation cannot be expressed as a linear transformation and is therefore impossible to express it as a matrix multiplication
โข We must convert the transformation to a linear one
Homogeneous Coordinates (1)
โข With homogeneous coordinates, we augment the dimensionality of the space by one
โข So ๐ฅ, ๐ฆ ๐ coordinates become ๐ฅ, ๐ฆ, ๐ค ๐
โข Similarly, all transformations are now expressed as 3X3 matrices
โ For w=1 we get the basic representation of a point: ๐ฅ, ๐ฆ, 1 ๐
โ All points which are multiples of each other are equivalent
โ Typically, we work with the basic representation of points
Homogeneous Coordinates (2)
โข Therefore the 2D space becomes a plane (slice) embedded in 3D space at w=1
Homogeneous Coordinates (3)
โข Points on the homogeneous 2D plane define an affine space and not a vector space
โ Adding two vectors results in a vector outside the plane (remember we also add the w coordinates!)
โข The origin of our homogeneous coordinate system is typically (0,0,1) (or (0,0,w) in general)
โข Since addition is not defined in our space, how is translation expressed?
Homogeneous Transformations (1)
โข Translation in our augmented, homogeneous space can be expressed as a linear transformation:
โ (it is actually a skew (shearing) transformation of x,y w.r.t. w in 3D)
๐ฅโฒ
๐ฆโฒ
๐ค
=1 0 ๐ก๐ฅ0 1 ๐ก๐ฆ0 0 1
๐ฅ๐ฆ๐ค
๐ค=1๐ฅโฒ, ๐ฆโฒ = ๐ฅ, ๐ฆ + (๐ก๐ฅ, ๐ก๐ฆ)
๐ค = 1(๐ก๐ฅ, ๐ก๐ฆ)
๐ฅ, ๐ฆ
Homogeneous Transformations (2)
โข Now all geometric transformations can be performed by matrix multiplication alone!
โข We can arbitrarily combine transformations in a unified manner
๐ ๐1 ๐ต๐ฏ1 ๐ ๐2 ๐ต๐ฏ2 ๐๐ 1,๐ 2 โฆ ๐ฉ โฆ = ๐๐1๐ป๐ฏ1๐๐2๐ป๐ฏ2๐๐ 1,๐ 2
โฆ๐ฉ
Homogeneous 2D Transformations
โข In matrix form (3X3) the homogeneous 2D transformations become:
๐๐ =cos ๐ โ sin ๐ 0sin ๐ cos ๐ 00 0 1
๐๐ ๐ฅ,๐ ๐ฆ =๐ ๐ฅ 0 00 ๐ ๐ฆ 0
0 0 1
๐๐ก๐ฅ,๐ก๐ฆ =1 0 ๐ก๐ฅ0 1 ๐ก๐ฆ0 0 1
๐๐ก๐ฅ,๐ =1 ๐ 00 1 00 0 1
๐๐ก๐ฆ,๐ =1 0 0๐ 1 00 0 1
Representing Shape Transformations
โข In the following, we will apply transformations to entire shapes
โข This is equivalent to applying the transformations on each defining vertex of the shape
โข Notation:
๐1 โ ๐2 โ ๐ ๐๐๐ก = ๐1 โ ๐2 โ ๐ฏ1 ๐ฏ2 ๐ฏ3 ๐ฏ4 = ๐1 โ ๐2 โ๐ฅ1 ๐ฅ2 ๐ฅ3๐ฆ1 ๐ฆ2 ๐ฆ31 1 1
๐ฅ4๐ฆ41
shape shape vertices
Categorizing the Transformations
โข Affine: preserve linear combinations
โข Linear: can be expressed by a concatenation of matrices, preserve parallel lines
โข Similitudes: preserve ratios of distances and angles
โข Rigid: preserve distances
Inverse Transformations
โข The inverse of geometric transformation is the inverse matrix ๐โ1 of the original transformation ๐
โข The inverse of a concatenated transformation is the concatenation of the inverse matrices in reverse order:
โข Inverse of standard transformations:
๐1๐2๐3โฆ๐๐โ1 = ๐๐
โ1โฆ ๐3โ1๐2
โ1๐1โ1
๐๐โ1 = ๐โ๐ ๐๐ ๐ฅ,๐ ๐ฆ
โ1 = ๐ 1๐ ๐ฅ,1๐ ๐ฆ
๐๐ก๐ฅ,๐ก๐ฆโ1 = ๐โ๐ก๐ฅ,โ๐ก๐ฆ
Shape Composition
โข We can use geometric transformations to create complex shapes from simple primitive ones
โ We use the transformations to modify instances of the original shapes and arrange them in their pose in the composite object
Original primitives (object space coords) Composite object Colored object
2D Transformation Example (1)
โข Given the following primitives
โข Build this:
1 1
1
2
yy
x x
y
x
1
0.5
1
4
31 1
A B
2D Transformation Example (2)
โข First, let us try to decompose the target shape into primitives:
โข Observe that in 2D we can order primitives in different layers to hide parts of the geometry
โข Second, locate the origin of the resulting shape and compare it to the one of the primitives
?
Three shape groups:
- Chassis
- Wheels
- Windshield
2D Transformation Example (3)
โข Chassis (3XB parts)
โข Looks like no scaling is required, just translations and rotations
โข Now observe where the pivot point should end in each one:
y
x
C1 C2 C3
y
x
C1 C2 C3
B
2D Transformation Example (4)
โข C1: Rotate +90 degrees (remember, it is a CCW system)
โข Then translate by (1, 2.5)
y
x
C1
B
y
x
C1
2.5
1
โข The transformation then is:
C1 = ๐(1.0,2.5)๐๐2B
Important!
Rightmost transformations are applied first to the shapes
(vertices)
Here, we first rotate then translate
2D Transformation Example (5)
y
x
C1
B
y
x
C1
๐๐2๐(1.0,2.5)B โ C1
Important!
Order of transformation does matter
(remember: transformations are relative to origin)
2D Transformation Example (6)
โข Now lets do C2: This only requires a translation
y
x
C1 C2 C3B
C2 = ๐(3.0,0.5)B
2D Transformation Example (7)
โข C3: Rotate 180 degrees, then translate
y
x
C1 C3C2
B
y
x
C1 C3C2
C3 = ๐(2.0,1.5)๐๐B
2D Transformation Example (8)
โข The windshield Wd is a single piece
โข Although it is not a rotated version of B, it has a slightly different scale in the X axis, giving it a more slanted slope
y
x
C1 C3C2
B
Wd = ๐(4.0,1.5)๐1.5,1.0B
y
x
C1 C3C2
B
Wd Wd
2D Transformation Example (9)
y
xB
๐1.5,1.0B
Important!
If you want to leave one coordinate unchanged, use a
scaling factor of 1
y
xB
๐1.5,0.0B
Wrong!
Never, ever zero the scaling factors!
This collapses the shape and the operation is irreversible (try inverting the corresponding
scaling matrixโฆ)
2D Transformation Example (10)
โข The wheels are easy to add since they are identical and only require a uniform scaling and translation
โข Room for optimization:
โ Create a โwheelโ object (by scaling once the original shape A)
โ Then only perform the translation:
y
x
C1 C3C2
Wheel = ๐0.5,0.5A
Wdy
xA
Wheel
W1 = ๐(1.0,0.5)Wheel
W2 = ๐(3.0,0.5)Wheel
Let us Add Some Animation (1)
โข What if instead of the flat-colored wheels we had a more interesting shape that would look better if rotated?
โข What if the car could also move forward?
y
x
y
x
Let us Add Some Animation (2)
โข Again, we need to decompose the problem and prioritize the motion:
โ Clearly, the wheels must be rotated around their axis
โ This must take place before moving them off the origin
โ The wheels should move in par with the rest of the car
โ Therefore, the translation of the car should happen after the composition of the entire vehicle
y
x
Let us Add Some Animation (3)
โข To spin the wheels, we must apply a rotation to the โwheelโ entity, before translation
โข Uniform scale and rotation can be safely interchanged
โข We rotate according to a user-defined angle ฮธ(t)
โข So, the new Wheel is:
y
x
y
x
-ฮธ(t)
Wheel = ๐โ๐(๐ก)๐0.5,0.5A
Note: Now the angle is negative, since this is a CW rotation
Let us Add Some Animation (4)
โข Now to more efficiently apply the forward motion to the entire car, letโs:
โ First group all of its components
โ Then apply the translation to the โcarโ group
y
x
y
x
Car ๐๐๐ฃ๐๐๐๐ถ๐๐ = ๐(๐ (๐ก),0.0)Car
๐ (๐ก)
Let us Add Some Animation (5)
โข Congratulations! You have just made your first transformation hierarchy, i.e. dependent transformations
โข More on this in the Scene Management chapter
y
x
Mirroring (1)
โข Via the scaling transformation, we can perform a switch of sides of the coordinates along an axis, by negating the scaling factor:
y
x
๐โ1,1
๐1,โ1
Mirroring (2)
โข However, caution must be exercised because mirroring changes the order of the vertices from CCW to CW and vice versa
โข This can seriously impact many algorithms that depend on the correct ordering of the vertices (see Rasterization and shading)
โข So, mirroring is best avoided, unless a re-ordering of the vertices can be done y
x
๐ฏ0
๐ฏ1
๐ฏ2๐ฏ2
๐ฏ1
๐ฏ0
Viewport Transformation (1)
โข Shape coordinates on the 2D canvas or image plane are expressed relative to a global absolute coordinate system, which is independent of the output device size and resolution
โ E.g. a pdf document page has the 2D origin at one corner and may be measured in real units, such as centimeters
โข The viewport transformation maps the coordinate system of the 2D canvas (image plane) to that of the actual viewport that the image should be generated in
Viewport Transformation (2)
Global reference system and
units (e.g. cm)
Viewport (pixel units)
Viewport Transformation (3)
โข What steps does the viewport transformation involve?
โ Definitely, we must first express the shapes relative to the corner of the window
โ We must scale the units
โ We must then express the contents of the window relative to the viewportโs shifted location in the image buffer (or screen)
Viewport Transformation (4)
โข Express the shapes relative to the corner of the window:
โ โsubtractโ the window corner from the point coordinates โmoveโ the point and the window so that the two coordinate systems coincide:
x
y
y
x
12
4
5.5 ๐ฉ
๐ฉ๐ค = ๐ฉ โ ๐จ๐ค = ๐โ๐จ๐ค๐ฉ
๐จ๐ค
y
x
12
๐ฉ๐ค
๐ฉ๐ค
Viewport Transformation (5)
โข Now we must map the canvas units to the viewport size. Two options usually:
โ We are given a fixed โpoints-per-unitโ metric (e.g. dpi โdots per inch), which is directly the scaling factor (can be different in x and y)
โ We are given the final resolution of the actual window, in โpointsโ (pixels), in which case, we must derive the x, y scaling factors:
y
x1cm
2cm
๐ค (๐๐)
โ(๐๐)
y
x100 pixels
220
pixels
๐ฉ๐ฃ
๐๐๐ ๐ฅ
๐๐๐ ๐ฆ๐ฉ๐ฃ = ๐๐๐๐ ๐ฅ๐ค ,
๐๐๐ ๐ฆโ
๐ฉ๐ค
Viewport Transformation (6)
โข Finally, we must (optionally) express the viewport coordinates w.r.t. the screen or drawing buffer:
x
y
4
5.5
๐ฉ๐ ๐๐๐๐๐ = ๐ฉ๐ฃ + ๐จ๐ฃ = ๐๐จ๐๐ฉ๐ฃ
๐จ๐ฃ
y
x
๐ฉ๐ฃ
๐๐๐ ๐ฅ
๐๐๐ ๐ฆ
x
y
764 px
470 px
๐จ๐ฃ
y
x
๐ฉ๐ ๐๐๐๐๐
๐๐๐ ๐ฅ
๐๐๐ ๐ฆ
Drawing area
3D TRANSFORMATIONS
About 3D Transformations
โข Going to 3D, means adding one more coordinate, the z direction
โข All 3D vectors are now expressed as 4-element columns in homogeneous coordinates
โข All transformations become 4X4 matrixes
โข Nothing else changes
A Third Dimension. Now What?
โข Translation and scaling are augmented by a z coordinate
โข Rotation:
โ We now have three coordinate axes to rotate around
โ In 2D, shapes revolved around a โzโ axis perpendicular to the plane
โ In 3D, this becomes the rotation around Z
โ โฆ and we also introduce a rotation around X and around Y
3D Geometric Transformations (1)
Translation:
Scaling:
๐๐ ๐ฅ,๐ ๐ฆ,๐ ๐ง =
๐ ๐ฅ 0 0 00 ๐ ๐ฆ 0 0
0 0 ๐ ๐ง 00 0 0 1
๐๐ก๐ฅ,๐ก๐ฆ,๐ก๐ง =
1 0 0 ๐ก๐ฅ0 1 0 ๐ก๐ฆ0 0 1 ๐ก๐ง0 0 0 1
zx
y
zx
y
zx
y
zx
y
3D Geometric Transformations (2)
Rotation around Z:
Rotation around X:
Rotation around Y:
๐๐ง,๐ =
cos ๐ โ sin ๐ 0 0sin ๐ cos ๐ 0 00 0 1 00 0 0 1
๐๐ฅ,๐ =
1 0 0 00 cos ๐ โ sin ๐ 00 sin ๐ cos ๐ 00 0 0 1
๐๐ฆ,๐ =
cos ๐ 0 sin ๐ 00 1 0 0
โ sin ๐ 0 cos ๐ 00 0 0 1
zx
y
zx
y
zx
y
zx
y
Rule of Thumb for Rotations
โข Positive angles follow the curled hand, when thumb lies along the positive axis direction
y
y
x
x
z
z
3D Geometric Transformations (3)
โข Shearing: Many skew combinations. Examples:
๐๐ก๐ฆโ๐ฅ =
1 ๐ 0 00 1 0 00 0 1 00 0 0 1
๐๐ก๐ฆ,๐งโ๐ฅ =
1 ๐ ๐ 00 1 0 00 0 1 00 0 0 1
๐๐ก๐ฆโ๐ฅ,๐ง =
1 ๐ 0 00 1 0 00 ๐ 1 00 0 0 1
z
x
yz
x
y
z
y
z
x
y
3D Transformations โ Example (1)
Build this:
Out of these:
1
1
1
1
1 1
1
1
z x
y
z x
y
z x
y
z
y
3D Transformations โ Example (2)
โข First, letโs identify the elements of the structure:
1
1
1
1
1 1
1
1
๐ถ๐ข๐๐ ๐๐๐๐๐ ๐ถ๐ฆ๐๐๐๐๐๐
๐๐๐๐๐
๐ถ๐ข๐๐๐ถ๐ข๐๐
๐ถ๐ข๐๐
๐ถ๐ฆ๐๐๐๐๐๐
๐ถ๐ฆ๐๐๐๐๐๐
z x
y
z x
y
z x
y
z
y
3D Transformations โ Example (3)
โข It is also some times more convenient to think in 2D in order to decompose the transformations into simpler steps
z
y
z
x
x z
y y
4
2
0.5
40.5
1
1 11 1
0.2
2.5
1
A
B
CD
E
F
3D Transformations โ Example (4)
โข Since one of the Cube corners is already at the origin, it is more convenient to first scale and then translate the piece to form part A
zA
1
1
1z x
yy
๐ด = ๐(1,0,0)๐(4,0.5,1)๐ถ๐ข๐๐
1
4
0.5
3D Transformations โ Example (5)
โข We have 2 identical parts. We create deformed cylinder to match the column shape and then two instances of the same object are placed in their final position
B
๐ถ๐๐๐ข๐๐ = ๐(0.5,2.5,0.5)๐ถ๐ฆ๐๐๐๐๐๐
1
1
z x
y
z x z
y
C
๐ต = ๐(1.5,0.5,0.5)๐ถ๐๐๐ข๐๐
๐ถ = ๐(4.5,0.5,0.5)๐ถ๐๐๐ข๐๐
2.5
0.5
3D Transformations โ Example (6)
โข The wedge is not conveniently oriented for scaling, since we need to scale along the hypotenuse
z
y
x
y
F
x
y
x
y
๐๐ง,โ3๐4๐๐๐๐๐ ๐ 4
2,1
2,2๐๐ง,โ3๐4๐๐๐๐๐
3D Transformations โ Example (6)
โข The wedge is not conveniently oriented for scaling, since we need to scale along the hypotenuse
z
y F
x
y
x
y
๐(3,3.5,โ0.5)๐4 22 ,
1
2,2๐๐ง,โ3๐4๐๐๐๐๐
3D Transformations โ Example (7)
โข The two doors must parametrically swing open
โข The door rotation is defined according to a local pivot axis
โข The two rotations are of exactly opposite angle
z
y
DE
Local pivot axes
๐๐๐๐๐
3D Transformations โ Example (8)
โข More convenient to first scale the cube then
โข Translate it so that the Y axis coincides with the local pivot axis
โข Then move the parts to their final position
z
y
DE
Local pivot axes
3D Transformations โ Example (9)
๐1,2.5,0.2๐ถ๐ข๐๐
๐ท๐๐๐โฒ = ๐(0,0.5,โ0.1)๐1,2.5,0.2๐ถ๐ข๐๐
๐ท๐๐๐ฃ๐๐ก = ๐๐ฆ,โ๐๐๐๐๐๐ท๐๐๐โฒ
๐ธ๐๐๐ฃ๐๐ก = ๐๐ฆ,๐๐๐๐๐๐๐ฆ,๐๐ท๐๐๐โฒ = ๐๐ฆ,๐+๐๐๐๐๐๐ท๐๐๐
โฒ
๐ธ๐๐๐ฃ๐๐ก๐ท๐๐๐ฃ๐๐ก
zx
y
zx
zx
yy
zx
zx
3D Transformations โ Example (9)
D = ๐(2,0,0.5)๐๐ฆ,โ๐๐๐๐๐๐(0,0.5,โ0.1)๐1,2.5,0.2๐ถ๐ข๐๐
E = ๐(4,0,0.5)๐๐ฆ,๐+๐๐๐๐๐๐(0,0.5,โ0.1)๐1,2.5,0.2๐ถ๐ข๐๐
z
y
DE
Application โ Transformation About Pivot (1)
โข Very often, we require an arbitrary transformation relative to a user-defined pivot point and not the origin of the coordinate system
?
Application โ Transformation About Pivot (2)
โข Method:
โ Bring the shape and the pivot point to the origin
โ Apply the transformation
โ Bring the shape back
๐๐๐๐ฃ๐๐ก(๐ฉ) = ๐โ๐ฉ๐๐๐ฉ
Note here that we only translated along the x,z coordinates of p, since the y coordinate
is unaffected by the particular rotation
Application โ Rotation Around Arbitrary Axis (1)
โข Sometimes we need to rotate a shape around an arbitrary axis. How can we do that?
โข The idea is to convert the arbitrary rotation to an axis-aligned rotation The arbitrary axis must be forced to coincide with one coord. system axis
๐ฏ
Application โ Rotation Around Arbitrary Axis (2)
Y
X
Z
Y
X
Z
๐ฏ = (๐ฃ๐ฅ, ๐ฃ๐ฆ, ๐ฃ๐ง)
๐ฃ๐ฆ2 + ๐ฃ๐ง
2
๐1๐1
๐ฃ๐ฅ
๐ฃ๐ฆ
๐ฃ๐ง ๐ฃ๐ฆ2 + ๐ฃ๐ง
2
โ๐2
๐ฃ๐ฅ
๐1 = atan(๐ฃ๐ฆ , ๐ฃ๐ง) ๐2 = atan(๐ฃ๐ฅ, ๐ฃ๐ฅ2 + ๐ฃ๐ง
2)
Collapse ๐ฏ axis on e.g. z axisโฆ
Application โ Rotation Around Arbitrary Axis (3)
Y
XZ
Y
X
Z
โ๐1
๐2
Y
X
Z
๐๐ฏ,๐ = ๐๐ฅ,โ๐1๐๐ฆ,๐2๐๐ง,๐๐๐ฆ,โ๐2๐๐ฅ,๐1
๐
Do the rotation around z instead โฆ and revert to the ๐ฏ axis
๐ฉ =
๐ข๐ฅ ๐ฃ๐ฅ ๐ค๐ฅ๐ข๐ฆ ๐ฃ๐ฆ ๐ค๐ฆ๐ข๐ง ๐ฃ๐ง ๐ค๐ง
๐๐ขโฒ
๐๐ฃโฒ
๐๐คโฒ
+
๐๐ฅ๐๐ฆ๐๐ง
Change of Basis Transformation (1)
โข Let ๐ฉโฒ = ๐ฉ ๐ข๐ฃ๐ค be the coordinates of ๐ฉ w.r.t. a coordinate system {๐, ๐ฎ, ๐ฏ,๐ฐ}
โข By definition, this means that: ๐ฉ = ๐๐ขโฒ ๐ฎ+๐๐ฃ
โฒ๐ฏ+๐๐คโฒ ๐ฐ+ ๐ or
โข And in homogeneous coordinates:
๐ฉ =
๐ข๐ฅ ๐ฃ๐ฅ ๐ค๐ฅ ๐๐ฅ๐ข๐ฆ ๐ฃ๐ฆ ๐ค๐ฆ ๐๐ฆ๐ข๐ง ๐ฃ๐ง ๐ค๐ง ๐๐ง0 0 0 1
๐๐ขโฒ
๐๐ฃโฒ
๐๐คโฒ
1
= ๐๐ โ ๐ โ ๐ฉโฒ
y
x
z
๐ฎ
๐ฐ
๐ฏ
๐
๐จ
๐๐ขโฒ
๐๐คโฒ
๐๐ฃโฒ
Change of Basis Transformation (2)
โข So the transformation ๐๐ โ ๐ is a rotation followed by translation that expresses the point from {๐, ๐ฎ, ๐ฏ,๐ฐ}to {๐จ, เท๐๐ฅ , เท๐๐ฆ, เท๐๐ง}
โข Therefore, the transformation ๐โ1 โ ๐โ๐= ๐๐ โ ๐โ๐
expresses the point from {๐จ, เท๐๐ฅ , เท๐๐ฆ , เท๐๐ง} to {๐, ๐ฎ, ๐ฏ,๐ฐ}
โข This pair of change of basis transformations is extremely useful in graphics, since we very often need to move from one coordinate system to another in many computations
Transforming Normals (1)
โข Caution should be exercised when transforming โdirectionsโ
โข It is wrong to apply arbitrary transformation matrices directly to normals
Transforming Normals (2)
โข What is the correct transformation ๐๐ given the 3X3 matrix ๐(excluding translation)?
โข Intuitively, we require that after the transformation, the normal is still perpendicular to any tangent vector ๐ฏ:
(๐๐๐ง) โ ๐๐ฏ = 0
Or, after manipulating the matrices to express the dot product in matrix form:
(๐๐๐ง)๐ ๐๐ฏ = ๐ง๐๐๐
๐๐๐ฏ = 0
Transforming Normals (3)
(๐๐๐ง)๐ ๐๐ฏ = ๐ง๐๐๐
๐๐๐ฏ = 0
But by the definition of the tangent vector ๐ฏ: ๐ง๐๐ฏ = 0and therefore we require:
๐๐๐๐ = ๐ึ
๐๐ = (๐โ1)๐
Contributors
โข Georgios Papaioannou