Table Of Contents
A scene is made of many objects, and objects are made of many points. Create a transformation matrix and run every point through it. Thus, all objects move the same. (For example, rotate a star map around the north pole. Each star is transformed independently.)
You will not be using matrix operations. You will be using equations that perform the matrix operations.
Move the point (x,y) to the point (x′,y′).
tx = x′ - x ty = y′ - y x′ = x + tx y′ = y + ty
Rotate a given angle θ theta. (x′,y′) are the point's new coordinates.
x′ = x cos θ - y sin θ y′ = x sin θ + y cos θ
Composite transformation can be achieved by concatenation of transformation matrices to obtain a combined transformation matrix. The purpose of composing transformations is to gain efficiency by applying a single composed transformation to a point, rather than applying a series of transformation, one after another.
Transformations and Matrices
Python Matrices and NumPy Arrays
To multiply two matrices, we use the dot() method.
a = np.array([[3, 6, 7], [5, -3, 0]]) b = np.array([[1, 1], [2, 1], [3, -3]]) ##c = np.array([[4, 4], [-3, 1], [-2, -1]] x = a.dot(b) ##x = c.dot(x) print(x)