Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

An Affine Transform is a Linear Transform + a Translation Vector.

$$ \begin{bmatrix}x'& y'\end{bmatrix} = \begin{bmatrix}x& y\end{bmatrix} \cdot \begin{bmatrix}a& b \\ c&d\end{bmatrix} + \begin{bmatrix}e& f\end{bmatrix} $$

It can be applied to individual points or to lines or even Bezier curves. For lines, it preserves the property that parallel lines remain parallel. For Bezier curves, it preserves the convex-hull property of the control points.

Multiplied-out, it produces 2 equations for yielding a "transformed" coordinate pair $(x', y')$ from the original pair $(x, y)$ and a list of constants $(a, b, c, d, e, f)$. $$ x' = a\cdot x + c\cdot y + e \\ y' = b\cdot x + d\cdot y + f $$

Conveniently, the Linear transform and the Translation vector can be put together into a 3D matrix which can operate over 2D homogeneous coordinates.

$$ \begin{bmatrix}x'& y'&1\end{bmatrix} = \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} $$

Which yields the same 2 equations above.

Very conveniently, the matrices themselves can be multiplied together to produce a third matrix (of constants) which performs the same transformation as the original 2 would perform in sequence. Put simply, the matrix multiplications are associative.

$$ \begin{matrix} \begin{bmatrix}x''& y''&1\end{bmatrix} & = & \left( \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix}\right) \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ & = & \begin{bmatrix}a \cdot x + c \cdot y+e & b \cdot x + d \cdot y+f &1 \end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ &=& \begin{bmatrix}g(a \cdot x + c \cdot y+e) + i( b \cdot x + d \cdot y+f) + k \\ h(a \cdot x + c \cdot y+e) + j( b \cdot x + d \cdot y+f) + m \\1 \end{bmatrix}^T \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \left( \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \right) \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}ag+bi& ah+bj &0\\ cg+di&ch+dj&0 \\ eg+fi+k&eh+fj+m&1\end{bmatrix} \end{matrix} $$

Alternatively you can consider a few basic transform types and compose any more complex transform by combining these (multiplying them together).

Identity transform

identity transform

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Scaling

scaling

$$\begin{bmatrix} S_x & 0 & 0 \\ 0 & S_y & 0 \\ 0 & 0 & 1 \\ \end{bmatrix}$$

*Note: a reflection can be performed with scaling parameters $(S_x, S_y) = (-1,1)$ or $(1,-1)$.

Translation

translation

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ T_x & T_y & 1 \end{bmatrix}$$

Skew x by y

skew x by y

$$\begin{bmatrix} 1 & Q_x & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Skew y by x

skew y by x

$$\begin{bmatrix} 1 & 0 & 0 \\ Q_y & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Rotation

rotation

$$\begin{bmatrix} \cos\theta & -sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{bmatrix} $$

[Note I've shown the form of Matrix here which accepts a row vector on the left. The transpose of these matrices will work with a column vector on the right.]

A matrix composed purely from scaling, rotation, and translation can be decomposed back into these three componentsdecomposed back into these three components.

An Affine Transform is a Linear Transform + a Translation Vector.

$$ \begin{bmatrix}x'& y'\end{bmatrix} = \begin{bmatrix}x& y\end{bmatrix} \cdot \begin{bmatrix}a& b \\ c&d\end{bmatrix} + \begin{bmatrix}e& f\end{bmatrix} $$

It can be applied to individual points or to lines or even Bezier curves. For lines, it preserves the property that parallel lines remain parallel. For Bezier curves, it preserves the convex-hull property of the control points.

Multiplied-out, it produces 2 equations for yielding a "transformed" coordinate pair $(x', y')$ from the original pair $(x, y)$ and a list of constants $(a, b, c, d, e, f)$. $$ x' = a\cdot x + c\cdot y + e \\ y' = b\cdot x + d\cdot y + f $$

Conveniently, the Linear transform and the Translation vector can be put together into a 3D matrix which can operate over 2D homogeneous coordinates.

$$ \begin{bmatrix}x'& y'&1\end{bmatrix} = \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} $$

Which yields the same 2 equations above.

Very conveniently, the matrices themselves can be multiplied together to produce a third matrix (of constants) which performs the same transformation as the original 2 would perform in sequence. Put simply, the matrix multiplications are associative.

$$ \begin{matrix} \begin{bmatrix}x''& y''&1\end{bmatrix} & = & \left( \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix}\right) \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ & = & \begin{bmatrix}a \cdot x + c \cdot y+e & b \cdot x + d \cdot y+f &1 \end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ &=& \begin{bmatrix}g(a \cdot x + c \cdot y+e) + i( b \cdot x + d \cdot y+f) + k \\ h(a \cdot x + c \cdot y+e) + j( b \cdot x + d \cdot y+f) + m \\1 \end{bmatrix}^T \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \left( \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \right) \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}ag+bi& ah+bj &0\\ cg+di&ch+dj&0 \\ eg+fi+k&eh+fj+m&1\end{bmatrix} \end{matrix} $$

Alternatively you can consider a few basic transform types and compose any more complex transform by combining these (multiplying them together).

Identity transform

identity transform

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Scaling

scaling

$$\begin{bmatrix} S_x & 0 & 0 \\ 0 & S_y & 0 \\ 0 & 0 & 1 \\ \end{bmatrix}$$

*Note: a reflection can be performed with scaling parameters $(S_x, S_y) = (-1,1)$ or $(1,-1)$.

Translation

translation

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ T_x & T_y & 1 \end{bmatrix}$$

Skew x by y

skew x by y

$$\begin{bmatrix} 1 & Q_x & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Skew y by x

skew y by x

$$\begin{bmatrix} 1 & 0 & 0 \\ Q_y & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Rotation

rotation

$$\begin{bmatrix} \cos\theta & -sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{bmatrix} $$

[Note I've shown the form of Matrix here which accepts a row vector on the left. The transpose of these matrices will work with a column vector on the right.]

A matrix composed purely from scaling, rotation, and translation can be decomposed back into these three components.

An Affine Transform is a Linear Transform + a Translation Vector.

$$ \begin{bmatrix}x'& y'\end{bmatrix} = \begin{bmatrix}x& y\end{bmatrix} \cdot \begin{bmatrix}a& b \\ c&d\end{bmatrix} + \begin{bmatrix}e& f\end{bmatrix} $$

It can be applied to individual points or to lines or even Bezier curves. For lines, it preserves the property that parallel lines remain parallel. For Bezier curves, it preserves the convex-hull property of the control points.

Multiplied-out, it produces 2 equations for yielding a "transformed" coordinate pair $(x', y')$ from the original pair $(x, y)$ and a list of constants $(a, b, c, d, e, f)$. $$ x' = a\cdot x + c\cdot y + e \\ y' = b\cdot x + d\cdot y + f $$

Conveniently, the Linear transform and the Translation vector can be put together into a 3D matrix which can operate over 2D homogeneous coordinates.

$$ \begin{bmatrix}x'& y'&1\end{bmatrix} = \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} $$

Which yields the same 2 equations above.

Very conveniently, the matrices themselves can be multiplied together to produce a third matrix (of constants) which performs the same transformation as the original 2 would perform in sequence. Put simply, the matrix multiplications are associative.

$$ \begin{matrix} \begin{bmatrix}x''& y''&1\end{bmatrix} & = & \left( \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix}\right) \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ & = & \begin{bmatrix}a \cdot x + c \cdot y+e & b \cdot x + d \cdot y+f &1 \end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ &=& \begin{bmatrix}g(a \cdot x + c \cdot y+e) + i( b \cdot x + d \cdot y+f) + k \\ h(a \cdot x + c \cdot y+e) + j( b \cdot x + d \cdot y+f) + m \\1 \end{bmatrix}^T \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \left( \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \right) \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}ag+bi& ah+bj &0\\ cg+di&ch+dj&0 \\ eg+fi+k&eh+fj+m&1\end{bmatrix} \end{matrix} $$

Alternatively you can consider a few basic transform types and compose any more complex transform by combining these (multiplying them together).

Identity transform

identity transform

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Scaling

scaling

$$\begin{bmatrix} S_x & 0 & 0 \\ 0 & S_y & 0 \\ 0 & 0 & 1 \\ \end{bmatrix}$$

*Note: a reflection can be performed with scaling parameters $(S_x, S_y) = (-1,1)$ or $(1,-1)$.

Translation

translation

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ T_x & T_y & 1 \end{bmatrix}$$

Skew x by y

skew x by y

$$\begin{bmatrix} 1 & Q_x & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Skew y by x

skew y by x

$$\begin{bmatrix} 1 & 0 & 0 \\ Q_y & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Rotation

rotation

$$\begin{bmatrix} \cos\theta & -sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{bmatrix} $$

[Note I've shown the form of Matrix here which accepts a row vector on the left. The transpose of these matrices will work with a column vector on the right.]

A matrix composed purely from scaling, rotation, and translation can be decomposed back into these three components.

add note for reflection under scaling
Source Link
luser droog
  • 1.4k
  • 2
  • 12
  • 27

An Affine Transform is a Linear Transform + a Translation Vector.

$$ \begin{bmatrix}x'& y'\end{bmatrix} = \begin{bmatrix}x& y\end{bmatrix} \cdot \begin{bmatrix}a& b \\ c&d\end{bmatrix} + \begin{bmatrix}e& f\end{bmatrix} $$

It can be applied to individual points or to lines or even Bezier curves. For lines, it preserves the property that parallel lines remain parallel. For Bezier curves, it preserves the convex-hull property of the control points.

Multiplied-out, it produces 2 equations for yielding a "transformed" coordinate pair $(x', y')$ from the original pair $(x, y)$ and a list of constants $(a, b, c, d, e, f)$. $$ x' = a\cdot x + c\cdot y + e \\ y' = b\cdot x + d\cdot y + f $$

Conveniently, the Linear transform and the Translation vector can be put together into a 3D matrix which can operate over 2D homogeneous coordinates.

$$ \begin{bmatrix}x'& y'&1\end{bmatrix} = \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} $$

Which yields the same 2 equations above.

Very conveniently, the matrices themselves can be multiplied together to produce a third matrix (of constants) which performs the same transformation as the original 2 would perform in sequence. Put simply, the matrix multiplications are associative.

$$ \begin{matrix} \begin{bmatrix}x''& y''&1\end{bmatrix} & = & \left( \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix}\right) \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ & = & \begin{bmatrix}a \cdot x + c \cdot y+e & b \cdot x + d \cdot y+f &1 \end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ &=& \begin{bmatrix}g(a \cdot x + c \cdot y+e) + i( b \cdot x + d \cdot y+f) + k \\ h(a \cdot x + c \cdot y+e) + j( b \cdot x + d \cdot y+f) + m \\1 \end{bmatrix}^T \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \left( \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \right) \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}ag+bi& ah+bj &0\\ cg+di&ch+dj&0 \\ eg+fi+k&eh+fj+m&1\end{bmatrix} \end{matrix} $$

Alternatively you can consider a few basic transform types and compose any more complex transform by combining these (multiplying them together).

Identity transform

identity transform

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Scaling

scaling

$$\begin{bmatrix} S_x & 0 & 0 \\ 0 & S_y & 0 \\ 0 & 0 & 1 \\ \end{bmatrix}$$

*Note: a reflection can be performed with scaling parameters $(S_x, S_y) = (-1,1)$ or $(1,-1)$.

Translation

translation

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ T_x & T_y & 1 \end{bmatrix}$$

Skew x by y

skew x by y

$$\begin{bmatrix} 1 & Q_x & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Skew y by x

skew y by x

$$\begin{bmatrix} 1 & 0 & 0 \\ Q_y & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Rotation

rotation

$$\begin{bmatrix} \cos\theta & -sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{bmatrix} $$

[Note I've shown the form of Matrix here which accepts a row vector on the left. The transpose of these matrices will work with a column vector on the right.]

A matrix composed purely from scaling, rotation, and translation can be decomposed back into these three components.

An Affine Transform is a Linear Transform + a Translation Vector.

$$ \begin{bmatrix}x'& y'\end{bmatrix} = \begin{bmatrix}x& y\end{bmatrix} \cdot \begin{bmatrix}a& b \\ c&d\end{bmatrix} + \begin{bmatrix}e& f\end{bmatrix} $$

It can be applied to individual points or to lines or even Bezier curves. For lines, it preserves the property that parallel lines remain parallel. For Bezier curves, it preserves the convex-hull property of the control points.

Multiplied-out, it produces 2 equations for yielding a "transformed" coordinate pair $(x', y')$ from the original pair $(x, y)$ and a list of constants $(a, b, c, d, e, f)$. $$ x' = a\cdot x + c\cdot y + e \\ y' = b\cdot x + d\cdot y + f $$

Conveniently, the Linear transform and the Translation vector can be put together into a 3D matrix which can operate over 2D homogeneous coordinates.

$$ \begin{bmatrix}x'& y'&1\end{bmatrix} = \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} $$

Which yields the same 2 equations above.

Very conveniently, the matrices themselves can be multiplied together to produce a third matrix (of constants) which performs the same transformation as the original 2 would perform in sequence. Put simply, the matrix multiplications are associative.

$$ \begin{matrix} \begin{bmatrix}x''& y''&1\end{bmatrix} & = & \left( \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix}\right) \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ & = & \begin{bmatrix}a \cdot x + c \cdot y+e & b \cdot x + d \cdot y+f &1 \end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ &=& \begin{bmatrix}g(a \cdot x + c \cdot y+e) + i( b \cdot x + d \cdot y+f) + k \\ h(a \cdot x + c \cdot y+e) + j( b \cdot x + d \cdot y+f) + m \\1 \end{bmatrix}^T \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \left( \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \right) \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}ag+bi& ah+bj &0\\ cg+di&ch+dj&0 \\ eg+fi+k&eh+fj+m&1\end{bmatrix} \end{matrix} $$

Alternatively you can consider a few basic transform types and compose any more complex transform by combining these (multiplying them together).

Identity transform

identity transform

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Scaling

scaling

$$\begin{bmatrix} S_x & 0 & 0 \\ 0 & S_y & 0 \\ 0 & 0 & 1 \\ \end{bmatrix}$$

Translation

translation

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ T_x & T_y & 1 \end{bmatrix}$$

Skew x by y

skew x by y

$$\begin{bmatrix} 1 & Q_x & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Skew y by x

skew y by x

$$\begin{bmatrix} 1 & 0 & 0 \\ Q_y & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Rotation

rotation

$$\begin{bmatrix} \cos\theta & -sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{bmatrix} $$

[Note I've shown the form of Matrix here which accepts a row vector on the left. The transpose of these matrices will work with a column vector on the right.]

A matrix composed purely from scaling, rotation, and translation can be decomposed back into these three components.

An Affine Transform is a Linear Transform + a Translation Vector.

$$ \begin{bmatrix}x'& y'\end{bmatrix} = \begin{bmatrix}x& y\end{bmatrix} \cdot \begin{bmatrix}a& b \\ c&d\end{bmatrix} + \begin{bmatrix}e& f\end{bmatrix} $$

It can be applied to individual points or to lines or even Bezier curves. For lines, it preserves the property that parallel lines remain parallel. For Bezier curves, it preserves the convex-hull property of the control points.

Multiplied-out, it produces 2 equations for yielding a "transformed" coordinate pair $(x', y')$ from the original pair $(x, y)$ and a list of constants $(a, b, c, d, e, f)$. $$ x' = a\cdot x + c\cdot y + e \\ y' = b\cdot x + d\cdot y + f $$

Conveniently, the Linear transform and the Translation vector can be put together into a 3D matrix which can operate over 2D homogeneous coordinates.

$$ \begin{bmatrix}x'& y'&1\end{bmatrix} = \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} $$

Which yields the same 2 equations above.

Very conveniently, the matrices themselves can be multiplied together to produce a third matrix (of constants) which performs the same transformation as the original 2 would perform in sequence. Put simply, the matrix multiplications are associative.

$$ \begin{matrix} \begin{bmatrix}x''& y''&1\end{bmatrix} & = & \left( \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix}\right) \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ & = & \begin{bmatrix}a \cdot x + c \cdot y+e & b \cdot x + d \cdot y+f &1 \end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ &=& \begin{bmatrix}g(a \cdot x + c \cdot y+e) + i( b \cdot x + d \cdot y+f) + k \\ h(a \cdot x + c \cdot y+e) + j( b \cdot x + d \cdot y+f) + m \\1 \end{bmatrix}^T \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \left( \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \right) \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}ag+bi& ah+bj &0\\ cg+di&ch+dj&0 \\ eg+fi+k&eh+fj+m&1\end{bmatrix} \end{matrix} $$

Alternatively you can consider a few basic transform types and compose any more complex transform by combining these (multiplying them together).

Identity transform

identity transform

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Scaling

scaling

$$\begin{bmatrix} S_x & 0 & 0 \\ 0 & S_y & 0 \\ 0 & 0 & 1 \\ \end{bmatrix}$$

*Note: a reflection can be performed with scaling parameters $(S_x, S_y) = (-1,1)$ or $(1,-1)$.

Translation

translation

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ T_x & T_y & 1 \end{bmatrix}$$

Skew x by y

skew x by y

$$\begin{bmatrix} 1 & Q_x & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Skew y by x

skew y by x

$$\begin{bmatrix} 1 & 0 & 0 \\ Q_y & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Rotation

rotation

$$\begin{bmatrix} \cos\theta & -sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{bmatrix} $$

[Note I've shown the form of Matrix here which accepts a row vector on the left. The transpose of these matrices will work with a column vector on the right.]

A matrix composed purely from scaling, rotation, and translation can be decomposed back into these three components.

fix skew matrix
Source Link
luser droog
  • 1.4k
  • 2
  • 12
  • 27

An Affine Transform is a Linear Transform + a Translation Vector.

$$ \begin{bmatrix}x'& y'\end{bmatrix} = \begin{bmatrix}x& y\end{bmatrix} \cdot \begin{bmatrix}a& b \\ c&d\end{bmatrix} + \begin{bmatrix}e& f\end{bmatrix} $$

It can be applied to individual points or to lines or even Bezier curves. For lines, it preserves the property that parallel lines remain parallel. For Bezier curves, it preserves the convex-hull property of the control points.

Multiplied-out, it produces 2 equations for yielding a "transformed" coordinate pair $(x', y')$ from the original pair $(x, y)$ and a list of constants $(a, b, c, d, e, f)$. $$ x' = a\cdot x + c\cdot y + e \\ y' = b\cdot x + d\cdot y + f $$

Conveniently, the Linear transform and the Translation vector can be put together into a 3D matrix which can operate over 2D homogeneous coordinates.

$$ \begin{bmatrix}x'& y'&1\end{bmatrix} = \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} $$

Which yields the same 2 equations above.

Very conveniently, the matrices themselves can be multiplied together to produce a third matrix (of constants) which performs the same transformation as the original 2 would perform in sequence. Put simply, the matrix multiplications are associative.

$$ \begin{matrix} \begin{bmatrix}x''& y''&1\end{bmatrix} & = & \left( \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix}\right) \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ & = & \begin{bmatrix}a \cdot x + c \cdot y+e & b \cdot x + d \cdot y+f &1 \end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ &=& \begin{bmatrix}g(a \cdot x + c \cdot y+e) + i( b \cdot x + d \cdot y+f) + k \\ h(a \cdot x + c \cdot y+e) + j( b \cdot x + d \cdot y+f) + m \\1 \end{bmatrix}^T \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \left( \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \right) \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}ag+bi& ah+bj &0\\ cg+di&ch+dj&0 \\ eg+fi+k&eh+fj+m&1\end{bmatrix} \end{matrix} $$

Alternatively you can consider a few basic transform types and compose any more complex transform by combining these (multiplying them together).

Identity transform

identity transform

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Scaling

scaling

$$\begin{bmatrix} S_x & 0 & 0 \\ 0 & S_y & 0 \\ 0 & 0 & 1 \\ \end{bmatrix}$$

Translation

translation

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ T_x & T_y & 1 \end{bmatrix}$$

Skew x by y

skew x by y

$$\begin{bmatrix} 1 & Q_x & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Skew y by x

skew y by x

$$\begin{bmatrix} 1 & Q_x & 0 \\ Q_y & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$$$\begin{bmatrix} 1 & 0 & 0 \\ Q_y & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Rotation

rotation

$$\begin{bmatrix} \cos\theta & -sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{bmatrix} $$

[Note I've shown the form of Matrix here which accepts a row vector on the left. The transpose of these matrices will work with a column vector on the right.]

A matrix composed purely from scaling, rotation, and translation can be decomposed back into these three components.

An Affine Transform is a Linear Transform + a Translation Vector.

$$ \begin{bmatrix}x'& y'\end{bmatrix} = \begin{bmatrix}x& y\end{bmatrix} \cdot \begin{bmatrix}a& b \\ c&d\end{bmatrix} + \begin{bmatrix}e& f\end{bmatrix} $$

It can be applied to individual points or to lines or even Bezier curves. For lines, it preserves the property that parallel lines remain parallel. For Bezier curves, it preserves the convex-hull property of the control points.

Multiplied-out, it produces 2 equations for yielding a "transformed" coordinate pair $(x', y')$ from the original pair $(x, y)$ and a list of constants $(a, b, c, d, e, f)$. $$ x' = a\cdot x + c\cdot y + e \\ y' = b\cdot x + d\cdot y + f $$

Conveniently, the Linear transform and the Translation vector can be put together into a 3D matrix which can operate over 2D homogeneous coordinates.

$$ \begin{bmatrix}x'& y'&1\end{bmatrix} = \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} $$

Which yields the same 2 equations above.

Very conveniently, the matrices themselves can be multiplied together to produce a third matrix (of constants) which performs the same transformation as the original 2 would perform in sequence. Put simply, the matrix multiplications are associative.

$$ \begin{matrix} \begin{bmatrix}x''& y''&1\end{bmatrix} & = & \left( \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix}\right) \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ & = & \begin{bmatrix}a \cdot x + c \cdot y+e & b \cdot x + d \cdot y+f &1 \end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ &=& \begin{bmatrix}g(a \cdot x + c \cdot y+e) + i( b \cdot x + d \cdot y+f) + k \\ h(a \cdot x + c \cdot y+e) + j( b \cdot x + d \cdot y+f) + m \\1 \end{bmatrix}^T \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \left( \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \right) \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}ag+bi& ah+bj &0\\ cg+di&ch+dj&0 \\ eg+fi+k&eh+fj+m&1\end{bmatrix} \end{matrix} $$

Alternatively you can consider a few basic transform types and compose any more complex transform by combining these (multiplying them together).

Identity transform

identity transform

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Scaling

scaling

$$\begin{bmatrix} S_x & 0 & 0 \\ 0 & S_y & 0 \\ 0 & 0 & 1 \\ \end{bmatrix}$$

Translation

translation

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ T_x & T_y & 1 \end{bmatrix}$$

Skew x by y

skew x by y

$$\begin{bmatrix} 1 & Q_x & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Skew y by x

skew y by x

$$\begin{bmatrix} 1 & Q_x & 0 \\ Q_y & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Rotation

rotation

$$\begin{bmatrix} \cos\theta & -sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{bmatrix} $$

[Note I've shown the form of Matrix here which accepts a row vector on the left. The transpose of these matrices will work with a column vector on the right.]

A matrix composed purely from scaling, rotation, and translation can be decomposed back into these three components.

An Affine Transform is a Linear Transform + a Translation Vector.

$$ \begin{bmatrix}x'& y'\end{bmatrix} = \begin{bmatrix}x& y\end{bmatrix} \cdot \begin{bmatrix}a& b \\ c&d\end{bmatrix} + \begin{bmatrix}e& f\end{bmatrix} $$

It can be applied to individual points or to lines or even Bezier curves. For lines, it preserves the property that parallel lines remain parallel. For Bezier curves, it preserves the convex-hull property of the control points.

Multiplied-out, it produces 2 equations for yielding a "transformed" coordinate pair $(x', y')$ from the original pair $(x, y)$ and a list of constants $(a, b, c, d, e, f)$. $$ x' = a\cdot x + c\cdot y + e \\ y' = b\cdot x + d\cdot y + f $$

Conveniently, the Linear transform and the Translation vector can be put together into a 3D matrix which can operate over 2D homogeneous coordinates.

$$ \begin{bmatrix}x'& y'&1\end{bmatrix} = \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} $$

Which yields the same 2 equations above.

Very conveniently, the matrices themselves can be multiplied together to produce a third matrix (of constants) which performs the same transformation as the original 2 would perform in sequence. Put simply, the matrix multiplications are associative.

$$ \begin{matrix} \begin{bmatrix}x''& y''&1\end{bmatrix} & = & \left( \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix}\right) \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ & = & \begin{bmatrix}a \cdot x + c \cdot y+e & b \cdot x + d \cdot y+f &1 \end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \\ &=& \begin{bmatrix}g(a \cdot x + c \cdot y+e) + i( b \cdot x + d \cdot y+f) + k \\ h(a \cdot x + c \cdot y+e) + j( b \cdot x + d \cdot y+f) + m \\1 \end{bmatrix}^T \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \left( \begin{bmatrix}a& b &0\\ c&d&0 \\ e&f&1\end{bmatrix} \cdot \begin{bmatrix}g& h &0\\ i&j&0 \\ k&m&1\end{bmatrix} \right) \\ &=& \begin{bmatrix}x& y&1\end{bmatrix} \cdot \begin{bmatrix}ag+bi& ah+bj &0\\ cg+di&ch+dj&0 \\ eg+fi+k&eh+fj+m&1\end{bmatrix} \end{matrix} $$

Alternatively you can consider a few basic transform types and compose any more complex transform by combining these (multiplying them together).

Identity transform

identity transform

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Scaling

scaling

$$\begin{bmatrix} S_x & 0 & 0 \\ 0 & S_y & 0 \\ 0 & 0 & 1 \\ \end{bmatrix}$$

Translation

translation

$$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ T_x & T_y & 1 \end{bmatrix}$$

Skew x by y

skew x by y

$$\begin{bmatrix} 1 & Q_x & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Skew y by x

skew y by x

$$\begin{bmatrix} 1 & 0 & 0 \\ Q_y & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

Rotation

rotation

$$\begin{bmatrix} \cos\theta & -sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{bmatrix} $$

[Note I've shown the form of Matrix here which accepts a row vector on the left. The transpose of these matrices will work with a column vector on the right.]

A matrix composed purely from scaling, rotation, and translation can be decomposed back into these three components.

mathjax it up
Source Link
Martin Ender
  • 2.7k
  • 4
  • 24
  • 45
Loading
link to my underappreciated work
Source Link
luser droog
  • 1.4k
  • 2
  • 12
  • 27
Loading
clarity
Source Link
luser droog
  • 1.4k
  • 2
  • 12
  • 27
Loading
applicable to other shapes
Source Link
luser droog
  • 1.4k
  • 2
  • 12
  • 27
Loading
add images
Source Link
luser droog
  • 1.4k
  • 2
  • 12
  • 27
Loading
Source Link
luser droog
  • 1.4k
  • 2
  • 12
  • 27
Loading