Transforming a vector¶
Transforming a vector¶
1# This example transforms the values of one vector by a matrix and outputs
2# the values of the modified vector to the output toolbox.
3
4# Create a local variable for the impact.creator object
5c = impact.creator
6
7# Create a matrix representing a 90 degree rotation followed by a scale by 2
8m = c.matrix()
9m.rotate(90)
10m.scale(2)
11
12# Create a vector
13v = c.vector(30,40)
14
15# Transform the vector by the matrix
16v.transform(m)
17
18# Create a local variable for the output toolbox
19ot = impact.gui.output_toolbox
20
21# Display the result of the addition in the output toolbox
22ot.add(v.x)
23ot.add(v.y)