Adding two 3D vectors¶
Adding two 3D vectors¶
1# This example adds the values of one Vector3D to another and outputs
2# the values of the modified Vector3D to the output toolbox.
3
4# Create a local variable for the impact.creator object
5c = impact.creator.three_d()
6
7# Create two Vector3D
8v1 = c.vector3_d(10,20,10)
9v2 = c.vector3_d(30,40,10)
10
11# Add v2 to v1
12v1.add(v2)
13
14# Create a local variable for the output toolbox
15ot = impact.gui.output_toolbox
16
17# Display the result of the addition in the output toolbox
18ot.add(v1.x)
19ot.add(v1.y)
20ot.add(v1.z)
21