Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell...
Transcript of Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell...
![Page 1: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/1.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Vector and Affine Math
Don Fussell Computer Science Department
The University of Texas at Austin
![Page 2: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/2.jpg)
Vectors A vector is a direction and a magnitude Does NOT include a point of reference Usually thought of as an arrow in space Vectors can be added together and multiplied by scalars Zero vector has no length or direction
Vectors
University of Texas at Austin CS354 - Computer Graphics Don Fussell
![Page 3: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/3.jpg)
Vector Spaces Set of vectors Closed under the following operations
Vector addition: v1 + v2 = v3
Scalar multiplication: s v1 = v2
Linear combinations:
Scalars come from some field F e.g. real or complex numbers
Linear independence Basis Dimension
vv =∑=
i
n
iia
1
University of Texas at Austin CS354 - Computer Graphics Don Fussell
![Page 4: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/4.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Vector Space Axioms Vector addition is associative and commutative Vector addition has a (unique) identity element (the 0 vector) Each vector has an additive inverse
So we can define vector subtraction as adding an inverse
Scalar multiplication has an identity element (1) Scalar multiplication distributes over vector addition and field addition Multiplications are compatible (a(bv)=(ab)v)
![Page 5: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/5.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Coordinate Representation
Pick a basis, order the vectors in it, then all vectors in the space can be represented as sequences of coordinates, i.e. coefficients of the basis vectors, in order. Example:
Cartesian 3-space Basis: [i j k] Linear combination: xi + yj + zk Coordinate representation: [x y z]
][][][ 212121222111 bzazbyaybxaxzyxbzyxa +++=+
![Page 6: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/6.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Row and Column Vectors
We can represent a vector, v = (x,y), in the plane
as a column vector
as a row vector €
xy"
# $ %
& '
€
x y[ ]
![Page 7: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/7.jpg)
Linear Transformations
Given vector spaces V and W A function is a linear map or linear transformation if
University of Texas at Austin CS354 - Computer Graphics Don Fussell
f :V→W
f (a1v1 +...+ amvm ) = a1 f (v1)+...+ am f (vm )
![Page 8: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/8.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Transformation Representation
We can represent a 2-D transformation M by a matrix
If v is a column vector, M goes on the left:
If v is a row vector, MT goes on the right:
We will use column vectors.
v'= vMT
!x !y"#
$%= x y"
#$%
a cb d
"
#&
$
%'
v'=Mv
!x!y
"
#$$
%
&''= a b
c d
"
#$
%
&'
xy
"
#$$
%
&''
€
M =a bc d"
# $
%
& '
![Page 9: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/9.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Two-dimensional transformations
Here's all you get with a 2 x 2 transformation matrix M:
So:
We will develop some intimacy with the elements a, b, c, d…
€
" x " y
#
$ % &
' ( =
a bc d#
$ %
&
' (
xy#
$ % &
' (
€
" x = ax + by" y = cx + dy
![Page 10: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/10.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Identity
Suppose we choose a=d=1, b=c=0: Gives the identity matrix:
Doesn't change anything €
1 00 1"
# $
%
& '
![Page 11: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/11.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Scaling
Suppose b=c=0, but let a and d take on any positive value: Gives a scaling matrix:
Provides differential (non-uniform) scaling in x and y:
€
a 00 d"
# $
%
& '
€
" x = ax" y = dy
€
2 00 2"
# $
%
& '
€
1 2 00 2
"
# $
%
& '
1
2
1 2
1
2
1 2
1
2
1 2
x
y
x
y
x
y
![Page 12: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/12.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Reflection
Suppose b=c=0, but let either a or d go negative. Examples:
x
y
x
y
x
y
x
y
€
−1 00 1#
$ %
&
' (
€
1 00 −1#
$ %
&
' (
![Page 13: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/13.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Shear
Now leave a=d=1 and experiment with b The matrix
gives: €
1 b0 1"
# $
%
& '
€
" x = x + by" y = y
1
1
1
1x
y
x
y
€
1 10 1"
# $
%
& '
![Page 14: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/14.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Effect on unit square Let's see how a general 2 x 2 transformation M affects the unit square:
1
1
p q
rs
x
y
x
y
€
a bc d"
# $
%
& ' p q r s[ ] = ( p ( q ( r ( s [ ]
a bc d"
# $
%
& ' 0 1 1 00 0 1 1"
# $
%
& ' =
0 a a + b b0 c c + d d"
# $
%
& '
![Page 15: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/15.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Effect on unit square, cont.
Observe: Origin invariant under M M can be determined just by knowing how the corners (1,0) and (0,1) are mapped a and d give x- and y-scaling b and c give x- and y-shearing
![Page 16: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/16.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Rotation
From our observations of the effect on the unit square, it should be easy to write down a matrix for “rotation about the origin”:
Thus
1
1x
y
x
y
€
10"
# $ %
& ' →
cos(θ)sin(θ)"
# $
%
& '
01"
# $ %
& ' →
−sin(θ)cos(θ)"
# $
%
& '
€
MR = R(θ) =cos(θ) −sin(θ)sin(θ) cos(θ)$
% &
'
( )
![Page 17: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/17.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Linear transformations The unit square observations also tell us the 2x2 matrix transformation
implies that we are representing a vector in a new coordinate system:
where u=[a c]T and w=[b d]T are vectors that define a new basis for a linear space.
The transformation to this new basis (a.k.a., change of basis) is a linear transformation.
v'=Mv
= a bc d
!
"#
$
%&
xy
!
"##
$
%&&
= u w!"
$%
xy
!
"##
$
%&&
= x ⋅u+ y ⋅w
![Page 18: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/18.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Limitations of the 2 x 2 matrix
A 2 x 2 linear transformation matrix allows Scaling Rotation Reflection Shearing
Q: What important operation does that leave out?
![Page 19: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/19.jpg)
Points A point is a location in space Cannot be added or multiplied together Subtract two points to get the vector between them Points are not vectors
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Points
• A point is a location in space
• Cannot be added or multiplied together
• Subtract two points to get the vector between them
![Page 20: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/20.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Affine transformations
In order to incorporate the idea that both the basis and the origin can change, we augment the linear space u, w with an origin t. Note that while u and w are basis vectors, the origin t is a point. We call u, w, and t (basis and origin) a frame for an affine space. Then, we can represent a change of frame as:
This change of frame is also known as an affine transformation. How do we write an affine transformation with matrices?
!p = x ⋅u+ y ⋅w+ t
![Page 21: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/21.jpg)
Basic Vector Arithmetic
University of Texas at Austin CS354 - Computer Graphics Don Fussell
u =rst
!
"
###
$
%
&&&v =
xyz
!
"
###
$
%
&&&u+ v =
r + xs+ yt + z
!
"
###
$
%
&&&
av =axayaz
!
"
###
$
%
&&&
v = x2 + y2 + z2 norm(v) = vv
![Page 22: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/22.jpg)
Parametric line segment
Or line, or ray, or just linear interpolation
Line segment Ray Line
University of Texas at Austin CS354 - Computer Graphics Don Fussell
p = p0 + t(p1 −p0 ) = (1− t)p0 + tp1
xyz
!
"
###
$
%
&&&=
x0y0z0
!
"
####
$
%
&&&&
+ tx1 − x0y1 − y0z1 − z0
!
"
####
$
%
&&&&
=
(1− t)x0 + t x1(1− t)y0 + t y1(1− t)z0 + tz1
!
"
####
$
%
&&&&
0 ≤ t ≤10 ≤ t ≤∞−∞≤ t ≤∞
![Page 23: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/23.jpg)
Vector dot product
University of Texas at Austin CS354 - Computer Graphics Don Fussell
u ⋅v = rx + sy+ tz = u v cos(φ)
Dot product
• Formula:
• Alternately:
• Where φ is the angle between the vectors
![Page 24: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/24.jpg)
Projection
Projection (u component parallel to v)
Rejection (u component orthogonal to v) Particularly useful when vectors are normalized
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Projection / rejection
• Projection:
• W is the part of U that lies on V
• Rejection: Just U - W
w = u ⋅vv ⋅v
v
u−w
![Page 25: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/25.jpg)
Cross product intuition
• If U & V point along the same line, W = 0
• Useful for constructing local coordinate frames
• Length of cross product is area of parallelogram
spanned by U and V (divide by 2 for area of the
triangle)
Cross product
w is orthogonal to u and v area of parallelogram use right-hand rule
University of Texas at Austin CS354 - Computer Graphics Don Fussell
w = u× v =i j kr s tx y z
=
sz− tytx − rzry− sx
#
$
%%%
&
'
(((
Cross product
• Formula:
• Creates a vector that is:
• Perpendicular to the inputs
• Length
• Right-hand orientedw = u v sin(φ)w
u× v = −(v×u)(u× v)×w ≠ u× (v×w)
![Page 26: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/26.jpg)
Determinants
det(MT) = det(M) det(AB) = det(A)det(B) if det(M) = 0, M is singular, has no inverse
University of Texas at Austin CS354 - Computer Graphics Don Fussell
a bc d
= ad − bc
a b cd e fg h i
= a e fh i
− bd fg i
+ c d eg h
= aei− afh+ bfg− bdi+ cdh− ceg
![Page 27: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/27.jpg)
Plane equation
Given normal vector N orthogonal to the plane and any point p in the plane
For a triangle Order matters, usually CCW
University of Texas at Austin CS354 - Computer Graphics Don Fussell
N ⋅p+ d = 0
a b c!"
#$
xyz
!
"
%%%
#
$
&&&+ d = ax + by+ cz+ d = 0Triangle normals
• Every triangle lies in a plane
• 2 choices of normal, pick one by convention
• CCW winding is usually used
• Formula:
N = norm((v1 − v0 )× (v2 − v0 ))
![Page 28: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/28.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Homogeneous Coordinates To represent transformations among affine frames, we can loft the
problem up into 3-space, adding a third component to every point:
Note that [a c 0]T and [b d 0]T represent vectors and [tx ty 1]T, [x y 1]T and [x' y' 1]T represent points.
!p =Mp
=
a b txc d ty0 0 1
"
#
$$$$
%
&
''''
xy1
"
#
$$$
%
&
'''
= u w t"#
%&
xy1
"
#
$$$
%
&
'''
= x ⋅u+ y ⋅w+1⋅ t
![Page 29: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/29.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Homogeneous coordinates This allows us to perform translation as well as the linear
transformations as a matrix operation:
€
" p = MTp" x " y 1
#
$
% % %
&
'
( ( (
=
1 0 tx
0 1 ty
0 0 1
#
$
% % %
&
'
( ( (
xy1
#
$
% % %
&
'
( ( (
" x = x + tx
" y = y + ty
1x
y
x
y
1 1
1
€
1 0 10 1 1 20 0 1
"
#
$ $ $
%
&
' ' '
![Page 30: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/30.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Rotation about arbitrary points
1. Translate q to origin 2. Rotate 3. Translate back Line up the matrices for these step in right to left order and multiply.
Note: Transformation order is important!!
Until now, we have only considered rotation about the origin.
With homogeneous coordinates, you can specify a rotation, Rq, about any point q = [qx qy 1]T with a matrix:
x
y
x
y
x
y
x
y
qθ
![Page 31: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/31.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Points and vectors From now on, we can represent points as have an additional coordinate of w=1.
Vectors have an additional coordinate of w=0. Thus, a change of origin has no effect on vectors.
Q: What happens if we multiply a matrix by a vector?
These representations reflect some of the rules of affine operations on points and vectors:
One useful combination of affine operations is:
Q: What does this describe?
€
vector + vector →vector ⋅ vector →
point −point →point + vector →
point + point →
€
p(t) = p0 + tv
![Page 32: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/32.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Barycentric coordinates A set of points can be used to create an affine frame. Consider a triangle ABC and a point p:
We can form a frame with an origin C and the vectors from C to the other vertices:
We can then write P in this coordinate frame
The coordinates (α, β, γ) are called the barycentric coordinates of p relative to A, B, and C.
A
B C
p
€
•
€
p =αu+ βv + t
€
u = A−C v = B−C t = C
![Page 33: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/33.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Computing barycentric coordinates For the triangle example we can compute the barycentric
coordinates of P:
Cramer’s rule gives the solution:
Computing the determinant of the denominator gives:
€
αA + βB + γC =
Ax Bx Cx
Ay By Cy
1 1 1
%
&
' ' '
(
)
* * *
α
β
γ
%
&
' ' '
(
)
* * *
=
pxpy1
%
&
' ' '
(
)
* * *
€
BxCy − ByCx + AyCx − AxCy + AxBy − AyBx€
α =
px Bx Cx
py By Cy
1 1 1Ax Bx Cx
Ay By Cy
1 1 1
β =
Ax px Cx
Ay py Cy
1 1 1Ax Bx Cx
Ay By Cy
1 1 1
γ =
Ax Bx pxAy By py1 1 1Ax Bx Cx
Ay By Cy
1 1 1
![Page 34: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/34.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Barycentric coords from area ratios Now, let’s rearrange the equation from two slides ago:
The determinant is then just the z-component of (B-A) × (C-A), which is two times the area of triangle ABC! Thus, we find:
Where SArea(RST) is the signed area of a triangle, which can be computed with cross-products.
€
BxCy − ByCx + AyCx − AxCy + AxBy − AyBx
= (Bx − Ax )(Cy − Ay ) − (By − Ay )(Cx − Ax )
€
α =SArea(pBC)SArea(ABC)
β =SArea(ApC)SArea(ABC)
γ =SArea(ABp)SArea(ABC)
![Page 35: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/35.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Affine and convex combinations Note that we seem to have added points together, which we said was illegal, but as long as they have coefficients that sum to one, it’s ok.
We call this an affine combination. More generally
is a proper affine combination if:
Note that if the αi ‘s are all positive, the result is more specifically called a convex combination.
Q: Why is it called a convex combination?
11
ni
iα
=
=∑
€
p =α1p1 +…+αnpn
![Page 36: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/36.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Basic 3-D transformations: scaling
Some of the 3-D transformations are just like the 2-D ones.
For example, scaling:
x x
y
z
y
z
€
" x " y " z 1
#
$
% % % %
&
'
( ( ( (
=
sx 0 0 00 sy 0 00 0 sz 00 0 0 1
#
$
% % % %
&
'
( ( ( (
xyz1
#
$
% % % %
&
'
( ( ( (
![Page 37: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/37.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Translation in 3D
x x
y
z
y
z
€
" x " y " z 1
#
$
% % % %
&
'
( ( ( (
=
1 0 0 tx
0 1 0 ty
0 0 1 tz
0 0 0 1
#
$
% % % %
&
'
( ( ( (
xyz1
#
$
% % % %
&
'
( ( ( (
![Page 38: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/38.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Rotation in 3D Rotation now has more possibilities in 3D:
x
z
y
xR
yR
zR
Use right hand rule
€
Rx (θ) =
1 0 0 00 cos(θ) −sin(θ) 00 sin(θ) cos(θ) 00 0 0 1
$
%
& & & &
'
(
) ) ) )
Ry (θ) =
cos(θ) 0 sin(θ) 00 1 0 0
−sin(θ) 0 cos(θ) 00 0 0 1
$
%
& & & &
'
(
) ) ) )
Rz(θ) =
cos(θ) −sin(θ) 0 0sin(θ) cos(θ) 0 00 0 1 00 0 0 1
$
%
& & & &
'
(
) ) ) )
![Page 39: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/39.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Shearing in 3D
Shearing is also more complicated. Here is one example:
We call this a shear with respect to the x-z plane.
x x
y
z
y
z
€
" x " y " z 1
#
$
% % % %
&
'
( ( ( (
=
1 b 0 00 1 0 00 0 1 00 0 0 1
#
$
% % % %
&
'
( ( ( (
xyz1
#
$
% % % %
&
'
( ( ( (
![Page 40: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/40.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Preservation of affine combinations A transformation F is an affine transformation if it preserves affine
combinations:
where the pi are points, and:
Clearly, the matrix form of F has this property. One special example is a matrix that drops a dimension. For example:
This transformation, known as an orthographic projection, is an affine transformation.
We’ll use this fact later…
11
ni
iα
=
=∑
€
" x " y 1
#
$
% % %
&
'
( ( (
=
1 0 0 00 1 0 00 0 0 1
#
$
% % %
&
'
( ( (
xyz1
#
$
% % % %
&
'
( ( ( (
€
F(α1p1 +…+αnpn ) =α1F(p1 ) +…+αnF(pn )
![Page 41: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/41.jpg)
University of Texas at Austin CS354 - Computer Graphics Don Fussell
Properties of affine transformations
Here are some useful properties of affine transformations:
Lines map to lines Parallel lines remain parallel Midpoints map to midpoints (in fact, ratios are always preserved)
p
q
rp'
q'
r's
t
st
:
:!
€
ratio =pqqr
=st
=" p " q " q " r
![Page 42: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/42.jpg)
Next Lecture
More about ray tracing, math, and transforms
University of Texas at Austin CS354 - Computer Graphics Don Fussell
![Page 43: Vector and Affine Math - University of Texas at Austin · Vector and Affine Math Don Fussell Computer Science Department The University of Texas at Austin . Vectors A vector is a](https://reader030.fdocuments.in/reader030/viewer/2022040704/5dd12464d6be591ccb646c8a/html5/thumbnails/43.jpg)
Thanks
Some material for these slides provided by Christian Miller
University of Texas at Austin CS354 - Computer Graphics Don Fussell