FormIt C++ API
v23.0.0 (2023.0.0)
|
The Transf3d class represents a general affine or projective transformation in 3D space.
The transform is represented by a 4x4 matrix, the last row being the projective coefficients and are set to (0,0,0,1) for affine transformations.
To transform a point or a vector, pre-multiply it by a Transf3d matrix.
#include <Transf3d.h>
Public Types | |
enum | ProjectionType { kParallelProjection, kPerspectiveProjection } |
Public Member Functions | |
Transf3d () | |
The constructor creates an identity transform. More... | |
Transf3d (const Point3d &origin, const Vector3d &xDir, const Vector3d &yDir, const Vector3d &zDir, bool bKeepScalingFactors=false) | |
The constructor creates a transform from an origin and directions of x, y and z axes. More... | |
Transf3d (const Point3d &origin, const Vector3d &xDir, const Vector3d &yDir) | |
The constructor creates a rigid motion transform from an origin and direction of x and y axis. More... | |
Transf3d (const Line3d &axis) | |
The constructor creates a rigid motion transform from an origin (axis.point) and the direction of the z axis (axis.vector). More... | |
Transf3d (const Point3d &origin) | |
The constructor creates a rigid motion transform from an origin. More... | |
void | setValue (size_t i1, size_t i2, double newValue) |
Set the Transf3d data at the (i1, i2) position to newValue. More... | |
void | addValue (size_t i1, size_t i2, double newValue) |
Adds newValue to the Transf3d data at the (i1, i2) position. More... | |
double | operator() (size_t i1, size_t i2) const |
Returns the Transf3d data at the (i1, i2) position. More... | |
Point3d | operator* (const Point3d &) const |
Transform points, vectors and other transforms. More... | |
Vector3d | operator* (const Vector3d &) const |
UnitVector3d | operator* (const UnitVector3d &) const |
This normalizes the result of the transformation (it doesn't stretch the vector)! More... | |
Transf3d | operator* (const Transf3d &) const |
Line3d | operator* (const Line3d &l) const |
Transf3d & | operator*= (const Transf3d &) |
void | getCoordSystem (Point3d &origin, Vector3d &xDir, Vector3d &yDir, Vector3d &zDir) const |
Point3d | origin () const |
void | setOrigin (Point3d const &pt) |
Set the origin of the CoordSystem. More... | |
Vector3d | xDir () const |
Returns the x component of the affine part of the transformation. More... | |
Vector3d | yDir () const |
Returns the y component of the affine part of the transformation. More... | |
Vector3d | zDir () const |
Returns the z component of the affine part of the transformation. More... | |
bool | project (const Point3d &p, Point3d &out) const |
Project a point, using the full 4x4 matrix, including the projectiv part. More... | |
Transf3d (ProjectionType type, const Point3d &fromPt, const Point3d &toPt=Point3d(0, 0, 0), const Vector3d &upDir=Vector3d(0, 0, 0)) | |
Create a general projection transformation (this is how to create a projection transformation to be passed to the Body::hideDisplay() method). More... | |
Transf3d | affineInverseTranspose () const |
Transposes the affine part of the inverse of the transformation. More... | |
Transf3d | invert () const |
bool | isValid () const |
bool | isOrthogonal () const |
No shear. More... | |
bool | isEqualScalingOrthogonal () const |
No shear, no nonequal scaling. More... | |
bool | isRigidTransform () const |
no shear, scaling, or mirroring. More... | |
Vector3d | stretchVector () const |
bool | isMirror () const |
bool | isPerspective () const |
bool | isIdentity () const |
bool | isEqual (const Transf3d &t, double dTol=WSM_MACHINE_TOL) const |
Returns true if the transformations are equal. More... | |
bool | isRotation90DegreeMultiple () const |
Returns true if taking the bounding box of transformed points is the same as transforming the bounding box of the points. More... | |
void | SetAllFlags () const |
Sets all the flags. More... | |
const double * | data () const |
Returns a pointer to the double array containing the transform. More... | |
Static Public Member Functions | |
static Transf3d | translation (const Vector3d &) |
Create special transformations. More... | |
static Transf3d | rotation (const Line3d &axis, double angle) |
static Transf3d | scaling (const Point3d &fixedPt, double factor) |
static Transf3d | scaling (const Point3d &fixedPt, const Vector3d &xyzFactors) |
static Transf3d | stretching (const Line3d &axis) |
static Transf3d | mirroring (const Plane &) |
static Transf3d | projectOn (const Plane &projPlane, const Vector3d &projDir=Vector3d::kNull) |
static Transf3d | createOrthogonalSnappedTransform (Point3d origin, double dGlobalScale, Vector3d const &xDir, Vector3d const &yDir, Vector3d const &zDir) |
Creates an orthogonal coordinate system that preserves the axial scaling that may exist in the given vectors. More... | |
static Transf3d | align (const Point3d &src1, const Point3d &src2, const Point3d &src3, const Point3d &dst1, const Point3d &dst2, const Point3d &dst3) |
The transformation maps points as follows: More... | |
static Transf3d | align (const Point3d &src1, const Vector3d &src2, const Vector3d &src3, const Point3d &dst1, const Vector3d &dst2, const Vector3d &dst3) |
The transformation maps points and vectors as follows: More... | |
static Transf3d | align (const Point3d &src1, const Vector3d &src2, const Point3d &dst1, const Vector3d &dst2) |
Static Public Attributes | |
static const Transf3d | kFrontView |
Some ready to use projection transformations. More... | |
static const Transf3d | kBackView |
static const Transf3d | kTopView |
static const Transf3d | kBottomView |
static const Transf3d | kLeftView |
static const Transf3d | kRightView |
static const Transf3d | kIsometricView |
static const Transf3d | kDimetricView |
static const Transf3d | kIdentity |
|
inline |
The constructor creates an identity transform.
WSM::Transf3d::Transf3d | ( | const Point3d & | origin, |
const Vector3d & | xDir, | ||
const Vector3d & | yDir, | ||
const Vector3d & | zDir, | ||
bool | bKeepScalingFactors = false |
||
) |
The constructor creates a transform from an origin and directions of x, y and z axes.
Note if bKeepScalingFactors is true does not normalize x, y, and z axes before construction. Also note that orthogonality of x, y, and z is not checked.
The constructor creates a rigid motion transform from an origin and direction of x and y axis.
If yDir is not perpendicular to xDir, yDir will be adjusted.
WSM::Transf3d::Transf3d | ( | const Line3d & | axis | ) |
The constructor creates a rigid motion transform from an origin (axis.point) and the direction of the z axis (axis.vector).
The directions of the x and y axes are determined according to the AutoCAD's arbitrary axis algorithm.
WSM::Transf3d::Transf3d | ( | const Point3d & | origin | ) |
The constructor creates a rigid motion transform from an origin.
The x, y and z axis are aligned with the world x, y and z axis.
WSM::Transf3d::Transf3d | ( | ProjectionType | type, |
const Point3d & | fromPt, | ||
const Point3d & | toPt = Point3d(0, 0, 0) , |
||
const Vector3d & | upDir = Vector3d(0, 0, 0) |
||
) |
Create a general projection transformation (this is how to create a projection transformation to be passed to the Body::hideDisplay() method).
void WSM::Transf3d::addValue | ( | size_t | i1, |
size_t | i2, | ||
double | newValue | ||
) |
Adds newValue to the Transf3d data at the (i1, i2) position.
Transf3d WSM::Transf3d::affineInverseTranspose | ( | ) | const |
Transposes the affine part of the inverse of the transformation.
|
static |
The transformation maps points as follows:
Point src1 maps to point dst1 Vector (src1,src2) maps to vector (dst1,dst2) Plane (src1,src2,src3) maps to plane (dst1,dst2,dst3)
|
static |
The transformation maps points and vectors as follows:
Point src1 maps to point dst1 Vector src2 maps to vector dst2 Plane (src1,src2,src3) maps to plane (dst1,dst2,dst3)
|
static |
|
static |
Creates an orthogonal coordinate system that preserves the axial scaling that may exist in the given vectors.
The following snaps are applied in the given order for values which are close to the snap value. Origin components are snapped to 0. The global scale is snapped to 1, and then applied to the individual axis vectors. The lengths of the axes are snapped to 1. The X, Y and Z lengths are snapped together. The X and Y vectors are snapped to the principal axes and principal planes. The Z vector is then recomputed as the cross of the snapped X and Y axes, and the Y vector is recomputed as the cross of the new Z and snapped X axes.
|
inline |
Returns a pointer to the double array containing the transform.
void WSM::Transf3d::getCoordSystem | ( | Point3d & | origin, |
Vector3d & | xDir, | ||
Vector3d & | yDir, | ||
Vector3d & | zDir | ||
) | const |
Transf3d WSM::Transf3d::invert | ( | ) | const |
|
inline |
Returns true if the transformations are equal.
bool WSM::Transf3d::isEqualScalingOrthogonal | ( | ) | const |
No shear, no nonequal scaling.
bool WSM::Transf3d::isIdentity | ( | ) | const |
bool WSM::Transf3d::isMirror | ( | ) | const |
bool WSM::Transf3d::isOrthogonal | ( | ) | const |
No shear.
bool WSM::Transf3d::isPerspective | ( | ) | const |
bool WSM::Transf3d::isRigidTransform | ( | ) | const |
no shear, scaling, or mirroring.
bool WSM::Transf3d::isRotation90DegreeMultiple | ( | ) | const |
Returns true if taking the bounding box of transformed points is the same as transforming the bounding box of the points.
bool WSM::Transf3d::isValid | ( | ) | const |
|
inline |
Returns the Transf3d data at the (i1, i2) position.
Transform points, vectors and other transforms.
UnitVector3d WSM::Transf3d::operator* | ( | const UnitVector3d & | ) | const |
This normalizes the result of the transformation (it doesn't stretch the vector)!
Point3d WSM::Transf3d::origin | ( | ) | const |
Project a point, using the full 4x4 matrix, including the projectiv part.
Returns false if the point couldn't be projected by the perspective transform because it lied behind the view point.
|
static |
|
static |
void WSM::Transf3d::SetAllFlags | ( | ) | const |
Sets all the flags.
Note this is only required if you want the isXXX methods to truly be read only.
void WSM::Transf3d::setOrigin | ( | Point3d const & | pt | ) |
Set the origin of the CoordSystem.
void WSM::Transf3d::setValue | ( | size_t | i1, |
size_t | i2, | ||
double | newValue | ||
) |
Set the Transf3d data at the (i1, i2) position to newValue.
Vector3d WSM::Transf3d::stretchVector | ( | ) | const |
Create special transformations.
Vector3d WSM::Transf3d::xDir | ( | ) | const |
Returns the x component of the affine part of the transformation.
Not necessarily length 1.
Vector3d WSM::Transf3d::yDir | ( | ) | const |
Returns the y component of the affine part of the transformation.
Not necessarily length 1.
Vector3d WSM::Transf3d::zDir | ( | ) | const |
Returns the z component of the affine part of the transformation.
Not necessarily length 1.
|
static |
|
static |
|
static |
|
static |
Some ready to use projection transformations.
|
static |
|
static |
|
static |
|
static |
|
static |