Cyclone 3DR Script
from Technodigit, part of Hexagon. Copyright 1997-2024.
Loading...
Searching...
No Matches
SMatrix Class Reference

Provide matrix with 3 lines and 4 columns to make any transformation. More...

Public Types

enum  ConstraintFlag {
  TRANSLATION_X = 1 , TRANSLATION_Y = 2 , TRANSLATION_Z = 4 , ROTATION_X = 8 ,
  ROTATION_Y = 16 , ROTATION_Z = 32 , ALL_MOVEMENT = 63
}
 The transformation constraints (bit mask option) More...
 
enum  SequenceEnum { OrderXYZ = 0 , OrderYXZ = 1 , OrderZXY = 2 }
 In which order are applied the rotations? More...
 
enum  UnitEnum { RADIAN = 0 , DEGREE = 1 }
 Unit of the angle. More...
 

Public Member Functions

number AddToDocAsUCS (string name, boolean isActivated=true)
 Add the matrix to the scene as an UCS with the given name. More...
 
 ApplyTransformation (SMatrix matrixToMul)
 Apply the transformation on the current matrix. It's the matrix product of the two matrices: this*matrixToMul. More...
 
Object GetEuler (UnitEnum unit)
 Interpret values from a SMatrix and find the rotation angle and the translation vector. The convention used is to apply rotation in order X->Y->Z such that R = Rz*Ry*Rx. More...
 
Object GetQuaternion ()
 Interpret values from a SMatrix and find the quaternion w + xi + yj + zk and the translation vector. More...
 
number GetValue (number row, number column)
 Get the value of the SMatrix at the position(row, column). More...
 
Object InitAlign (SPoint fixedP1, SPoint fixedP2, SPoint fixedP3, SPoint mobileP1, SPoint mobileP2, SPoint mobileP3)
 This is an overloaded member function, provided for convenience. It differs from the other InitAlign() function only in what arguments it accepts. More...
 
Object InitAlign (SPoint fixedP1, SPoint fixedP2, SPoint mobileP1, SPoint mobileP2)
 Calculate the transformation matrix from 2 matching point couples. More...
 
Object InitAutoRoughAlign (SComp refObject, SComp objectToAlign)
 Compute the matrix to roughly align a component on another. More...
 
Object InitBestAlign (Array< SPoint > targetPoints, Array< SPoint > sourcePoints, number mode, ConstraintFlag constraintBitMask=SMatrix.ALL_MOVEMENT, SPoint fixedPoint=null, SVector constraintAxis=null)
 Set the matrix for the best fit mapping of the source points onto the target points in a least squares sense. More...
 
Object InitBestRotate (Array< SPoint > targetPoints, Array< SPoint > sourcePoints, SPoint fixPoint)
 Set the matrix for the best ROTATION mapping of the source points onto the target points in a least squares sense. ONLY ROTATION. More...
 
Object InitBestTranslate (Array< SPoint > targetPoints, Array< SPoint > sourcePoints)
 Set the matrix for the best TRANSLATION mapping of the source points onto the target points in a least squares sense. ONLY TRANSLATION. More...
 
 InitIdentity ()
 Initialize the SMatrix to the unitary matrix. All the cells are initialized to zero except the diagonal which is to 1. More...
 
Object InitInverse (SMatrix mat)
 Initialize the current matrix to the inversed matrix that is: CurrentMatrix*Mat=IdentityMatrix. More...
 
 InitMirrorAxis (SPoint axisP1, SPoint axisP2)
 Set the matrix for a mirror axis. More...
 
 InitMirrorPlane (SPoint planePnt, SVector normalVect)
 Set the matrix for a planar mirror. More...
 
 InitMirrorPnt (SPoint mirrorCenter)
 Set the matrix for a point mirror. More...
 
 InitQuaternion (number w, number x, number y, number z)
 Initialize a rotation matrix from a quaternion tuple (w, x, y, z). More...
 
Object InitRot (number angX, number angY, number angZ, UnitEnum unit, SequenceEnum sequence, SPoint originPoint)
 Set the matrix for the rotation around the 3 axis X,Y,Z. More...
 
Object InitRot (SPoint axisPt, SVector axisVect, number angle, UnitEnum unit)
 Set the matrix for the rotation of an angle around an axis. More...
 
Object InitRPSAlignment (Array< SPoint > targetPoints, Array< SPoint > sourcePoints, Array< Array< boolean > > xyzConstraints, Array< SCloud > associatedClouds=null, number neighborhood=0)
 Compute the RPS alignment matrix from given source and target SPoint. More...
 
 InitScale (SPoint scaleCenter, number xScale, number yScale, number zScale)
 Set the matrix for a different scale ratio along X, Y and Z with a center. More...
 
boolean IsIdentity ()
 Return if the matrix is the identity or not. More...
 
 SMatrix ()
 Default constructor. More...
 
 SMatrix (Array< number > row1, Array< number > row2, Array< number > row3)
 Construct a SMatrix by defining its rows. More...
 
 SMatrix (SMatrix matrix)
 Construct a SMatrix by copying the SMatrix other. More...
 
 SMatrix (SPoint axisPt, SVector axisVect, number angle, UnitEnum unit)
 Constructor to set a rotation matrix of an angle around an axis. If the input data are not coherent, the matrix returned is the identity. More...
 
 SMatrix (SVector translate)
 Constructor from a vector. The SMatrix obtained is a pure translation. More...
 
string toString ()
 Get the type of the variable. More...
 
number UpdateUCS (string name)
 Update with the current matrix the UCS found with the given name. More...
 
string ValuesToString ()
 Get a string representation of the matrix. More...
 

Static Public Member Functions

static Object BestFitCompute (Array< SComp > compTable, number thresholdDist=0, number bestFitType=0, ConstraintFlag constraintBitMask=SMatrix.ALL_MOVEMENT, SPoint fixedPoint=null, SVector constraintAxis=null, boolean attractReversedNormals=true)
 Calculate the matrix that should be applied to each component of a set to make a best fit of all the components in a least squares sense. More...
 
static Object EulerToQuaternion (number angX, number angY, number angZ, UnitEnum unit)
 Return the quaternion w + xi + yj + zk associated to the rotation angles in Euler convention (Applied in order X->Y->Z such that R = Rz*Ry*Rx). More...
 
static SMatrix FromActiveCS ()
 Return the matrix associated to the active coordinate system. More...
 
static Array< SMatrixFromUCS (string name)
 Search all the component with the given name. More...
 
static Object GetArmCoordinateSystem (number index)
 Return the SMatrix saved at a given index. More...
 
static SMatrix New ()
 Default constructor. More...
 
static SMatrix New (Array< number > row1, Array< number > row2, Array< number > row3)
 Construct a SMatrix by defining its rows. More...
 
static SMatrix New (SMatrix matrix)
 Construct a SMatrix by copying the SMatrix other. More...
 
static SMatrix New (SPoint axisPt, SVector axisVect, number angle, UnitEnum unit)
 Constructor to set a rotation matrix of an angle around an axis. If the input data are not coherent, the matrix returned is the identity. More...
 
static SMatrix New (SVector translate)
 Constructor from a vector. The SMatrix obtained is a pure translation. More...
 
static Object QuaternionToEuler (number w, number x, number y, number z, UnitEnum unit)
 Return the rotation angles associated to the quaternion w + xi + yj + zk. Rotation angles are given in the Euler convention (Applied in order X->Y->Z such that R = Rz*Ry*Rx). More...
 
static Object SaveArmCoordinateSystem (number index, SMatrix newMatrix)
 Save a SMatrix as a Coordinate System. If a matrix exists at the input index, it will be deleted. More...
 
static Object UpdateArmCoordinateSystem (number index, SMatrix newMatrix)
 Update the matrix at the input index, by multiplying the current matrix by the input matrix. More...
 

Detailed Description

Provide matrix with 3 lines and 4 columns to make any transformation.

This class should be used in order to apply transformations to other components.

Member Enumeration Documentation

◆ ConstraintFlag

The transformation constraints (bit mask option)

Enumerator
TRANSLATION_X 

Allow the translation along the X-axis.

TRANSLATION_Y 

Allow the translation along the Y-axis.

TRANSLATION_Z 

Allow the translation along the Z-axis.

ROTATION_X 

Allow the rotation around the X-axis.

ROTATION_Y 

Allow the rotation around the Y-axis.

ROTATION_Z 

Allow the rotation around the Z-axis.

ALL_MOVEMENT 

Disable constraints.

◆ SequenceEnum

In which order are applied the rotations?

Enumerator
OrderXYZ 

Applied in order X->Y->Z such that R = Rz*Ry*Rx. This is the Euler convention. In aerial photogrammetric measurements this transformation corresponds to the OPK sequence also called (Omega Phi Kappa) with Omega=Rx, Phi=Ry and Kappa=Rz.

OrderYXZ 

Applied in order Y->X->Z such that R=Rz*Rx*Ry. In aerial photogrammetric measurements this transformation corresponds to the POK sequence also called (Phi Omega Kappa) with Omega=Rx, Phi=Ry and Kappa=Rz.

OrderZXY 

Applied in order Z->X->Y such that R=Ry*Rx*Rz. In terrestrial photogrammetric measurements this transformation corresponds to the POK sequence also called (Phi Omega Kappa) with Omega=Rx, Kappa=Ry and Phi=Rz.

◆ UnitEnum

Unit of the angle.

Enumerator
RADIAN 

Radian.

DEGREE 

Degree.

Constructor & Destructor Documentation

◆ SMatrix() [1/5]

SMatrix::SMatrix ( )

Default constructor.

The matrix is initialized to the unitary matrix.The vector is the null vector.

◆ SMatrix() [2/5]

SMatrix::SMatrix ( SMatrix  matrix)

Construct a SMatrix by copying the SMatrix other.

Parameters
matrix(SMatrix) The matrix to copy.

◆ SMatrix() [3/5]

SMatrix::SMatrix ( SVector  translate)

Constructor from a vector. The SMatrix obtained is a pure translation.

Parameters
translate(SVector) The translation vector.

◆ SMatrix() [4/5]

SMatrix::SMatrix ( Array< number >  row1,
Array< number >  row2,
Array< number >  row3 
)

Construct a SMatrix by defining its rows.

Parameters
row1(Array<number>) The 4 data of the first row
row2(Array<number>) The 4 data of the second row
row3(Array<number>) The 4 data of the third row

◆ SMatrix() [5/5]

SMatrix::SMatrix ( SPoint  axisPt,
SVector  axisVect,
number  angle,
UnitEnum  unit 
)

Constructor to set a rotation matrix of an angle around an axis. If the input data are not coherent, the matrix returned is the identity.

Parameters
axisPt(SPoint) First point of the axis.
axisVect(SVector) Vector of the axis.
angle(number) Angle around the axis.
unit(UnitEnum) In which unit is expressed angle.

Member Function Documentation

◆ AddToDocAsUCS()

number SMatrix::AddToDocAsUCS ( string  name,
boolean  isActivated = true 
)

Add the matrix to the scene as an UCS with the given name.

Note
The matrix used for the UCS should not have null rows. Also, the vectors created from the rows should not be parallel.
Parameters
name(string) Name of the UCS
isActivated(boolean) True if the UCS should be activated
Returns
The error code
Return values
0No error.
1The matrix is not well defined.

◆ ApplyTransformation()

SMatrix::ApplyTransformation ( SMatrix  matrixToMul)

Apply the transformation on the current matrix. It's the matrix product of the two matrices: this*matrixToMul.

Parameters
matrixToMul(SMatrix) The SMatrix corresponding to the transformation to apply.

◆ BestFitCompute()

static Object SMatrix::BestFitCompute ( Array< SComp compTable,
number  thresholdDist = 0,
number  bestFitType = 0,
ConstraintFlag  constraintBitMask = SMatrix.ALL_MOVEMENT,
SPoint  fixedPoint = null,
SVector  constraintAxis = null,
boolean  attractReversedNormals = true 
)
static

Calculate the matrix that should be applied to each component of a set to make a best fit of all the components in a least squares sense.

Note
This function analyzes the overlapping area of the objects. It means that an overlapping area must exist. Otherwise the best fit operation may give a non relevant result or no result at all (identity matrix).
If you use this function with clouds, the cloud must represent a surface in order to project point on this cloud. If you have only a few points (less than 100 of overlapping area) it may be difficult for the function to approximate a surface and to make statistic evaluations. The result may be disappointing or you may have no result at all (identity matrix). If you have only a few points in cloud number 1 to best fit with the same number of points matching in cloud number 2, you should prefer the function SMatrix.InitBestAlign().
Before calling the function, the component should be roughly prepositioned so they are not too far from each other.
If the fitting error is small, there is a high chance that the position of the component is correct. A high fitting error can come from several factors:
Parameters
compTable(Array<SComp>) Table of components to best fit together The first component of the list is assumed to be immobile. Valid components in the list are: SCloud, SPoly, SMultiline, SCADSurface
thresholdDist(number) Ignore the part of the components whose distance with other components is greater than this threshold. If a complete session is done and BestFitCompute has not been called previously, this value can be set to null to tell the function to take 1/100 of the greatest size. The parameter "thresholdDist" is very critical To explain this value, we will take the comparison of a "magnet". When you make the best fit, you "attract" some parts of the shape so that they get closer and to minimize a distance. However, the fitting between the shapes will be correct only if the "attraction" is done between 2 parts representing the same shape in the different objects to fit. In other words, if you attract 2 parts at the opposite extremities of the object to fit, there is a high chance that the position at the end will be incorrect. To avoid this, the "magnet" must limit his attraction to a certain distance and it is the goal of this parameter. The value to set should be in relation with the misalignment error before entering in the command. In other words "how far are the object to align?". In this value, you must also take in account the measurement accuracy and the noise thickness, if any.
bestFitType(number) Which type of best fit should be done ?
  • 0: Component 1 to n are best fitted with the first component (number 0 that is immobile)
  • 1: Best fit all together. (component number i is best fitted with all other n-1 components). This option is ignored if there are only 2 components.
  • 2: Component 1 to n are best fitted with the first component (number 0 that is immobile) and a SCALE is applied on components 1 to n
constraintBitMask(ConstraintFlag) The transformation constraints (bit mask option)
fixedPoint(SPoint) The fixed point. If not null, this point will not move during the rotation.
constraintAxis(SVector) The axis of constraint. If not null, the translation will be guided by this vector.
attractReversedNormals(boolean) Should we make attraction between surfaces having reversed normals ?
  • false: Do not consider overlapping when surfaces have not the same orientation.
  • true: Make an attraction between surfaces even if they do not have the same orientation.
    Note:
    This option will only affect meshes and clouds containing scanning direction information
Return values
ret.ErrorCode(number) The error code
  • 0: OK, no error
  • 1: Invalid list of components or bad / incomplete initialization or impossible to initialize.
ret.MatrixTbl(Array<SMatrix>) The array of resulting matrices defining new component positions, in the same order as the input component table. The first component being assumed as immobile, the first matrix is initialized with the identity matrix.
ret.StdDeviationTbl(Array<number>) The registration standard deviation error of each component
ret.MeanErrorTbl(Array<number>) The registration mean error of each component

◆ EulerToQuaternion()

static Object SMatrix::EulerToQuaternion ( number  angX,
number  angY,
number  angZ,
UnitEnum  unit 
)
static

Return the quaternion w + xi + yj + zk associated to the rotation angles in Euler convention (Applied in order X->Y->Z such that R = Rz*Ry*Rx).

Parameters
angX(number) The pitch angle (left handed rotation around X
angY(number) The roll angle (left handed rotation around Y)
angZ(number) The yaw or heading angle (left handed rotation around Z)
unit(UnitEnum) In which unit are expressed the angles.
Return values
ret.QuatW(number) The coefficient w of the quaternion w + xi + yj + zk.
ret.QuatX(number) The coefficient x of the quaternion w + xi + yj + zk.
ret.QuatY(number) The coefficient y of the quaternion w + xi + yj + zk.
ret.QuatZ(number) The coefficient z of the quaternion w + xi + yj + zk.

◆ FromActiveCS()

static SMatrix SMatrix::FromActiveCS ( )
static

Return the matrix associated to the active coordinate system.

Returns
(SMatrix) The SMatrix associated to the active UCS/WCS.

◆ FromUCS()

static Array< SMatrix > SMatrix::FromUCS ( string  name)
static

Search all the component with the given name.

Parameters
name(string) The name to find.
Returns
(Array<SMatrix>) All the SMatrix with the given name.

◆ GetArmCoordinateSystem()

static Object SMatrix::GetArmCoordinateSystem ( number  index)
static

Return the SMatrix saved at a given index.

Parameters
index(number) The index of the CS to update (1 to 9)
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred
ret.Matrix(SMatrix) The matrix at given index.

◆ GetEuler()

Object SMatrix::GetEuler ( UnitEnum  unit)

Interpret values from a SMatrix and find the rotation angle and the translation vector. The convention used is to apply rotation in order X->Y->Z such that R = Rz*Ry*Rx.

See also
SMatrix::GetQuaternion
Parameters
unit(UnitEnum) In which unit will be expressed the angles.
Return values
ret.ErrorCode(number) The error code
  • 0: OK, no error.
  • 1: The matrix is not a pure rotation, impossible to find rotation and scale, but the translation vector is valid.
ret.Vector(SVector) The translation SVector
ret.RotX(number) The pitch angle (left handed rotation around X)
ret.RotY(number) The roll angle (left handed rotation around Y)
ret.RotZ(number) The yaw or heading angle (left handed rotation around Z)
ret.ScaleX(number) The matrix scale along X
ret.ScaleY(number) The matrix scale along Y
ret.ScaleZ(number) The matrix scale along Z

◆ GetQuaternion()

Object SMatrix::GetQuaternion ( )

Interpret values from a SMatrix and find the quaternion w + xi + yj + zk and the translation vector.

See also
SMatrix::GetEuler
Return values
ret.ErrorCode(number) The error code
  • 0: OK, no error.
  • 1: The matrix is not a pure rotation, impossible to find quaternion and scale, but the translation vector is valid.
ret.Vector(SVector) The translation SVector
ret.QuatW(number) The coefficient w of the quaternion w + xi + yj + zk.
ret.QuatX(number) The coefficient x of the quaternion w + xi + yj + zk.
ret.QuatY(number) The coefficient y of the quaternion w + xi + yj + zk.
ret.QuatZ(number) The coefficient z of the quaternion w + xi + yj + zk.
ret.ScaleX(number) The matrix scale along X
ret.ScaleY(number) The matrix scale along Y
ret.ScaleZ(number) The matrix scale along Z

◆ GetValue()

number SMatrix::GetValue ( number  row,
number  column 
)

Get the value of the SMatrix at the position(row, column).

Parameters
row(number) The index of the row 0 <= row < 3
column(number) The index of the column 0 <= column < 4
Returns
(number) The value at the position (row, column)

◆ InitAlign() [1/2]

Object SMatrix::InitAlign ( SPoint  fixedP1,
SPoint  fixedP2,
SPoint  fixedP3,
SPoint  mobileP1,
SPoint  mobileP2,
SPoint  mobileP3 
)

This is an overloaded member function, provided for convenience. It differs from the other InitAlign() function only in what arguments it accepts.

Parameters
fixedP1(SPoint) Arrival P1
fixedP2(SPoint) Arrival P2
fixedP3(SPoint) Arrival P3
mobileP1(SPoint) Departure P1 to move on fixedP1
mobileP2(SPoint) Departure P2 to align on segment fixedP1 fixedP2
mobileP3(SPoint) Departure P3 to put on the same plane as fixedP1 fixedP2 fixedP3
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Transformation could not be computed. Inconsistent points, an identity matrix is initialized.

◆ InitAlign() [2/2]

Object SMatrix::InitAlign ( SPoint  fixedP1,
SPoint  fixedP2,
SPoint  mobileP1,
SPoint  mobileP2 
)

Calculate the transformation matrix from 2 matching point couples.

Parameters
fixedP1(SPoint) Arrival P1
fixedP2(SPoint) Arrival P2
mobileP1(SPoint) Departure P1 to move on fixedP1
mobileP2(SPoint) Departure P2 to align on segment fixedP1 fixedP2
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Transformation could not be computed. Inconsistent points, an identity matrix is initialized.

◆ InitAutoRoughAlign()

Object SMatrix::InitAutoRoughAlign ( SComp  refObject,
SComp  objectToAlign 
)

Compute the matrix to roughly align a component on another.

Note
The two components to align are supposed to represent the same shape. Unpredictable result may occur if the two components do not represent the same shape or just an overlap portion. If the shape is "symmetric" (sphere, cube, parallelepiped, etc.) the result may be unpredictable modulo 180 degrees.
It is usually necessary to call SMatrix.BestFitCompute() after calling SMatrix.InitAutoRoughAlign()
Parameters
refObject(SComp) The reference object. Valid components in the list are: SCloud, SPoly
objectToAlign(SComp) The object to align on refObject. Valid components in the list are: SCloud, SPoly
Return values
ret.ErrorCode(number) The error code
  • 0: OK, no error.
  • 1: Transformation could not be computed. An identity matrix is initialized.

◆ InitBestAlign()

Object SMatrix::InitBestAlign ( Array< SPoint targetPoints,
Array< SPoint sourcePoints,
number  mode,
ConstraintFlag  constraintBitMask = SMatrix.ALL_MOVEMENT,
SPoint  fixedPoint = null,
SVector  constraintAxis = null 
)

Set the matrix for the best fit mapping of the source points onto the target points in a least squares sense.

Note
The number of points of each list must be the same and point number i of both lists is assumed to match together.
Parameters
targetPoints(Array<SPoint>) The table of target points
sourcePoints(Array<SPoint>) The table of departure points
mode(number) The type of transformation to do
  • 0: Rigid (Translation + Rotation ; no affinity)
  • 1: Translation + Rotation + Scale (apply if necessary a scale; SAME scale along X, Y and Z)
constraintBitMask(ConstraintFlag) Transformation constraints (bit mask option)
fixedPoint(SPoint) The fixed SPoint. If not null, this point will not move during the rotation.
constraintAxis(SVector) The axis of constraint. If not null, the translation will be guided by this vector.
Return values
ret.ErrorCode(number) The error code
  • 0: OK (normal calculation).
  • 1: Transformation could not be computed. Inconsistent points, an identity matrix is initialized.

◆ InitBestRotate()

Object SMatrix::InitBestRotate ( Array< SPoint targetPoints,
Array< SPoint sourcePoints,
SPoint  fixPoint 
)

Set the matrix for the best ROTATION mapping of the source points onto the target points in a least squares sense. ONLY ROTATION.

Note
The number of points of each list must be the same and point number i of both lists is assumed to match together.
Parameters
targetPoints(Array<SPoint>) The table of target SPoint
sourcePoints(Array<SPoint>) The table of departure SPoint
fixPoint(SPoint) The point which must not move
Return values
ret.ErrorCode(number) The error code
  • 0: OK, no error.
  • 1: Transformation could not be computed. Inconsistent points, an identity matrix is initialized.

◆ InitBestTranslate()

Object SMatrix::InitBestTranslate ( Array< SPoint targetPoints,
Array< SPoint sourcePoints 
)

Set the matrix for the best TRANSLATION mapping of the source points onto the target points in a least squares sense. ONLY TRANSLATION.

Note
The number of points of each list must be the same and point number i of both lists is assumed to match together.
Parameters
targetPoints(Array<SPoint>) The table of target SPoint
sourcePoints(Array<SPoint>) The table of departure SPoint
Return values
ret.ErrorCode(number) The error code
  • 0: OK, no error.
  • 1: Transformation could not be computed. Inconsistent points, an identity matrix is initialized.

◆ InitIdentity()

SMatrix::InitIdentity ( )

Initialize the SMatrix to the unitary matrix. All the cells are initialized to zero except the diagonal which is to 1.

◆ InitInverse()

Object SMatrix::InitInverse ( SMatrix  mat)

Initialize the current matrix to the inversed matrix that is: CurrentMatrix*Mat=IdentityMatrix.

Parameters
mat(SMatrix) The SMatrix to inverse
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: The input matrix cannot be inversed in this case, current matrix is initialized to null matrix

◆ InitMirrorAxis()

SMatrix::InitMirrorAxis ( SPoint  axisP1,
SPoint  axisP2 
)

Set the matrix for a mirror axis.

Parameters
axisP1(SPoint) The first point of the axis.
axisP2(SPoint) The second point of the axis.

◆ InitMirrorPlane()

SMatrix::InitMirrorPlane ( SPoint  planePnt,
SVector  normalVect 
)

Set the matrix for a planar mirror.

Parameters
planePnt(SPoint) A SPoint on the plane
normalVect(SVector) The plane normal

◆ InitMirrorPnt()

SMatrix::InitMirrorPnt ( SPoint  mirrorCenter)

Set the matrix for a point mirror.

Parameters
mirrorCenter(SPoint) The mirror center.

◆ InitQuaternion()

SMatrix::InitQuaternion ( number  w,
number  x,
number  y,
number  z 
)

Initialize a rotation matrix from a quaternion tuple (w, x, y, z).

Note
The function normalizes the quaternion before setting the matrix.
Parameters
w(number) The w value.
x(number) The x value.
y(number) The y value.
z(number) The z value.

◆ InitRot() [1/2]

Object SMatrix::InitRot ( number  angX,
number  angY,
number  angZ,
UnitEnum  unit,
SequenceEnum  sequence,
SPoint  originPoint 
)

Set the matrix for the rotation around the 3 axis X,Y,Z.

Parameters
angX(number) Omega
angY(number) Phi
angZ(number) Kappa
unit(UnitEnum) In which unit are expressed the angles.
sequence(SequenceEnum) In which order are applied the rotations?
  • SMatrix.OrderXYZ: Applied in order X->Y->Z such that R = Rz*Ry*Rx. This is the Euler convention. In aerial photogrammetric measurements this transformation corresponds to the OPK sequence also called (Omega Phi Kappa) with Omega=Rx, Phi=Ry and Kappa=Rz.
  • SMatrix.OrderYXZ: Applied in order Y->X->Z such that R=Rz*Rx*Ry. In aerial photogrammetric measurements this transformation corresponds to the POK sequence also called (Phi Omega Kappa) with Omega=Rx, Phi=Ry and Kappa=Rz.
  • SMatrix.OrderZXY: Applied in order Z->X->Y such that R=Ry*Rx*Rz. In terrestrial photogrammetric measurements this transformation corresponds to the POK sequence also called (Phi Omega Kappa) with Omega=Rx, Kappa=Ry and Phi=Rz.
originPoint(SPoint) The translation done in space
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Inconsistent data was entered, an identity matrix is initialized.

◆ InitRot() [2/2]

Object SMatrix::InitRot ( SPoint  axisPt,
SVector  axisVect,
number  angle,
UnitEnum  unit 
)

Set the matrix for the rotation of an angle around an axis.

Parameters
axisPt(SPoint) First point of the axis
axisVect(SVector) Vector of the axis
angle(number) Angle
unit(UnitEnum) In which unit is expressed the angle.
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Inconsistent data was entered, an identity matrix is initialized.

◆ InitRPSAlignment()

Object SMatrix::InitRPSAlignment ( Array< SPoint targetPoints,
Array< SPoint sourcePoints,
Array< Array< boolean > >  xyzConstraints,
Array< SCloud associatedClouds = null,
number  neighborhood = 0 
)

Compute the RPS alignment matrix from given source and target SPoint.

Note
The size of each list: sourcePoints, targetPoints, xyzConstraints and associatedClouds (if not null) must be the same and each i-th element from each list is assumed to match together.
Call ApplyTransformation() to apply the matrix transformation on mobile components
var mat = SMatrix.New();
var sourcePts = [pt1, pt2, pt3]; // SPoint array
var targetPts = [pt4, pt5, pt6]; // SPoint array
var constraints = [[true, true, true], [true, true, false], [true, false, false]]; // [X, Y, Z] constraints triplet array
var associatedClouds = [mobilePtCloud, mobilePtCloud, mobilePtCloud]; // SCloud array
var res = mat.InitRPSAlignment(targetPts, sourcePts, constraints, associatedClouds, 0.1);
if(res.ErrorCode == 0)
mobilePtCloud.ApplyTransformation(mat);
Provide matrix with 3 lines and 4 columns to make any transformation.
Definition: Reshaper.h:2019
Object InitRPSAlignment(Array< SPoint > targetPoints, Array< SPoint > sourcePoints, Array< Array< boolean > > xyzConstraints, Array< SCloud > associatedClouds=null, number neighborhood=0)
Compute the RPS alignment matrix from given source and target SPoint.
static SMatrix New()
Default constructor.
Parameters
targetPoints(Array<SPoint>) The table of target SPoint
sourcePoints(Array<SPoint>) The table of departure SPoint
xyzConstraints(Array<Array<boolean>>) The X, Y and Z direction constraints (for RPS alignment). In order to define a strict RPS alignment, one direction (X, Y or Z) has to be constrained 3 times, another direction has to be constrained twice and the last direction has to be constrained by one pair of points only. For this reason, a strict RPS alignment can be obtained using only between 3 and 6 pairs of points.
associatedClouds(Array<SCloud>) The table of SCloud associated with the source points or null if no optimization on source points to do. The best of nearest points from sourcePoints will be used, the distance neighborhood is used to find this point in the cloud
neighborhood(number) The distance to which mobile points can be adjusted
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred

◆ InitScale()

SMatrix::InitScale ( SPoint  scaleCenter,
number  xScale,
number  yScale,
number  zScale 
)

Set the matrix for a different scale ratio along X, Y and Z with a center.

Parameters
scaleCenter(SPoint) The scale center
xScale(number) The X scale
yScale(number) The Y scale
zScale(number) The Z scale

◆ IsIdentity()

boolean SMatrix::IsIdentity ( )

Return if the matrix is the identity or not.

Returns
(boolean) True if the matrix is the identity.

◆ New() [1/5]

static SMatrix SMatrix::New ( )
static

Default constructor.

The matrix is initialized to the unitary matrix.The vector is the null vector.

Returns
(SMatrix) The new SMatrix.

◆ New() [2/5]

static SMatrix SMatrix::New ( Array< number >  row1,
Array< number >  row2,
Array< number >  row3 
)
static

Construct a SMatrix by defining its rows.

Parameters
row1(Array<number>) The 4 data of the first row
row2(Array<number>) The 4 data of the second row
row3(Array<number>) The 4 data of the third row
Returns
(SMatrix) The new SMatrix.

◆ New() [3/5]

static SMatrix SMatrix::New ( SMatrix  matrix)
static

Construct a SMatrix by copying the SMatrix other.

Parameters
matrix(SMatrix) The matrix to copy.
Returns
(SMatrix) The new SMatrix.

◆ New() [4/5]

static SMatrix SMatrix::New ( SPoint  axisPt,
SVector  axisVect,
number  angle,
UnitEnum  unit 
)
static

Constructor to set a rotation matrix of an angle around an axis. If the input data are not coherent, the matrix returned is the identity.

Parameters
axisPt(SPoint) First point of the axis.
axisVect(SVector) Vector of the axis.
angle(number) Angle around the axis.
unit(UnitEnum) In which unit is expressed angle.
Returns
(SMatrix) The new SMatrix.

◆ New() [5/5]

static SMatrix SMatrix::New ( SVector  translate)
static

Constructor from a vector. The SMatrix obtained is a pure translation.

Parameters
translate(SVector) The translation vector.
Returns
(SMatrix) The new SMatrix.

◆ QuaternionToEuler()

static Object SMatrix::QuaternionToEuler ( number  w,
number  x,
number  y,
number  z,
UnitEnum  unit 
)
static

Return the rotation angles associated to the quaternion w + xi + yj + zk. Rotation angles are given in the Euler convention (Applied in order X->Y->Z such that R = Rz*Ry*Rx).

Parameters
w(number) The coefficient w of the quaternion w + xi + yj + zk.
x(number) The coefficient x of the quaternion w + xi + yj + zk.
y(number) The coefficient y of the quaternion w + xi + yj + zk.
z(number) The coefficient z of the quaternion w + xi + yj + zk.
unit(UnitEnum) In which unit are expressed the angles.
Return values
ret.ErrorCode(number) The error code
  • 0: OK, no error.
  • 1: The matrix is not a pure rotation, impossible to find rotation and scale.
ret.RotX(number) The pitch angle (left handed rotation around X)
ret.RotY(number) The roll angle (left handed rotation around Y)
ret.RotZ(number) The yaw or heading angle (left handed rotation around Z)
ret.ScaleX(number) The matrix scale along X
ret.ScaleY(number) The matrix scale along Y
ret.ScaleZ(number) The matrix scale along Z

◆ SaveArmCoordinateSystem()

static Object SMatrix::SaveArmCoordinateSystem ( number  index,
SMatrix  newMatrix 
)
static

Save a SMatrix as a Coordinate System. If a matrix exists at the input index, it will be deleted.

Parameters
index(number) The index of the CS to update (1 to 9)
newMatrix(SMatrix) The new matrix
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred

◆ toString()

string SMatrix::toString ( )

Get the type of the variable.

Returns
(string) The type name

◆ UpdateArmCoordinateSystem()

static Object SMatrix::UpdateArmCoordinateSystem ( number  index,
SMatrix  newMatrix 
)
static

Update the matrix at the input index, by multiplying the current matrix by the input matrix.

Parameters
index(number) The index of the CS to update (1 to 9)
newMatrix(SMatrix) The new matrix
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred

◆ UpdateUCS()

number SMatrix::UpdateUCS ( string  name)

Update with the current matrix the UCS found with the given name.

Note
The matrix used for the update should not have null rows. Also, the vectors created from the rows should not be parallel.
Parameters
name(string) The name of the UCS to update
Return values
0No error.
1There are more than one UCS with the given name or this is the WCS.
2The matrix is not well defined.

◆ ValuesToString()

string SMatrix::ValuesToString ( )

Get a string representation of the matrix.

Returns
(string) A string representing the matrix content