Vector

Vector

Class Vector()

Vector(parent='MODEL', name='Vector_n', label='Vector_n', 
active=True, x=1, y=0, z=0)

3D Vector.

angle, normalize

Keyword Arguments

name | String | The variable name. | Vector_n, for next available integer n.

label | String | The descriptive label. | Vector_n, for next available integer n.

parent | Object | The parent. | MODEL.

active | Bool | Used to activate or deactivate this entity. | True.

x | Double | The x component. | 1.

y | Double | The y component. | 0.

z | Double | The z component. | 0.

Notes

1. The parent parameter can only be initialized by the constructor and should not be modified directly.

2. Only parent can be used as a positional argument in the constructor.

Methods

angle(other, degrees=False)

Calculates angle between two vectors.

other | str | Name of the second vector. Can also be a python object. | .

degrees | Bool | If True returns the angle in degrees. | False.

Returns:

Angle between self and other.

Return type:

Double

normalize()

Normalize the vector.

Returns:

Normalized vector.

Return type:

Vector

Vector Pair

Class VectorPair()

VectorPair(parent='MODEL', name='VectorPair_n', label='VectorPair_n', active=True, sym='NONE')

3D vector pair.

Keyword Arguments

name | String | The variable name. | VectorPair_n, for next available integer n.

label | String | The descriptive label. | VectorPair_n, for next available integer n.

parent | Object | The parent. | MODEL.

active | Bool | Defines if entity is activated when True or deactivated when False. | True.

sym | Enum | The symmetry of pair entity. Takes values 'LEFT' for left entity as master, 'RIGHT' for right entity as master or 'NONE' when it is not symmetric. | ‘NONE'.

Instances

l | Point | The left point. | .

r | Point | The right point. | .

Notes

Instance is a reference to an entity. You cannot modify an instance, but can modify its properties.

Examples

========
Create a vector, modify its properties and perform different operations on the vector
>>> #Create a Vector and set its x, y and z component
>>> v1 = Vector(name='v_1', label='Vector_1', x=1, y=2, z=3)
>>> v2 = Vector(name='v_2', label='Vector_2', x=-3, y=0, z=1)
>>> #Unary minus
>>> v3 = -v1
>>> v3.x
-1
>>> v3.y
-2
>>> v3.z
-3
>>> #Addition
>>> v4 = v1 + v2
>>> v4.x
-2
>>> v4.y
2
>>> v4.z
4
>>> #Subtraction
>>> v5 = v1 - v2
>>> v5.x
4
>>> v5.y
4
>>> v5.z
2
>>> #Dot product of 2 vectors
>>> v1%v2
0
>>> #Cross product of 2 vectors
>>> v6 = v1*v2
>>> v6.x
0.169030850946
>>> v6.y
-0.845154254729
>>> v6.z
0.507092552837
>>> #Calculate angles between vectors
>>> v1.angle(v2)
1.5707963267948966
>>> v1.angle(v2, degrees=True)
90.0
>>> #Calculate magnitude of the vector
>>> v1.magnitude()
3.7416573867739413
>>> #Create a unit vector
>>> v7 = v1.normalize()
>>> v7.x
0.267261241912
>>> v7.y
0.534522483825
>>> v7.z
0.801783725737
>>> #Scale a vector with a factor
>>> v8 = v1*10
>>> v8.x
10
>>> v8.y
20
>>> v8.z
30