CustusX  2020.10.01-dev+develop.ab728
An IGT application

The CustusX Math library, based on Eigen. More...

Classes

class  cx::IntBoundingBox3D
 Representation of an integer bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk. More...
 
class  cx::DoubleBoundingBox3D
 Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk. More...
 
class  cx::DecomposedTransform3D
 Helper class for visualizing rotational angles to a human user. More...
 
class  cx::Frame3D
 Defines an axis-angle representation of a position+orientation in 3D space. More...
 

Macros

#define EIGEN_DEFAULT_IO_FORMAT   Eigen::IOFormat(6, 0, " ", " ", "","","","")
 
#define EIGEN_PLAINOBJECTBASE_PLUGIN   "cxPlainObjectEigenAddons.h"
 
#define EIGEN_MATRIXBASE_PLUGIN   "cxMatrixBaseEigenAddons.h"
 
#define EIGEN_TRANSFORM_PLUGIN   "cxTransformEigenAddons.h"
 

Typedefs

typedef Transform3D cx::Transform3D
 Transform3D is a representation of an affine 3D transform. More...
 
typedef boost::shared_ptr< Transform3D > cx::Transform3DPtr
 
typedef Eigen::Vector3d cx::Vector3D
 Vector3D is a representation of a point or vector in 3D. More...
 
typedef boost::shared_ptr< Vector3D > cx::Vector3DPtr
 

Functions

std::ostream & cx::operator<< (std::ostream &s, const IntBoundingBox3D &data)
 
bool cx::similar (const DoubleBoundingBox3D &a, const DoubleBoundingBox3D &b, double tol)
 
std::ostream & cx::operator<< (std::ostream &s, const DoubleBoundingBox3D &data)
 
DoubleBoundingBox3D cx::intersection (DoubleBoundingBox3D a, DoubleBoundingBox3D b)
 
std::ostream & cx::operator<< (std::ostream &s, const Frame3D &t)
 
bool cx::similar (const Transform3D &a, const Transform3D &b, double tol)
 
DoubleBoundingBox3D cx::transform (const Transform3D &m, const DoubleBoundingBox3D &bb)
 
Transform3D cx::createTransformNormalize (const DoubleBoundingBox3D &in, const DoubleBoundingBox3D &out)
 
Transform3D cx::createTransformScale (const Vector3D &scale_)
 
Transform3D cx::createTransformTranslate (const Vector3D &translation)
 
Transform3D cx::createTransformRotateX (const double angle)
 
Transform3D cx::createTransformRotateY (const double angle)
 
Transform3D cx::createTransformRotateZ (const double angle)
 
Transform3D cx::createTransformIJC (const Vector3D &ivec, const Vector3D &jvec, const Vector3D &center)
 
Transform3D cx::createTransformRotationBetweenVectors (Vector3D from, Vector3D to)
 
cxResource_EXPORT Transform3D cx::createTransformLPS2RAS ()
 
cxResource_EXPORT Transform3D cx::createTransformFromReferenceToExternal (PATIENT_COORDINATE_SYSTEM external)
 
std::string cx::matrixAsSingleLineString (cx::Transform3D transform)
 
bool cx::similar (double a, double b, double tol=1.0E-6)
 check for equality with a tolerance: |b-a|<tol More...
 
Vector3D cx::multiply_elems (const Vector3D &a, const Vector3D &b)
 perform element-wise multiplication of a and b. More...
 
Vector3D cx::divide_elems (const Vector3D &a, const Vector3D &b)
 perform element-wise division of a and b. More...
 
Vector3D cx::cross (const Vector3D &a, const Vector3D &b)
 compute cross product of a and b. More...
 
double cx::dot (const Vector3D &a, const Vector3D &b)
 compute inner product (or dot product) of a and b. More...
 
bool cx::similar (const Vector3D &a, const Vector3D &b, double tol=1.0E-6)
 check for equality with a tolerance: |b-a|<tol More...
 
Vector3D cx::unitVector (double thetaXY, double thetaZ=0.0)
 compute a unit vector given angles xy in the xy plane and z meaning the elevation from the xy plane. More...
 
double cx::getThetaXY (Vector3D v)
 get thetaXY, meaning the angle of v projected onto the xy plane More...
 
double cx::getThetaZ (Vector3D v)
 get thetaZ, z meaning the elevation from the xy plane More...
 
Vector3D cx::round (const Vector3D &a)
 
Vector3D cx::ceil (const Vector3D &a)
 
bool cx::similar (const Eigen::Array3i &a, const Eigen::Array3i &b)
 identical to the equality operator, exists for symmetry with Vector3D. More...
 
QString cx::prettyFormat (Vector3D val, int decimals, int fieldWidth)
 
Eigen::Vector2d cx::fromString (const QString &text)
 

Detailed Description

The CustusX Math library, based on Eigen.

The math in CustusX should preferrably be done in terms of Eigen, http://eigen.tuxfamily.org/dox/

The core classes Vector3D and Transform3D have been reduced to typedefs of Eigen structures.

Macro Definition Documentation

#define EIGEN_DEFAULT_IO_FORMAT   Eigen::IOFormat(6, 0, " ", " ", "","","","")

Definition at line 58 of file cxMathBase.h.

#define EIGEN_MATRIXBASE_PLUGIN   "cxMatrixBaseEigenAddons.h"

Definition at line 61 of file cxMathBase.h.

#define EIGEN_PLAINOBJECTBASE_PLUGIN   "cxPlainObjectEigenAddons.h"

Definition at line 60 of file cxMathBase.h.

#define EIGEN_TRANSFORM_PLUGIN   "cxTransformEigenAddons.h"

Definition at line 62 of file cxMathBase.h.

Typedef Documentation

typedef Eigen::Affine3d cx::Transform3D

Transform3D is a representation of an affine 3D transform.

Transform3D is implemented using the Eigen library type Eigen::Affine3d, and extended with convenience methods using the Eigen plugin system.

Some of the extension exist for backward compatibility with the old inhouse Transform3D.

Definition at line 33 of file cxLandmarkPatientRegistrationWidget.h.

typedef boost::shared_ptr<Transform3D> cx::Transform3DPtr

Definition at line 225 of file cxTransform3D.h.

typedef Eigen::Vector3d cx::Vector3D

Vector3D is a representation of a point or vector in 3D.

Vector3D is implemented using the Eigen library type Eigen::Vector3d, and extended with convenience methods using the Eigen plugin system.

Some of the extension exist for backward compatibility with the old inhouse Vector3D.

Definition at line 42 of file cxVector3D.h.

typedef boost::shared_ptr<Vector3D> cx::Vector3DPtr

Definition at line 43 of file cxVector3D.h.

Function Documentation

cxResource_EXPORT Vector3D cx::ceil ( const Vector3D a)

Definition at line 84 of file cxVector3D.cpp.

cxResource_EXPORT Transform3D cx::createTransformFromReferenceToExternal ( PATIENT_COORDINATE_SYSTEM  external)

Create a transform from the internal (LPS) space to a given external (LPS or RAS) space. The return value is on the form sMr, where s=external space, r=internal ref space.

Definition at line 271 of file cxTransform3D.cpp.

cxResource_EXPORT Transform3D cx::createTransformIJC ( const Vector3D ivec,
const Vector3D jvec,
const Vector3D center 
)

Create a transform to a space defined by an origin and two perpendicular unit vectors that for the x-y plane. The original space is A and the space defined by ijc are B The returned transform M_AB converts a point in B to A: p_A = M_AB * p_B

Definition at line 255 of file cxTransform3D.cpp.

cxResource_EXPORT Transform3D cx::createTransformLPS2RAS ( )

Convert from left-posterior-superior (LPS) or right-anterior-superior (RAS). LPS is used by DICOM and CustusX, RAS is used by Slicer, ITK-Snap, NifTI,

Definition at line 266 of file cxTransform3D.cpp.

cxResource_EXPORT Transform3D cx::createTransformNormalize ( const DoubleBoundingBox3D in,
const DoubleBoundingBox3D out 
)

Normalize volume defined by in to volume defined by out.

This is intended for creating transforms from one viewport to another, i.e. the two boxes should be aligned and differ only in translation + scaling.

Definition at line 233 of file cxTransform3D.cpp.

cxResource_EXPORT Transform3D cx::createTransformRotateX ( const double  angle)

Create a transform representing a rotation about the X-axis with an input angle.

Definition at line 171 of file cxTransform3D.cpp.

cxResource_EXPORT Transform3D cx::createTransformRotateY ( const double  angle)

Create a transform representing a rotation about the Y-axis with an input angle.

Definition at line 178 of file cxTransform3D.cpp.

cxResource_EXPORT Transform3D cx::createTransformRotateZ ( const double  angle)

Create a transform representing a rotation about the Z-axis with an input angle.

Definition at line 185 of file cxTransform3D.cpp.

cxResource_EXPORT Transform3D cx::createTransformRotationBetweenVectors ( Vector3D  from,
Vector3D  to 
)

Definition at line 192 of file cxTransform3D.cpp.

cxResource_EXPORT Transform3D cx::createTransformScale ( const Vector3D scale)

Create a transform representing a scale in x,y,z

Definition at line 157 of file cxTransform3D.cpp.

cxResource_EXPORT Transform3D cx::createTransformTranslate ( const Vector3D translation)

Create a transform representing a translation

Definition at line 164 of file cxTransform3D.cpp.

cxResource_EXPORT Vector3D cx::cross ( const Vector3D a,
const Vector3D b 
)

compute cross product of a and b.

Definition at line 41 of file cxVector3D.cpp.

cxResource_EXPORT Vector3D cx::divide_elems ( const Vector3D a,
const Vector3D b 
)

perform element-wise division of a and b.

Definition at line 36 of file cxVector3D.cpp.

cxResource_EXPORT double cx::dot ( const Vector3D a,
const Vector3D b 
)

compute inner product (or dot product) of a and b.

Definition at line 46 of file cxVector3D.cpp.

cxResource_EXPORT Eigen::Vector2d cx::fromString ( const QString &  text)

Definition at line 106 of file cxVector3D.cpp.

cxResource_EXPORT double cx::getThetaXY ( Vector3D  k)

get thetaXY, meaning the angle of v projected onto the xy plane

Definition at line 65 of file cxVector3D.cpp.

cxResource_EXPORT double cx::getThetaZ ( Vector3D  k)

get thetaZ, z meaning the elevation from the xy plane

Definition at line 70 of file cxVector3D.cpp.

cxResource_EXPORT DoubleBoundingBox3D cx::intersection ( DoubleBoundingBox3D  a,
DoubleBoundingBox3D  b 
)

Create the bounding box that is contained in both a and b. No intersection gives a zero box.

Definition at line 288 of file cxBoundingBox3D.cpp.

cxResource_EXPORT std::string cx::matrixAsSingleLineString ( Transform3D  transform)

Utility function used to convert Transform3D to a single line string.

Functions like getDisplayFriendlyInfo() in MeshHelpers and VolumeHelpers don't display the whole matrix if it contain newlines.

Definition at line 279 of file cxTransform3D.cpp.

cxResource_EXPORT Vector3D cx::multiply_elems ( const Vector3D a,
const Vector3D b 
)

perform element-wise multiplication of a and b.

Definition at line 31 of file cxVector3D.cpp.

cxResource_EXPORT std::ostream & cx::operator<< ( std::ostream &  s,
const IntBoundingBox3D data 
)

Definition at line 125 of file cxBoundingBox3D.cpp.

cxResource_EXPORT std::ostream & cx::operator<< ( std::ostream &  s,
const Frame3D t 
)

Definition at line 156 of file cxFrame3D.cpp.

cxResource_EXPORT std::ostream & cx::operator<< ( std::ostream &  s,
const DoubleBoundingBox3D data 
)

Definition at line 233 of file cxBoundingBox3D.cpp.

cxResource_EXPORT QString cx::prettyFormat ( Vector3D  val,
int  decimals,
int  fieldWidth 
)

Definition at line 98 of file cxVector3D.cpp.

cxResource_EXPORT Vector3D cx::round ( const Vector3D a)

Definition at line 75 of file cxVector3D.cpp.

cxResource_EXPORT bool cx::similar ( double  a,
double  b,
double  tol 
)

check for equality with a tolerance: |b-a|<tol

Definition at line 26 of file cxVector3D.cpp.

cxResource_EXPORT bool cx::similar ( const Vector3D a,
const Vector3D b,
double  tol 
)

check for equality with a tolerance: |b-a|<tol

Definition at line 51 of file cxVector3D.cpp.

cxResource_EXPORT bool cx::similar ( const Eigen::Array3i &  a,
const Eigen::Array3i &  b 
)

identical to the equality operator, exists for symmetry with Vector3D.

Definition at line 93 of file cxVector3D.cpp.

cxResource_EXPORT bool cx::similar ( const Transform3D a,
const Transform3D b,
double  tol 
)

Definition at line 135 of file cxTransform3D.cpp.

cxResource_EXPORT bool cx::similar ( const DoubleBoundingBox3D a,
const DoubleBoundingBox3D b,
double  tol 
)

Definition at line 228 of file cxBoundingBox3D.cpp.

cxResource_EXPORT DoubleBoundingBox3D cx::transform ( const Transform3D m,
const DoubleBoundingBox3D bb 
)

Transform bb using the transform m. Only the two defining corners are actually transformed.

Definition at line 150 of file cxTransform3D.cpp.

cxResource_EXPORT Vector3D cx::unitVector ( double  thetaXY,
double  thetaZ 
)

compute a unit vector given angles xy in the xy plane and z meaning the elevation from the xy plane.

Definition at line 56 of file cxVector3D.cpp.