Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Combining Transformations | Geometric Transformations
Geometric Modelling with Python

Combining Transformations

Swipe to show menu

When working with geometric shapes, you often need to apply more than one transformation to a shape. This process is called transformation composition. The order in which you apply transformations—such as translation, rotation, and scaling—matters greatly, because each transformation changes the shape’s position, size, or orientation in a way that affects the next operation.

Suppose you start with a polygon and want to translate it (move it), then rotate it, and finally scale it. If you change the order—say, scale first, then rotate, then translate—you may end up with a very different result. This is because transformations are not commutative: A followed by B does not always give the same result as B followed by A.

To combine transformations, you apply each one to the shape in sequence. Each step uses the result of the previous step as its input. This approach lets you build up complex manipulations from simple operations, but you must always be aware of the order.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
import numpy as np import matplotlib.pyplot as plt # Define a simple triangle polygon polygon = np.array([ [0, 0], [1, 0], [0.5, 1], [0, 0] ]) # Translation: move by (2, 1) def translate(points, tx, ty): return points + np.array([tx, ty]) # Rotation: rotate by theta degrees around origin def rotate(points, theta_deg): theta = np.radians(theta_deg) rotation_matrix = np.array([ [np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)] ]) return points @ rotation_matrix.T # Scaling: scale by (sx, sy) def scale(points, sx, sy): scaling_matrix = np.array([ [sx, 0], [0, sy] ]) return points @ scaling_matrix.T # Apply transformations translated = translate(polygon, 2, 1) rotated = rotate(translated, 45) scaled = scale(rotated, 1.5, 0.5) # Plotting plt.figure(figsize=(6, 6)) plt.plot(polygon[:, 0], polygon[:, 1], 'bo-', label='Original') plt.plot(translated[:, 0], translated[:, 1], 'go-', label='Translated') plt.plot(rotated[:, 0], rotated[:, 1], 'ro-', label='Rotated') plt.plot(scaled[:, 0], scaled[:, 1], 'mo-', label='Scaled') plt.legend() plt.axis('equal') plt.title('Combining Translation, Rotation, and Scaling') plt.show()
question mark

Which statement best describes why the order of applying transformations matters when combining them?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 7

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Section 2. Chapter 7
some-alt