libatomprobe
Library for Atom Probe Tomography (APT) computation
|
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 Point3D & | operator= (const Point3D &pt) |
Assignment operator. More... | |
const Point3D & | operator+= (const Point3D &pt) |
+= operator More... | |
const Point3D & | operator-= (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... | |
|
inline |
Constructor with no initialisation.
Definition at line 46 of file point3D.h.
Referenced by getCentroid(), and transform3x3().
|
inline |
Constructor initialising values from an array of length 4*(sizeof(float))
Definition at line 49 of file point3D.h.
References setValueArr().
|
inline |
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().
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().
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().
Calculate the cross product of this and another point.
Definition at line 285 of file point3D.cpp.
Referenced by AtomProbe::TriangleWithVertexNorm::computeACWNormal(), AtomProbe::TriangleWithVertexNorm::computeArea(), AtomProbe::computeRotationMatrix(), AtomProbe::distanceToSegment(), AtomProbe::Mesh::getTriNormal(), AtomProbe::Mesh::getVolume(), hasNaN(), AtomProbe::intersect_RayTriangle(), main(), orthogonalise(), and AtomProbe::TriangleWithVertexNorm::safeComputeACWNormal().
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().
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().
find the centroid of a set of points
Definition at line 393 of file point3D.cpp.
References Point3D().
Referenced by mag().
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().
|
inline |
Get value of ith dimension (0, 1, 2)
Definition at line 98 of file point3D.h.
Referenced by AtomProbe::SimpleCubicGen::generateLattice(), AtomProbe::FaceCentredCubicGen::generateLattice(), AtomProbe::BodyCentredCubicGen::generateLattice(), AtomProbe::K3DNodeApprox::getAxisVal(), AtomProbe::IonHit::getBoundCube(), AtomProbe::IonHit::getIonDataLimits(), and AtomProbe::K3DNodeApprox::getLocVal().
|
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().
|
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().
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().
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.
|
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().
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().
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().
void AtomProbe::Point3D::normalise | ( | ) |
Make point unit magnitude, maintaining direction.
Definition at line 337 of file point3D.cpp.
References mag(), and sqrMag().
Referenced by AtomProbe::TriangleWithVertexNorm::computeACWNormal(), extend(), AtomProbe::getRotationMatrix(), AtomProbe::Mesh::getTriNormal(), hasNaN(), AtomProbe::intersect_RayTriangle(), main(), orthogonalise(), and AtomProbe::TriangleWithVertexNorm::safeComputeACWNormal().
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().
Elemental multiplication of two Point3D objects (X1*X2, Y1*Y2, Z1*Z2)
Definition at line 237 of file point3D.cpp.
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().
Addition of Point3D objects (X1+X2, Y1+Y2, Z1+Z2)
Definition at line 178 of file point3D.cpp.
Referenced by hasNaN().
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.
Subtraction of two Point3D objects (X1-X2, Y1-Y2, Z1-Z2)
Definition at line 197 of file point3D.cpp.
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().
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().
Elemental division of two Point3D objects (X1/X2, Y1/Y2, Z1/Z2)
Definition at line 260 of file point3D.cpp.
bool AtomProbe::Point3D::operator== | ( | const Point3D & | pt | ) | const |
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().
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.
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().
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().
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().
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().
|
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().
|
inline |
|
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().
float AtomProbe::Point3D::sqrDist | ( | const Point3D & | pt | ) | const |
Returns the square of distance to another Point3D.
(X1-X2)^2 + (Y1-Y2)^2 ...
Definition at line 272 of file point3D.cpp.
Referenced by AtomProbe::K3DTreeExact::clearAllTags(), AtomProbe::computeConvexHull(), AtomProbe::distanceToSegment(), AtomProbe::K3DTreeApprox::findKNearest(), AtomProbe::K3DTreeExact::findUntaggedInRadius(), AtomProbe::generate1DAxialDistHist(), AtomProbe::generate1DAxialDistHistSweep(), AtomProbe::BoundCube::getMaxDistanceToBox(), AtomProbe::getRotationMatrix(), hasNaN(), AtomProbe::BoundCube::intersects(), main(), AtomProbe::signedDistanceToFacet(), AtomProbe::K3DNodeApprox::sqrDist(), and testInexactKDTree().
float AtomProbe::Point3D::sqrMag | ( | ) | const |
Returns magnitude^2, taking this as a position vector.
Definition at line 332 of file point3D.cpp.
Referenced by angle(), AtomProbe::TriangleWithVertexNorm::computeArea(), AtomProbe::computeRotationMatrix(), AtomProbe::distanceToSegment(), extend(), AtomProbe::generate1DAxialDistHist(), getISOSpherical(), hasNaN(), AtomProbe::intersect_RayTriangle(), mag(), main(), normal(), normalise(), orthogonalise(), AtomProbe::TriangleWithVertexNorm::safeComputeACWNormal(), and 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().
|
friend |
Output streaming operator. Streams values in the text format (x,y,z)
Definition at line 417 of file point3D.cpp.
Referenced by hasNaN().