Maths

class BBox

Calculate various bounding box metrics from a list of points, such as min, max, midpoint, radius and size.

classmethod FromObject(cls, obj, selOnly=False)

Returns a new BBox object with all points from the passed object.

Parameters:selOnly (bool) – use selected points only instead of all points.
Raises ValueError:
 if the object has no points.
classmethod FromPointList(cls, lst)

Returns a new BBox object with all points from a list added.

Elements of lst must be of type c4d.Vector.

Raises ValueError:
 if the list is empty.
classmethod FromPolygon(cls, poly, obj)

Returns a new BBox object with all points from the passed polygon.

AddPoint(p)

Add metrics from point p.

AddPoints(lst)

Add metrics from a list of points.

GetMax()

Return max bounds vector.

GetMin()

Return min bounds vector.

GetMp()

Return midpoint vector.

GetRad()

Return radius vector.

GetSize()

Return size vector.

class Plane(pos, n)

Represents a plane defined by positional offset and normal direction.

SetN(self, newN)

Sets the normal of the plane to newN.

SetPos(self, newPos)

Sets the positional offset of the plane to newPos.

SideAsString(self, d)

Given distance d return a string indicating the residence of the point that correlates to the given distance.

Used together with PointResidence():

SideAsString(PointResidence(self, p))
Returns:either front, back or onplane
PointResidence(self, p)

Define the resident direction of a point with respect to the plane.

The point can be either in front of the plane (+1), on the plane (0) or at the back of the plane (-1).

PointDistance(self, p, signed=True)

Calculate distance from a point p to the plane.

Parameters:signed (bool) – set to True if you want the signed distance.

A signed distance can be useful to determine if the point is located in the half space from the backside of the plane or in the half space on the front.

LineIntersection(self, p, d=None)

Calculate intersection point with a line starting at position p and pointing in the direction d.

Parameters:d (c4d.Vector) – direction of the line. If None, the normal of the plane will be used instead.
Returns:c4d.Vector representing the intersection point, or None if an intersection isn’t possible (parallel directions).
FloatEqual(a, b, places=8)

Same as c4d.utils.FloatTolerantCompare just a shorter function name.

MAbs(m)

abs() each component vector of matrix m.

VDeg(v, isHPB=False)

Convert each component of vector v to degrees.

VRad(v, isHPB=False)

Convert each component of vector v to radians.

VAvg(lv)

Calculate the average of a list of vectors.

VAbsMin(v)

Return min component of a vector using abs(x) < abs(y) comparisons.

VAbsMax(v)

Return max component of a vector using abs(x) > abs(y) comparisons.

VBoundaryLerp(lv, t=0.5)

Interpolate linearily between a list of vectors, such that the resulting vector points to the weighted midpoint in the vector space defined by the boundaries max X to min X and max Y to min Y.

Parameters:t (float) – the weighting coefficient.
Returns:None if len(lst) is 0 or if the angle between the two max/min vectors is greater than 180 degrees.
VLerp(startv, endv, t=0.5)

Linear interpolation between 2 vectors.

Same as c4d.utils.VectorMix.

VNLerp(startv, endv, t=0.5)

Normalized linear interpolation between 2 vectors.

VSLerp(startv, endv, t=0.5)

Spherical linear interpolation between 2 vectors.

BuildMatrix(v, off=None, order="zyx")

Builds a new orthonormal basis from a direction and (optionally) an offset vector using John F. Hughes and Thomas Möller’s method.

If off is None, off will default to a zero vector.

BuildMatrix2(v, off=None, base="z")

Builds a new orthonormal basis from a direction and (optionally) an offset vector using base aligned cross products.

If off is None, off will default to a zero vector.

Parameters:base (str) – the base component ‘v’ represents. Must be one of x, y, z, -x, -y, -z
BuildMatrix3(v, v2, off=None, base="z")

Builds a new orthonormal basis from 2 direction and (optionally) an offset vector using cross products.

Parameters:base (str) – the base component ‘v’ represents.
GetMulP(m, v)

Multiply a matrix with a vector representing a point.

Same as c4d.Matrix.Mul(v).

GetMulV(m, v)

Multiply a matrix with a vector representing a direction.

Same as c4d.Matrix.MulV(v)

Det(m)

Determinant of an n x n matrix.

m can be of type c4d.Matrix when n = 3 or list<list> when n = 3 or n = 4 .

Transpose(e)

Transpose matrix e in row-major format to column-major.

e can be of type list<list> structure or c4d.Matrix.

ListToMatrix(lv)

Convert a list of 3 or 4 c4d.Vector to c4d.Matrix.

ListListToMatrix(lli)

Convert a list<list> structure, representing a list of list of coordinate values to a c4d.Matrix.

See MatrixToListList() to find out which list corresponds to which matrix component.

MatrixToListList(m, inclOff=False)

Convert a c4d.Matrix to a list<list> structure.

The structure layout is generally in row-major format, and the ordering the same as the order required for constructing a c4d.Matrix by hand:

[[off.x, off.y, off.z],
 [v1.x,   v1.y,  v1.z],
 [v2.x,   v2.y,  v2.z],
 [v3.x,   v3.y,  v3.z]]
UnitNormal(a, b, c)

Calculate unit normal of a planar surface.

Raises ValueError:
 if magnitude <= 0.0
IsPointInTriangle(p, a, b, c)

Returns True if the point p is inside the triangle given by points a, b, and c.

IsColinear(lv)

Given a list of vectors check if they all share the same coordinates in at least 2 dimensions.

Returns:True if all the vectors in the list are co-linear.
IsZeroVector(v)

Uses float tolerant component comparison to check if v is a zero vector.

LineLineDistance(p1a, p1b, p2a, p2b)

Computes the smallest distance between two 3D lines.

Returns:tuple of two c4d.Vectors which are the points on each of the two input lines that, when connected, form a segment which represents the shortest distance between the two lines.
WrapPi(theta)

Wraps an angle theta in range -pi..pi by adding the correct multiple of 2 pi.

SafeAcos(x)

Same as math.acos(x) but if x is out of range, it is clamped to the nearest valid value. The value returned is in range 0..pi, the same as the standard math.acos function.

Previous topic

API docs

Next topic

Mesh

This Page