libatomprobe
Library for Atom Probe Tomography (APT) computation
Public Member Functions | Static Public Member Functions | Friends | List of all members
AtomProbe::Point3D Class Reference

A 3D point data class storage. More...

#include <point3D.h>

Public Member Functions

 Point3D ()
 Constructor with no initialisation. More...
 
 Point3D (const float *f)
 Constructor initialising values from an array of length 4*(sizeof(float)) More...
 
 Point3D (float x, float y, float z)
 Constructor with initialising values, X, Y and Z. More...
 
void setValue (unsigned int ui, float val)
 Set value val of the ui-th dimension, ui in (0,1,2) More...
 
void setValue (float fX, float fY, float fZ)
 Set the XYZ value fo the point. More...
 
bool parse (const std::string &s)
 Set from string representation. More...
 
void setValueArr (const float *val)
 Set value by pointer (X, Y, Z from array of len 3) More...
 
float getValue (unsigned int ui) const
 Get value of ith dimension (0, 1, 2) More...
 
const float * getValueArr () const
 Obtain a pointer to internal array (3 floats) More...
 
void copyValueArr (float *value) const
 Copy data from internal into target array of length 3 : Pointer MUST be allocated. More...
 
void add (const Point3D &obj)
 Add a point to this, without generating a return value. More...
 
void extend (float distance)
 Extend the vector by the specified distance. More...
 
bool hasNaN () const
 Returns true if any of the 3 data pts are NaN. More...
 
bool operator== (const Point3D &pt) const
 Equality operator. More...
 
const Point3Doperator= (const Point3D &pt)
 Assignment operator. More...
 
const Point3Doperator+= (const Point3D &pt)
 += operator More...
 
const Point3Doperator-= (const Point3D &pt)
 -= operator More...
 
Point3D operator*= (const float scale)
 *= operator, multiplies the whole Point3D by a scalar More...
 
const Point3D operator+ (const Point3D &pt) const
 Addition of Point3D objects (X1+X2, Y1+Y2, Z1+Z2) More...
 
const Point3D operator+ (float f) const
 Addition of a scalar to a Point3D object (X+f, Y+f, Z+f) More...
 
const Point3D operator* (float scale) const
 Scalar multiplication (X*f, Y*f, Z*f) More...
 
const Point3D operator* (const Point3D &pt) const
 Elemental multiplication of two Point3D objects (X1*X2, Y1*Y2, Z1*Z2) More...
 
const Point3D operator/ (float scale) const
 Scalar division of Point3D by scale (X/scale, Y/scale, Z/scale) More...
 
const Point3D operator/ (const Point3D &pt) const
 Elemental division of two Point3D objects (X1/X2, Y1/Y2, Z1/Z2) More...
 
const Point3D operator- (const Point3D &pt) const
 Subtraction of two Point3D objects (X1-X2, Y1-Y2, Z1-Z2) More...
 
const Point3D operator- () const
 Negation, Returns a Point3D object with the negative of the previous value. More...
 
void normalise ()
 Make point unit magnitude, maintaining direction. More...
 
Point3D normal () const
 Return point unit magnitude, maintianing direction. More...
 
float sqrDist (const Point3D &pt) const
 Returns the square of distance to another Point3D. More...
 
float dotProd (const Point3D &pt) const
 Calculate the dot product of this and another point. More...
 
Point3D crossProd (const Point3D &pt) const
 Calculate the cross product of this and another point. More...
 
float angle (const Point3D &pt) const
 Calculate the angle between two position vectors in radians. More...
 
float sqrMag () const
 Returns magnitude^2, taking this as a position vector. More...
 
float mag () const
 Magnitude of position vector. More...
 
float operator[] (unsigned int ui) const
 Array indexing operator, Point3D[1] returns the value of the ui-th dim. More...
 
float & operator[] (unsigned int ui)
 Array reference operator, Point3D[1]. More...
 
bool insideBox (const Point3D &farPoint) const
 Is this point inside a box bounded by orign and farPoint? More...
 
bool insideBox (const Point3D &lowPt, const Point3D &hiPt) const
 Is this point inside a box bounded by lowPt and hiPt? More...
 
void negate ()
 Makes each value negative of old value (-X, -Y, -Z) More...
 
void reciprocal ()
 Makes each value its reciprocal (1/X, 1/Y, 1/Z) More...
 
void transform3x3 (const gsl_matrix *matrix)
 Perform a 3x3 matrix transformation using a GSL matrix. More...
 
bool orthogonalise (const Point3D &p)
 Perform a cross-product based orthogonalisation with the specified vector. More...
 
void setISOSpherical (float radius, float theta, float phi)
 Assign the vector using spherical coordinates. More...
 
void getISOSpherical (float &radius, float &theta, float &phi) const
 Get the Point3D value as spherical coordinates (ISO 30-11) More...
 

Static Public Member Functions

static void getCentroid (const std::vector< Point3D > &pts, Point3D &p)
 find the centroid of a set of points More...
 

Friends

std::ostream & operator<< (std::ostream &stream, const Point3D &)
 Output streaming operator. Streams values in the text format (x,y,z) More...
 

Detailed Description

A 3D point data class storage.

Definition at line 39 of file point3D.h.

Constructor & Destructor Documentation

◆ Point3D() [1/3]

AtomProbe::Point3D::Point3D ( )
inline

Constructor with no initialisation.

Definition at line 46 of file point3D.h.

Referenced by getCentroid(), and transform3x3().

◆ Point3D() [2/3]

AtomProbe::Point3D::Point3D ( const float *  f)
inline

Constructor initialising values from an array of length 4*(sizeof(float))

Definition at line 49 of file point3D.h.

References setValueArr().

Here is the call graph for this function:

◆ Point3D() [3/3]

AtomProbe::Point3D::Point3D ( float  x,
float  y,
float  z 
)
inline

Constructor with initialising values, X, Y and Z.

Definition at line 52 of file point3D.h.

Member Function Documentation

◆ add()

void AtomProbe::Point3D::add ( const Point3D obj)

Add a point to this, without generating a return value.

Add a Point3D set of values to this Point3D.

This is different to +=, because it generates no return value.

Definition at line 325 of file point3D.cpp.

Referenced by getValueArr().

◆ angle()

float AtomProbe::Point3D::angle ( const Point3D pt) const

Calculate the angle between two position vectors in radians.

Definition at line 388 of file point3D.cpp.

References dotProd(), and sqrMag().

Referenced by AtomProbe::Mesh::divideMeshSurface(), and hasNaN().

Here is the call graph for this function:

◆ copyValueArr()

void AtomProbe::Point3D::copyValueArr ( float *  value) const

Copy data from internal into target array of length 3 : Pointer MUST be allocated.

As a quick example, you can copy into a buffer you own Point3D p(1,2,3); float x[3]; p.copyValueArr(x[0]);

Definition at line 139 of file point3D.cpp.

References ASSERT.

Referenced by getValueArr().

◆ crossProd()

Point3D AtomProbe::Point3D::crossProd ( const Point3D pt) const

◆ dotProd()

float AtomProbe::Point3D::dotProd ( const Point3D pt) const

Calculate the dot product of this and another point.

(X1*X2 + Y1*Y2 ...)

Definition at line 279 of file point3D.cpp.

Referenced by angle(), AtomProbe::generate1DAxialDistHistSweep(), AtomProbe::Mesh::getVolume(), hasNaN(), AtomProbe::intersect_RayTriangle(), main(), and AtomProbe::signedDistanceToFacet().

◆ extend()

void AtomProbe::Point3D::extend ( float  distance)

Extend the vector by the specified distance.

Assumes Point3D is a vector from the origin, and adds on a vector parallel to Point3D of length distance.

Definition at line 298 of file point3D.cpp.

References ASSERT, normalise(), and sqrMag().

Referenced by getValueArr().

Here is the call graph for this function:

◆ getCentroid()

void AtomProbe::Point3D::getCentroid ( const std::vector< Point3D > &  pts,
Point3D p 
)
static

find the centroid of a set of points

Definition at line 393 of file point3D.cpp.

References Point3D().

Referenced by mag().

Here is the call graph for this function:

◆ getISOSpherical()

void AtomProbe::Point3D::getISOSpherical ( float &  radius,
float &  theta,
float &  phi 
) const

Get the Point3D value as spherical coordinates (ISO 30-11)

Internal cartesian representation converted to ISO 30-11 and returned in the pointers provided as input.

theta - inclination (angle from +z). phi - azimuth (angle from +x), r - radius

Definition at line 433 of file point3D.cpp.

References sqrMag().

Referenced by mag().

Here is the call graph for this function:

◆ getValue()

float AtomProbe::Point3D::getValue ( unsigned int  ui) const
inline

◆ getValueArr()

const float* AtomProbe::Point3D::getValueArr ( ) const
inline

Obtain a pointer to internal array (3 floats)

Definition at line 101 of file point3D.h.

References add(), copyValueArr(), and extend().

Referenced by AtomProbe::BoundCube::intersects().

Here is the call graph for this function:

◆ hasNaN()

bool AtomProbe::Point3D::hasNaN ( ) const
inline

Returns true if any of the 3 data pts are NaN.

Definition at line 128 of file point3D.h.

References angle(), crossProd(), dotProd(), normal(), normalise(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator<<, operator=(), operator==(), sqrDist(), and sqrMag().

Here is the call graph for this function:

◆ insideBox() [1/2]

bool AtomProbe::Point3D::insideBox ( const Point3D farPoint) const

Is this point inside a box bounded by orign and farPoint?

Returns true if this point is located inside (0,0,0) -> farPoint

Assuming box shape (non zero edges return false)

farPoint must be positive in all dim

Definition at line 308 of file point3D.cpp.

Referenced by mag().

◆ insideBox() [2/2]

bool AtomProbe::Point3D::insideBox ( const Point3D lowPt,
const Point3D hiPt 
) const

Is this point inside a box bounded by lowPt and hiPt?

Returns true if this point is located inside lowPt -> hiPt

Assuming box shape.

Definition at line 316 of file point3D.cpp.

◆ mag()

float AtomProbe::Point3D::mag ( ) const
inline

Magnitude of position vector.

Definition at line 197 of file point3D.h.

References getCentroid(), getISOSpherical(), insideBox(), negate(), operator[](), orthogonalise(), reciprocal(), setISOSpherical(), sqrMag(), and transform3x3().

Referenced by normal(), normalise(), AtomProbe::signedDistanceToFacet(), transform3x3(), and AtomProbe::triIsDegenerate().

Here is the call graph for this function:

◆ negate()

void AtomProbe::Point3D::negate ( )

Makes each value negative of old value (-X, -Y, -Z)

Definition at line 358 of file point3D.cpp.

Referenced by mag().

◆ normal()

Point3D AtomProbe::Point3D::normal ( ) const

Return point unit magnitude, maintianing direction.

Definition at line 347 of file point3D.cpp.

References mag(), and sqrMag().

Referenced by hasNaN(), and orthogonalise().

Here is the call graph for this function:

◆ normalise()

void AtomProbe::Point3D::normalise ( )

◆ operator*() [1/2]

const Point3D AtomProbe::Point3D::operator* ( float  scale) const

Scalar multiplication (X*f, Y*f, Z*f)

Definition at line 226 of file point3D.cpp.

Referenced by hasNaN().

◆ operator*() [2/2]

const Point3D AtomProbe::Point3D::operator* ( const Point3D pt) const

Elemental multiplication of two Point3D objects (X1*X2, Y1*Y2, Z1*Z2)

Definition at line 237 of file point3D.cpp.

◆ operator*=()

Point3D AtomProbe::Point3D::operator*= ( const float  scale)

*= operator, multiplies the whole Point3D by a scalar

Definition at line 217 of file point3D.cpp.

Referenced by hasNaN().

◆ operator+() [1/2]

const Point3D AtomProbe::Point3D::operator+ ( const Point3D pt) const

Addition of Point3D objects (X1+X2, Y1+Y2, Z1+Z2)

Definition at line 178 of file point3D.cpp.

Referenced by hasNaN().

◆ operator+() [2/2]

const Point3D AtomProbe::Point3D::operator+ ( float  f) const

Addition of a scalar to a Point3D object (X+f, Y+f, Z+f)

Definition at line 188 of file point3D.cpp.

◆ operator+=()

const Point3D & AtomProbe::Point3D::operator+= ( const Point3D pt)

+= operator

Definition at line 170 of file point3D.cpp.

Referenced by hasNaN().

◆ operator-() [1/2]

const Point3D AtomProbe::Point3D::operator- ( const Point3D pt) const

Subtraction of two Point3D objects (X1-X2, Y1-Y2, Z1-Z2)

Definition at line 197 of file point3D.cpp.

◆ operator-() [2/2]

const Point3D AtomProbe::Point3D::operator- ( ) const

Negation, Returns a Point3D object with the negative of the previous value.

Definition at line 207 of file point3D.cpp.

Referenced by hasNaN().

◆ operator-=()

const Point3D & AtomProbe::Point3D::operator-= ( const Point3D pt)

-= operator

Definition at line 149 of file point3D.cpp.

Referenced by hasNaN().

◆ operator/() [1/2]

const Point3D AtomProbe::Point3D::operator/ ( float  scale) const

Scalar division of Point3D by scale (X/scale, Y/scale, Z/scale)

Definition at line 248 of file point3D.cpp.

Referenced by hasNaN().

◆ operator/() [2/2]

const Point3D AtomProbe::Point3D::operator/ ( const Point3D pt) const

Elemental division of two Point3D objects (X1/X2, Y1/Y2, Z1/Z2)

Definition at line 260 of file point3D.cpp.

◆ operator=()

const Point3D & AtomProbe::Point3D::operator= ( const Point3D pt)

Assignment operator.

Definition at line 162 of file point3D.cpp.

Referenced by hasNaN().

◆ operator==()

bool AtomProbe::Point3D::operator== ( const Point3D pt) const

Equality operator.

Definition at line 157 of file point3D.cpp.

Referenced by hasNaN().

◆ operator[]() [1/2]

float AtomProbe::Point3D::operator[] ( unsigned int  ui) const

Array indexing operator, Point3D[1] returns the value of the ui-th dim.

Definition at line 127 of file point3D.cpp.

References ASSERT.

Referenced by mag().

◆ operator[]() [2/2]

float & AtomProbe::Point3D::operator[] ( unsigned int  ui)

Array reference operator, Point3D[1].

returns reference to data in ui-th dim

Definition at line 133 of file point3D.cpp.

References ASSERT.

◆ orthogonalise()

bool AtomProbe::Point3D::orthogonalise ( const Point3D p)

Perform a cross-product based orthogonalisation with the specified vector.

Definition at line 372 of file point3D.cpp.

References crossProd(), normal(), normalise(), and sqrMag().

Referenced by mag().

Here is the call graph for this function:

◆ parse()

bool AtomProbe::Point3D::parse ( const std::string &  s)

Set from string representation.

From a string representation of a 3D point, parse and store the data in a Point3D.

Must contain 3 entries.

Values can be separated by whitespace or any of ,;|_

Polar notation is indicated by < ... >

Polar notation assumes <radius,theta,phi> in degrees (they will be converted to radians internally) and then converted into cartesian coordinates (X,Y,Z)

Point3D mypoint;
mypoint.parse("<1,45,90>");
cout << mypoint << endl;

Returns:

(-3.09086e-08,0.707107,0.707107)

Definition at line 39 of file point3D.cpp.

References M_PI, setISOSpherical(), setValueArr(), AtomProbe::splitStrsRef(), AtomProbe::stream_cast(), and AtomProbe::stripWhite().

Referenced by main(), setValue(), and transform3x3().

Here is the call graph for this function:

◆ reciprocal()

void AtomProbe::Point3D::reciprocal ( )

Makes each value its reciprocal (1/X, 1/Y, 1/Z)

Definition at line 365 of file point3D.cpp.

Referenced by mag().

◆ setISOSpherical()

void AtomProbe::Point3D::setISOSpherical ( float  radius,
float  theta,
float  phi 
)

Assign the vector using spherical coordinates.

theta - inclination (angle from +z). phi - azimuth (angle from +x), r - radius

The value of the point is stored in cartesian coords.

Definition at line 425 of file point3D.cpp.

Referenced by AtomProbe::generate1DAxialDistHistSweep(), mag(), parse(), and AtomProbe::GnomonicProjection::toPlanar().

◆ setValue() [1/2]

void AtomProbe::Point3D::setValue ( unsigned int  ui,
float  val 
)
inline

Set value val of the ui-th dimension, ui in (0,1,2)

Definition at line 57 of file point3D.h.

Referenced by AtomProbe::BoundCube::getBounds(), AtomProbe::BoundCube::intersects(), AtomProbe::BoundCube::max(), and AtomProbe::BoundCube::min().

◆ setValue() [2/2]

void AtomProbe::Point3D::setValue ( float  fX,
float  fY,
float  fZ 
)
inline

Set the XYZ value fo the point.

Definition at line 60 of file point3D.h.

References parse().

Here is the call graph for this function:

◆ setValueArr()

void AtomProbe::Point3D::setValueArr ( const float *  val)
inline

Set value by pointer (X, Y, Z from array of len 3)

Definition at line 90 of file point3D.h.

Referenced by parse(), Point3D(), and AtomProbe::IonHit::setHit().

◆ sqrDist()

float AtomProbe::Point3D::sqrDist ( const Point3D pt) const

◆ sqrMag()

float AtomProbe::Point3D::sqrMag ( ) const

◆ transform3x3()

void AtomProbe::Point3D::transform3x3 ( const gsl_matrix *  matrix)

Perform a 3x3 matrix transformation using a GSL matrix.

Definition at line 445 of file point3D.cpp.

References floatSwapBytes(), mag(), parse(), Point3D(), sqrMag(), and TEST.

Referenced by AtomProbe::getRotationMatrix(), and mag().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const Point3D pt 
)
friend

Output streaming operator. Streams values in the text format (x,y,z)

Definition at line 417 of file point3D.cpp.

Referenced by hasNaN().


The documentation for this class was generated from the following files: