Cyclone 3DR Script
from Technodigit, part of Hexagon. Copyright 1997-2024.
|
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< SMatrix > | FromUCS (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... | |
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.
The transformation constraints (bit mask option)
In which order are applied the rotations?
enum SMatrix::UnitEnum |
SMatrix::SMatrix | ( | ) |
Default constructor.
The matrix is initialized to the unitary matrix.The vector is the null vector.
SMatrix::SMatrix | ( | SMatrix | matrix | ) |
SMatrix::SMatrix | ( | SVector | translate | ) |
SMatrix::SMatrix | ( | Array< number > | row1, |
Array< number > | row2, | ||
Array< number > | row3 | ||
) |
Construct a SMatrix by defining its rows.
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 |
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.
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.
|
number SMatrix::AddToDocAsUCS | ( | string | name, |
boolean | isActivated = true |
||
) |
Add the matrix to the scene as an UCS with the given name.
name | (string) Name of the UCS |
isActivated | (boolean) True if the UCS should be activated |
0 | No error. |
1 | The matrix is not well defined. |
SMatrix::ApplyTransformation | ( | SMatrix | matrixToMul | ) |
|
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.
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 ?
|
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 ?
|
ret.ErrorCode | (number) The error code
|
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 |
|
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).
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.
|
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. |
|
static |
|
static |
|
static |
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.
unit | (UnitEnum) In which unit will be expressed the angles.
|
ret.ErrorCode | (number) The error code
|
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 |
Object SMatrix::GetQuaternion | ( | ) |
Interpret values from a SMatrix and find the quaternion w + xi + yj + zk and the translation vector.
ret.ErrorCode | (number) The error code
|
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 |
number SMatrix::GetValue | ( | number | row, |
number | column | ||
) |
Get the value of the SMatrix at the position(row, column).
row | (number) The index of the row 0 <= row < 3 |
column | (number) The index of the column 0 <= column < 4 |
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.
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 |
ret.ErrorCode | (number) The error code
|
Calculate the transformation matrix from 2 matching point couples.
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 |
ret.ErrorCode | (number) The error code
|
Compute the matrix to roughly align a component on another.
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 |
ret.ErrorCode | (number) The error code
|
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.
targetPoints | (Array<SPoint>) The table of target points |
sourcePoints | (Array<SPoint>) The table of departure points |
mode | (number) The type of transformation to do
|
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. |
ret.ErrorCode | (number) The error code
|
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.
targetPoints | (Array<SPoint>) The table of target SPoint |
sourcePoints | (Array<SPoint>) The table of departure SPoint |
fixPoint | (SPoint) The point which must not move |
ret.ErrorCode | (number) The error code
|
Set the matrix for the best TRANSLATION mapping of the source points onto the target points in a least squares sense. ONLY TRANSLATION.
targetPoints | (Array<SPoint>) The table of target SPoint |
sourcePoints | (Array<SPoint>) The table of departure SPoint |
ret.ErrorCode | (number) The error code
|
SMatrix::InitIdentity | ( | ) |
Initialize the SMatrix to the unitary matrix. All the cells are initialized to zero except the diagonal which is to 1.
Object SMatrix::InitInverse | ( | SMatrix | mat | ) |
Initialize the current matrix to the inversed matrix that is: CurrentMatrix*Mat=IdentityMatrix.
ret.ErrorCode | (number) The error code
|
SMatrix::InitMirrorPnt | ( | SPoint | mirrorCenter | ) |
Set the matrix for a point mirror.
mirrorCenter | (SPoint) The mirror center. |
SMatrix::InitQuaternion | ( | number | w, |
number | x, | ||
number | y, | ||
number | z | ||
) |
Initialize a rotation matrix from a quaternion tuple (w, x, y, z).
w | (number) The w value. |
x | (number) The x value. |
y | (number) The y value. |
z | (number) The z value. |
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.
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?
|
originPoint | (SPoint) The translation done in space |
ret.ErrorCode | (number) The error code
|
Set the matrix for the rotation of an angle around an axis.
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.
|
ret.ErrorCode | (number) The error code
|
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.
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 |
ret.ErrorCode | (number) The error code
|
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.
scaleCenter | (SPoint) The scale center |
xScale | (number) The X scale |
yScale | (number) The Y scale |
zScale | (number) The Z scale |
boolean SMatrix::IsIdentity | ( | ) |
Return if the matrix is the identity or not.
|
static |
|
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.
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.
|
|
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).
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.
|
ret.ErrorCode | (number) The error code
|
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 |
|
static |
string SMatrix::toString | ( | ) |
Get the type of the variable.
|
static |
Update the matrix at the input index, by multiplying the current matrix by the input matrix.
index | (number) The index of the CS to update (1 to 9) |
newMatrix | (SMatrix) The new matrix |
ret.ErrorCode | (number) The error code
|
number SMatrix::UpdateUCS | ( | string | name | ) |
Update with the current matrix the UCS found with the given name.
name | (string) The name of the UCS to update |
0 | No error. |
1 | There are more than one UCS with the given name or this is the WCS. |
2 | The matrix is not well defined. |
string SMatrix::ValuesToString | ( | ) |
Get a string representation of the matrix.