6. ccPrimitives

Primitives regroups all the geometric generators provided by CloudCompare: ccBox, ccCone, ccCylinder, ccPlane, ccQuadric, ccSphere, ccTorus, ccDish.

The primitives are derived from a generic primitive ccGenericPrimitive.

Rotation Translation matrix can be applied at construction time or after.

6.1. Box

class cloudComPy.ccBox

Bases: ccGenericPrimitive, ccMesh

Box dimensions axis along each dimension are defined in a single 3D vector.

A box is in fact composed of 6 planes (ccPlane).

Parameters
  • dims (tuple) – box dimensions

  • transMat (ccGLMatrix,optional) – 3D transformation, default 0 (can be set afterwards with ccDrawableObject::setGLTransformation)

  • name (str,optional) – name, default ‘Box’

getDimensions(self: _cloudComPy.ccBox) Vector3Tpl<T>

Get the box dimensions.

Returns

the box dimensions

Return type

tuple dimensions

6.2. Cone

class cloudComPy.ccCone

Bases: ccGenericPrimitive, ccMesh

Cone axis corresponds to the ‘Z’ dimension by default.

Parameters
  • bottomRadius (float) – cone bottom radius

  • topRadius (float) – cone top radius

  • height (float) – cone height (transformation should point to the axis center)

  • xOff (float,optional) – (default 0) displacement of axes along X-axis (Snout mode)

  • yOff (float,optional) – (default 0) displacement of axes along Y-axis (Snout mode)

  • transMat (ccGLMatrix,optional) – (default 0) 3D transformation (can be set afterwards with ccDrawableObject::setGLTransformation)

  • name (str,optional) – name, default ‘Cone’

  • precision (int,optional) – drawing precision (angular step = 360/precision), default 24

  • uniqueID (int,optional) – unique ID (handle with care)

getBottomCenter(self: _cloudComPy.ccCone) Vector3Tpl<T>

Returns axis bottom end point after applying transformation.

Returns

axis bottom end point after applying transformation

Return type

CCVector3

getBottomRadius(self: _cloudComPy.ccCone) float

Returns bottom radius.

Returns

bottom radius

Return type

double

getHeight(self: _cloudComPy.ccCone) float

Returns Height.

Returns

Height

Return type

double

getLargeCenter(self: _cloudComPy.ccCone) Vector3Tpl<T>

Returns cone axis end point associated with whichever radii is larger.

Returns

cone axis end point associated with whichever radii is larger

Return type

CCVector3

getLargeRadius(self: _cloudComPy.ccCone) float

Returns whichever cone radii is larger.

Returns

whichever cone radii is larger

Return type

double

getSmallCenter(self: _cloudComPy.ccCone) Vector3Tpl<T>

Returns cone axis end point associated with whichever radii is smaller.

Returns

cone axis end point associated with whichever radii is smaller

Return type

CCVector3

getSmallRadius(self: _cloudComPy.ccCone) float

Returns whichever cone radii is smaller.

Returns

whichever cone radii is smaller

Return type

double

getTopCenter(self: _cloudComPy.ccCone) Vector3Tpl<T>

Returns axis top end point after applying transformation.

Returns

axis top end point after applying transformation

Return type

CCVector3

getTopRadius(self: _cloudComPy.ccCone) float

Returns top radius.

Returns

top radius

Return type

double

6.3. Cylinder

class cloudComPy.ccCylinder

Bases: ccCone

Cylinder axis corresponds to the ‘Z’ dimension.

Internally represented by a cone with the same top and bottom radius.

Parameters
  • radius (float) – cylinder radius

  • height (float) – cylinder height (transformation should point to the axis center)

  • transMat (ccGLMatrix,optional) – (default 0) 3D transformation (can be set afterwards with ccDrawableObject::setGLTransformation)

  • name (str,optional) – name, default ‘Cylinder’

  • precision (int,optional) – drawing precision (angular step = 360/precision), default 24

  • uniqueID (int,optional) – unique ID (handle with care)

6.4. Plane

class cloudComPy.ccPlane

Bases: ccGenericPrimitive, ccMesh

Plane normal corresponds to ‘Z’ dimension.

Parameters
  • xWidth (float) – plane width along ‘X’ dimension

  • yWidth (float) – plane width along ‘Y’ dimension

  • transMat (ccGLMatrix,optional) – (default 0) 3D transformation (can be set afterwards with ccDrawableObject::setGLTransformation)

  • name (str,optional) – name, default ‘Plane’

static Fit(arg0: _cloudComPy.GenericIndexedCloudPersist) _cloudComPy.ccPlane

Fits a plane primitive on a cloud.

The cloud can be either a pointCloud or a Polyline.

Parameters

cloud (GenericIndexedCloudPersist) – input cloud

Returns

plane primitive (if successful)

Return type

ccPlane

getCenter(self: _cloudComPy.ccPlane) Vector3Tpl<T>

Returns the center of the plane.

Returns

plane center

Return type

CCVector3

getEquation(self: _cloudComPy.ccPlane) List[float]

Returns the equation of the plane.

Returns

Plane equation : [a, b, c, d] as ax+by+cz=d

Return type

tuple

getNormal(self: _cloudComPy.ccPlane) Vector3Tpl<T>

Returns the normal of the plane.

Returns

plane normal

Return type

CCVector3

6.5. Quadric

class cloudComPy.ccQuadric

Bases: ccGenericPrimitive, ccMesh

Quadric orthogonal dimension is ‘Z’ by default.

Parameters
  • minCorner (tuple) – min corner of the ‘representation’ base area

  • maxCorner (tuple) – max corner of the ‘representation’ base area

  • eq (tuple) – equation coefficients ( Z = a + b.X + c.Y + d.X^2 + e.X.Y + f.Y^2)

  • dims (tuple,optional) – (default 0) dimension indexes

  • transMat (ccGLMatrix,optional) – (default 0) 3D transformation (can be set afterwards with ccDrawableObject::setGLTransformation)

  • name (str,optional) – optional name, default ‘Quadric’

  • precision (int,optional) – optional drawing precision, default 24

6.6. Sphere

class cloudComPy.ccSphere

Bases: ccGenericPrimitive, ccMesh

Parameters
  • radius (float) – sphere radius.

  • transMat (ccGLMatrix,optional) – (default 0) 3D transformation (can be set afterwards with ccDrawableObject::setGLTransformation)

  • name (str,optional) – optional name, default ‘Sphere’

  • precision (int,optional) – optional drawing precision (angular step = 360/precision), default 24

  • uniqueID (int,optional) – optional unique ID (handle with care)

getRadius(self: _cloudComPy.ccSphere) float

Get the sphere radius.

Returns

radius

Return type

float

6.7. Torus

class cloudComPy.ccTorus

Bases: ccGenericPrimitive, ccMesh

Torus is defined in the XY plane by default.

Parameters
  • insideRadius (float) – inside radius

  • outsideRadius (float) – outside radius

  • angle (float,optional) – rad (default 2*pi) subtended angle (in radians)

  • rectangularSection (bool,optional) – (default False) whether section is rectangular or round

  • rectSectionHeight (float,optional) – section height (if rectangular torus)

  • transMat (ccGLMatrix,optional) – (default 0) 3D transformation (can be set afterwards with ccDrawableObject::setGLTransformation)

  • name (str,optional) – name, default ‘Torus’

  • precision (int,optional) – drawing precision (main loop angular step = 360/(4*precision), circular section angular step = 360/precision), default 24

  • uniqueID (int,optional) – unique ID (handle with care)

6.8. Dish

class cloudComPy.ccDish

Bases: ccGenericPrimitive, ccMesh

Either a section of a sphere, or half of an ellipsoid!

The origin of the Dish is at the centre of the base, and the Z-axis lies along the normal to the base.

Parameters
  • radius (float) – base radius

  • height (float) – maximum height of dished surface above base

  • radius2 (float,optional) – (default 0) If radius2 is zero, dish is drawn as a section of sphere. If radius2 is >0, dish is defined as half of an ellipsoid.

  • transMat (ccGLMatrix,optional) – (default 0) 3D transformation (can be set afterwards with ccDrawableObject::setGLTransformation)

  • name (str,optional) – name, default ‘Dish’

  • precision (int,optional) – drawing precision (angular step = 360/precision), default 24

6.9. Generic primitive

class cloudComPy.ccGenericPrimitive

Bases: pybind11_object

getTransformation(self: _cloudComPy.ccGenericPrimitive) _cloudComPy.ccGLMatrix

Returns transformation matrix.

Returns

transformation matrix

Return type

ccGLMatrix

getTypeName(self: _cloudComPy.ccGenericPrimitive) QString

Returns type name (sphere, cylinder, etc.)

Returns

type name

Return type

str

7. transformations

7.1. Rotation Translation Matrix

class cloudComPy.ccGLMatrix

Bases: ccGLMatrixTpl_float

A 4x4 ‘transformation’ matrix (column major order), simple precision (float).

Transformation (M) is composed by a rotation (R) and a translation (T): M*X = R*X + T. See OpenGL transformations.

Available operators: += -= *= *

Default constructor (no parameter) gives identity.

Alternate constructor 1:

Parameters
  • X (tuple) – 3 first elements of the 1st column (last one is 0)

  • Y (tuple) – 3 first elements of the 2nd column (last one is 0)

  • Z (tuple) – 3 first elements of the 3rd column (last one is 0)

  • Tr (tuple) – 3 first elements of the last column (last one is 1)

Alternate constructor 2: :param list data: 16 elements of the 4x4 matrix, stored in column major order (see data())

FromToRotation(self: Vector3Tpl<T>, arg0: Vector3Tpl<T>) _cloudComPy.ccGLMatrix

Creates a transformation matrix that rotates a vector to another.

Adapted from “Efficiently Building a Matrix to Rotate One Vector to Another” By Tomas Möller, John Hughes, Journal of Graphics Tools, 4(4):1-4, 1999

Parameters
  • from (tuple) – normalized non-zero source vector

  • to (tuple) – normalized non-zero destination vector

Returns

transformation matrix

Return type

ccGLMatrix

FromViewDirAndUpDir(self: Vector3Tpl<T>, arg0: Vector3Tpl<T>) _cloudComPy.ccGLMatrix

Generates a ‘viewing’ matrix from a looking vector and a ‘up’ direction.

warning No translation is applied (pure rotation matrix).

Parameters
  • forward (tuple) – forward ‘view’ vector

  • up (tuple) – up vector

Returns

rotation matrix

Return type

ccGLMatrix

Interpolate(self: float, arg0: _cloudComPy.ccGLMatrixTpl_float, arg1: _cloudComPy.ccGLMatrixTpl_float) _cloudComPy.ccGLMatrix

Interpolates two matrices at relative position ‘coef’

Parameters
  • coef (float) – interpolation position (should be between 0 and 1).

  • glMat1 (ccGLMatrix) – ‘left’ matrix

  • glMat2 (ccGLMatrix) – ‘right’ matrix

Returns

interpolated matrix

Return type

ccGLMatrix

clearTranslation(self: _cloudComPy.ccGLMatrixTpl_float) None

Clears translation.

Translation is set to (0,0,0).

data(self: _cloudComPy.ccGLMatrixTpl_float) List[float]

Returns internal data of the ccGLMatrix

Returns

one dim. data array of 16 float in the order col. 1, col. 2, col. 3, col. 4

Return type

tuple

static fromDouble(arg0: ccGLMatrixTpl<double>) ccGLMatrix

Converts a ccGLMatrixd (double precision) in a ccGLMatrix (simple precision).

Parameters

dblmat (ccGLMatrix_double) – double precision ccGLMatrix

Returns

simple precision ccGLMatrix

Return type

ccGLMatrix

static fromString(arg0: QString) _cloudComPy.ccGLMatrixTpl_float

Static method returning a ccGLMatrix from the string version of the transformer coefficients.

If the creation does not succeed, returns identity transformation.

Parameters

matText (string) – string version of the transformer coefficients.

Returns

ccGLMatrix transformation

Return type

ccGLMatrix

getColumn(self: _cloudComPy.ccGLMatrixTpl_float, arg0: int) List[float]

Returns a column of the transformation, given its index.

Parameters

index (int) – column index (between 0 and 3)

Returns

column

Return type

tuple

getParameters1(self: _cloudComPy.ccGLMatrixTpl_float) _cloudComPy.ccGLMatrixParams1_float

Returns equivalent parameters: a rotation axis, an angle and a translation.

Returns

equivalent parameters structure

Return type

ccGLMatrixParams1_float or ccGLMatrixParams1_double

getParameters2(self: _cloudComPy.ccGLMatrixTpl_float) _cloudComPy.ccGLMatrixParams2_float

Returns equivalent parameters: 3 rotation angles and a translation.

Returns

equivalent parameters structure

Return type

ccGLMatrixParams2_float or ccGLMatrixParams2_double

initFromParameters(*args, **kwargs)

Overloaded function.

  1. initFromParameters(self: _cloudComPy.ccGLMatrixTpl_float, arg0: float, arg1: Vector3Tpl<T>, arg2: Vector3Tpl<T>) -> None

Inits transformation from a rotation axis, an angle and a translation.

Parameters
  • alpha_rad (float) – rotation angle (in radians)

  • axis3D (tuple) – rotation axis

  • t3D (tuple) – translation (x, y, z)

  1. initFromParameters(self: _cloudComPy.ccGLMatrixTpl_float, arg0: float, arg1: float, arg2: float, arg3: Vector3Tpl<T>) -> None

Inits transformation from 3 rotation angles and a translation.

See Euler angles (Tait-Bryan Z1Y2X3)

Parameters
  • phi_rad (float) – Phi angle (in radians)

  • theta_rad (float) – Theta angle (in radians)

  • psi_rad (float) – Psi angle (in radians)

  • t3D (tuple) – translation (x, y, z)

inverse(self: _cloudComPy.ccGLMatrixTpl_float) _cloudComPy.ccGLMatrix

Returns inverse transformation.

Returns

inverse transformation matrix

Return type

ccGLMatrix

invert(self: _cloudComPy.ccGLMatrixTpl_float) None

Inverts transformation (in place).

toString(self: _cloudComPy.ccGLMatrixTpl_float) QString

String version of the transformer coefficients

Returns

String version of the transformer coefficients

Return type

string

transpose(self: _cloudComPy.ccGLMatrixTpl_float) None

Transposes matrix (in place)

transposed(self: _cloudComPy.ccGLMatrixTpl_float) _cloudComPy.ccGLMatrix

Returns transposed matrix.

Returns

transposed matrix

Return type

ccGLMatrix

xRotation(self: _cloudComPy.ccGLMatrixTpl_float) _cloudComPy.ccGLMatrix

Returns the rotation component around X only.

Returns

rotation matrix

Return type

ccGLMatrix

yRotation(self: _cloudComPy.ccGLMatrixTpl_float) _cloudComPy.ccGLMatrix

Returns the rotation component around Y only.

Returns

rotation matrix

Return type

ccGLMatrix

zRotation(self: _cloudComPy.ccGLMatrixTpl_float) _cloudComPy.ccGLMatrix

Returns the rotation component around Z only.

Returns

rotation matrix

Return type

ccGLMatrix

class cloudComPy.ccGLMatrixd

Bases: ccGLMatrixTpl_double

A 4x4 ‘transformation’ matrix (column major order), double precision (double).

Transformation (M) is composed by a rotation (R) and a translation (T): M*X = R*X + T. See OpenGL transformations.

Available operators: += -= *= *

Default constructor (no parameter) gives identity.

Alternate constructor 1:

Parameters
  • X (tuple) – 3 first elements of the 1st column (last one is 0)

  • Y (tuple) – 3 first elements of the 2nd column (last one is 0)

  • Z (tuple) – 3 first elements of the 3rd column (last one is 0)

  • Tr (tuple) – 3 first elements of the last column (last one is 1)

Alternate constructor 2: :param list data: 16 elements of the 4x4 matrix, stored in column major order (see data())

FromToRotation(self: Vector3Tpl<T>, arg0: Vector3Tpl<T>) _cloudComPy.ccGLMatrixd

Creates a transformation matrix that rotates a vector to another.

Adapted from “Efficiently Building a Matrix to Rotate One Vector to Another” By Tomas Möller, John Hughes, Journal of Graphics Tools, 4(4):1-4, 1999

Parameters
  • from (tuple) – normalized non-zero source vector

  • to (tuple) – normalized non-zero destination vector

Returns

transformation matrix

Return type

ccGLMatrix

FromViewDirAndUpDir(self: Vector3Tpl<T>, arg0: Vector3Tpl<T>) _cloudComPy.ccGLMatrixd

Generates a ‘viewing’ matrix from a looking vector and a ‘up’ direction.

warning No translation is applied (pure rotation matrix).

Parameters
  • forward (tuple) – forward ‘view’ vector

  • up (tuple) – up vector

Returns

rotation matrix

Return type

ccGLMatrix

Interpolate(self: float, arg0: _cloudComPy.ccGLMatrixTpl_double, arg1: _cloudComPy.ccGLMatrixTpl_double) _cloudComPy.ccGLMatrixd

Interpolates two matrices at relative position ‘coef’

Parameters
  • coef (float) – interpolation position (should be between 0 and 1).

  • glMat1 (ccGLMatrix) – ‘left’ matrix

  • glMat2 (ccGLMatrix) – ‘right’ matrix

Returns

interpolated matrix

Return type

ccGLMatrix

clearTranslation(self: _cloudComPy.ccGLMatrixTpl_double) None

Clears translation.

Translation is set to (0,0,0).

data(self: _cloudComPy.ccGLMatrixTpl_double) List[float]

Returns internal data of the ccGLMatrix

Returns

one dim. data array of 16 float in the order col. 1, col. 2, col. 3, col. 4

Return type

tuple

static fromString(arg0: QString) _cloudComPy.ccGLMatrixTpl_double

Static method returning a ccGLMatrix from the string version of the transformer coefficients.

If the creation does not succeed, returns identity transformation.

Parameters

matText (string) – string version of the transformer coefficients.

Returns

ccGLMatrix transformation

Return type

ccGLMatrix

getColumn(self: _cloudComPy.ccGLMatrixTpl_double, arg0: int) List[float]

Returns a column of the transformation, given its index.

Parameters

index (int) – column index (between 0 and 3)

Returns

column

Return type

tuple

getParameters1(self: _cloudComPy.ccGLMatrixTpl_double) _cloudComPy.ccGLMatrixParams1_double

Returns equivalent parameters: a rotation axis, an angle and a translation.

Returns

equivalent parameters structure

Return type

ccGLMatrixParams1_float or ccGLMatrixParams1_double

getParameters2(self: _cloudComPy.ccGLMatrixTpl_double) _cloudComPy.ccGLMatrixParams2_double

Returns equivalent parameters: 3 rotation angles and a translation.

Returns

equivalent parameters structure

Return type

ccGLMatrixParams2_float or ccGLMatrixParams2_double

initFromParameters(*args, **kwargs)

Overloaded function.

  1. initFromParameters(self: _cloudComPy.ccGLMatrixTpl_double, arg0: float, arg1: Vector3Tpl<T>, arg2: Vector3Tpl<T>) -> None

Inits transformation from a rotation axis, an angle and a translation.

Parameters
  • alpha_rad (float) – rotation angle (in radians)

  • axis3D (tuple) – rotation axis

  • t3D (tuple) – translation (x, y, z)

  1. initFromParameters(self: _cloudComPy.ccGLMatrixTpl_double, arg0: float, arg1: float, arg2: float, arg3: Vector3Tpl<T>) -> None

Inits transformation from 3 rotation angles and a translation.

See Euler angles (Tait-Bryan Z1Y2X3)

Parameters
  • phi_rad (float) – Phi angle (in radians)

  • theta_rad (float) – Theta angle (in radians)

  • psi_rad (float) – Psi angle (in radians)

  • t3D (tuple) – translation (x, y, z)

inverse(self: _cloudComPy.ccGLMatrixTpl_double) _cloudComPy.ccGLMatrixd

Returns inverse transformation.

Returns

inverse transformation matrix

Return type

ccGLMatrix

invert(self: _cloudComPy.ccGLMatrixTpl_double) None

Inverts transformation (in place).

toString(self: _cloudComPy.ccGLMatrixTpl_double) QString

String version of the transformer coefficients

Returns

String version of the transformer coefficients

Return type

string

transpose(self: _cloudComPy.ccGLMatrixTpl_double) None

Transposes matrix (in place)

transposed(self: _cloudComPy.ccGLMatrixTpl_double) _cloudComPy.ccGLMatrixd

Returns transposed matrix.

Returns

transposed matrix

Return type

ccGLMatrix

xRotation(self: _cloudComPy.ccGLMatrixTpl_double) _cloudComPy.ccGLMatrixd

Returns the rotation component around X only.

Returns

rotation matrix

Return type

ccGLMatrix

yRotation(self: _cloudComPy.ccGLMatrixTpl_double) _cloudComPy.ccGLMatrixd

Returns the rotation component around Y only.

Returns

rotation matrix

Return type

ccGLMatrix

zRotation(self: _cloudComPy.ccGLMatrixTpl_double) _cloudComPy.ccGLMatrixd

Returns the rotation component around Z only.

Returns

rotation matrix

Return type

ccGLMatrix

class cloudComPy.ccGLMatrixParams1_float

Bases: pybind11_object

Equivalent parameters of a ccGLMatrix transformation: a rotation axis, an angle and a translation.

Variables
  • alpha_rad (float) – rotation angle in radians (in [0;pi])

  • axis3D (tuple) – unit rotation axis

  • t3D (tuple) – translation

class cloudComPy.ccGLMatrixParams2_float

Bases: pybind11_object

Equivalent parameters of a ccGLMatrix transformation: 3 rotation angles and a translation.

See Euler angles (Tait-Bryan Z1Y2X3)

Variables
  • phi_rad (float) – Phi angle (in radians)

  • theta_rad (float) – Theta angle (in radians)

  • psi_rad (float) – Psi angle (in radians)

  • t3D (tuple) – translation

class cloudComPy.ccGLMatrixParams1_double

Bases: pybind11_object

Equivalent parameters of a ccGLMatrix transformation: a rotation axis, an angle and a translation.

Variables
  • alpha_rad (float) – rotation angle in radians (in [0;pi])

  • axis3D (tuple) – unit rotation axis

  • t3D (tuple) – translation

class cloudComPy.ccGLMatrixParams2_double

Bases: pybind11_object

Equivalent parameters of a ccGLMatrix transformation: 3 rotation angles and a translation.

See Euler angles (Tait-Bryan Z1Y2X3)

Variables
  • phi_rad (float) – Phi angle (in radians)

  • theta_rad (float) – Theta angle (in radians)

  • psi_rad (float) – Psi angle (in radians)

  • t3D (tuple) – translation