downstate medical center division of pediatric surgery
TRANSCRIPT
Affine Transformation• rigid transformation: preserves relative distances and angles
– translation, rotation, reflection
• non-rigid transformation: scale, shear
• affine transformation:– informally, rigid and non-rigid transformations that keep the parallel lines
parallel– more formally, all transformation in the following format
p’ = A * p + bwhere A is a matrix, P’, P, and B vectors
– ex) translation, scale, rotation, reflection, shear
Scaling• matrix representation of a 2D scaling by Sx, Sy:
• uniform scaling: Sx = Sy• non-uniform scaling: Sx != Sy
Translation• move objects to new positions by (tx, ty)• tx: horizontal translation amount• ty: vertical translation amount• essentially, add (tx, ty) to all vertices of an object
P(x, y)
P’(x’, y’)
Rotation
p(x, y)
p’(x’, y’)
ab
R: radius
p(x, y) = (Rcos(a), Rsin(b))
p’(x’, y’) = (Rcos(a+b), Rcos(a+b))
RotationRecall, sin(a + b) = sin(a)cos(b) + cos(a)sin(b)
cos(a + b) = cos(a)sin(b) – cos(b)sin(a)
p(x, y) = (Rcos(a), Rsin(a))p’(x’, y’) = (Rcos(a+b), Rsin(a+b))
x’ = Rcos(a+b) = R(cos(a)sin(b) – cos(b)sin(a)) = Rcos(a)sin(b) – Rcos(b)sin(a) x = Rcos(a), y = Rsin(a)= x*sin(b) – y*cos(b)
y’ = Rsin(a+b) = R(sin(a)cos(b) + cos(a)sin(b))= Rsin(a)cos(b) + Rcos(a)sin(b)= y*cos(a) + x*sin(b)= x*sin(b) + y*cos(a)
Reflection about y = x line• matrix representation of horizontal-vertical reflection:
• equivalent to rotating 180 degrees
Horizontal Shearing• matrix representation of a 2D horizontal reflection:
θ
shx = tan(90 – θ)
= cot(θ)
Homogeneous Coordinates• notice that all transformations except for translation could be
expressed in the affine transformation format (p’ = A * p + b where b in all cases is (0, 0)T
• to also express translation as matrix * vector multiplication (instead of addition of two vectors), use homogeneous coordinates
• homogeneous coordinates: one additional coordinate W– can represent all 2D affine transformations with (3x3 matrix) * (3x1
vector) multiplication
To Consider• Rotation/scaling of objects not anchored at the Origin
– translate the object to the origin– rotate or scale– translate the object back to where it was anchored before