This documentation is for the free plugin Py4D in CINEMA 4D R11.5 and not for the C4DSDK of Python in CINEMA 4D R12. For R12, please visit PluginCafe.com
Single precision vector mathematics. A vector class represents a point, a color, a direction, an HPB-angle or a simple coordinate in a 3D space using the Cartesian coordinates x, y and z. The values are stored in the members x, y and z. For example, positions are stored in the order (X position; Y position; Z position) and rotations in the order (H angle; P angle; B angle). In CINEMA 4D you can also use a vector to store colors and their values. The vector class can also represent a direction, an arrow pointing from the origin of the coordinates, such as (0,0,0), to an endpoint; or a floating-point component of an RGB (Red, Green, Blue) color model.
Note
CINEMA 4D uses a left-handed coordinate system.

Here is an example how to use:
vec = Vector(30, 40, 1.5) #new instance of the vector with the passed arguments
vec1 = Vector(vec.x) #new instance of the vector with all components of value vec.x
vec2 = Vector(vec) #copy constructor for vector
vec3 = vec * vec1 / vec2 #simple calculations
| Parameters: |
|
|---|
All arguments are optional so you can create a new vector without any arguments. All components are simply 0. Otherwise x could be a Vector. In this case, all components of the passed vector will be copied to the new vector. If you just pass a number, all components will be set to this. The last way is to set all compoents which have to be of numeric type.
| Parameters: |
|
|---|---|
| Return type: | |
| Returns: | A new vector. |
Returns the Vector as string. Called if str() is wrapped around an instance of Vector. (see __str__).:
vec = Vector(30.0, 40.0, 2)
print vec # output 'Vector(30.0, 40.0, 2.0)'
| Return type: | str |
|---|---|
| Returns: | The Vector as string. |
Get the absolute (positive) value of each component.
| Return type: | Vector |
|---|---|
| Returns: | The absolute vector. |
Add a scalar or Vector to the Vector.
| Parameter: | other (Vector or number) – The scalar or Vector. |
|---|
Subtract a scalar or vector to the vector
| Parameter: | other (Vector or number) – The scalar or Vector. |
|---|
In the case, other is a Vector it takes the dot product of the left hand operand with the right. If the argument is a float, it multiplies each vector component by a scalar and set the vector equal to a result.
:param other : Multiply with self. :rtype: Vector :return: Returns a new vector, if other is of type float.
Returns a float value if other is of type Vector.
Divide the vector.
Divide each vector component by a scalar.
:param other : The scalar. :rtype: Vector :return: The vector.
Take the cross product of the left hand operand with the right.
| Param: | The other argument. |
|---|---|
| Return type: | Vector |
| Returns: | The cross product. |
Multiplies two vectors together componentwise and set the left hand vector to the result.
| Param: | The other argument. |
|---|---|
| Return type: | Vector |
| Returns: | The cross product. |
Get the normalized vector.
| Return type: | Vector |
|---|---|
| Returns: | The normalized vector. |
Check if two vectors are identical.
| Parameter: | other (Vector) – The vector to check. |
|---|---|
| Return type: | bool |
| Returns: | Returns True if both vectors are identical. |
Check if two vectors are unidentical.
| Parameter: | other (Vector) – The vector to check. |
|---|---|
| Return type: | bool |
| Returns: | Returns True if both vectors are unidentical. |
This method takes the cross product of the left hand operand with the right.
| Parameter: | v2 (Vector) – The other vector. |
|---|---|
| Return type: | Vector |
| Returns: | The result. |
Returns the length of the vector.
| Return type: | float |
|---|---|
| Returns: | The length. |
Returns a new normalized vector.
| Return type: | Vector |
|---|---|
| Returns: | The normalized vector. |
Limit the magnitude of a Vector:
def LimitVector(v, max):
"""
This function limit the
magnitude of a Vector
"""
if v.GetLength()>max:
v.Normalize()
v *= max