17 #ifndef ATOMPROBE_POINT3D_H 18 #define ATOMPROBE_POINT3D_H 24 #include <gsl/gsl_matrix.h> 31 #include <gsl/gsl_linalg.h> 53 { value[0] = x, value[1] = y, value[2] = z;}
57 inline void setValue(
unsigned int ui,
float val){value[ui]=val;};
60 inline void setValue(
float fX,
float fY,
float fZ)
61 {value[0]=fX; value[1]=fY; value[2]=fZ;}
87 bool parse(
const std::string &s);
98 inline float getValue(
unsigned int ui)
const {
return value[ui];};
125 void extend(
float distance);
128 bool hasNaN()
const {
return (std::isnan(value[0]) ||
129 std::isnan(value[1]) || std::isnan(value[2]));};
254 #ifdef __LITTLE_ENDIAN__ float sqrDist(const Point3D &pt) const
Returns the square of distance to another Point3D.
void reciprocal()
Makes each value its reciprocal (1/X, 1/Y, 1/Z)
const float * getValueArr() const
Obtain a pointer to internal array (3 floats)
void negate()
Makes each value negative of old value (-X, -Y, -Z)
float operator[](unsigned int ui) const
Array indexing operator, Point3D[1] returns the value of the ui-th dim.
const Point3D operator*(float scale) const
Scalar multiplication (X*f, Y*f, Z*f)
Point3D(const float *f)
Constructor initialising values from an array of length 4*(sizeof(float))
Point3D crossProd(const Point3D &pt) const
Calculate the cross product of this and another point.
Point3D(float x, float y, float z)
Constructor with initialising values, X, Y and Z.
const Point3D & operator+=(const Point3D &pt)
+= operator
Point3D()
Constructor with no initialisation.
void copyValueArr(float *value) const
Copy data from internal into target array of length 3 : Pointer MUST be allocated.
bool orthogonalise(const Point3D &p)
Perform a cross-product based orthogonalisation with the specified vector.
void getISOSpherical(float &radius, float &theta, float &phi) const
Get the Point3D value as spherical coordinates (ISO 30-11)
const Point3D operator+(const Point3D &pt) const
Addition of Point3D objects (X1+X2, Y1+Y2, Z1+Z2)
float sqrMag() const
Returns magnitude^2, taking this as a position vector.
A 3D point data class storage.
void setISOSpherical(float radius, float theta, float phi)
Assign the vector using spherical coordinates.
bool parse(const std::string &s)
Set from string representation.
float angle(const Point3D &pt) const
Calculate the angle between two position vectors in radians.
float mag() const
Magnitude of position vector.
Point3D normal() const
Return point unit magnitude, maintianing direction.
const Point3D & operator-=(const Point3D &pt)
-= operator
friend std::ostream & operator<<(std::ostream &stream, const Point3D &)
Output streaming operator. Streams values in the text format (x,y,z)
bool hasNaN() const
Returns true if any of the 3 data pts are NaN.
void setValueArr(const float *val)
Set value by pointer (X, Y, Z from array of len 3)
void transform3x3(const gsl_matrix *matrix)
Perform a 3x3 matrix transformation using a GSL matrix.
void setValue(unsigned int ui, float val)
Set value val of the ui-th dimension, ui in (0,1,2)
void normalise()
Make point unit magnitude, maintaining direction.
Point3D operator*=(const float scale)
*= operator, multiplies the whole Point3D by a scalar
bool operator==(const Point3D &pt) const
Equality operator.
const Point3D operator-() const
Negation, Returns a Point3D object with the negative of the previous value.
void add(const Point3D &obj)
Add a point to this, without generating a return value.
const Point3D & operator=(const Point3D &pt)
Assignment operator.
void setValue(float fX, float fY, float fZ)
Set the XYZ value fo the point.
float getValue(unsigned int ui) const
Get value of ith dimension (0, 1, 2)
const Point3D operator/(float scale) const
Scalar division of Point3D by scale (X/scale, Y/scale, Z/scale)
bool insideBox(const Point3D &farPoint) const
Is this point inside a box bounded by orign and farPoint?
float dotProd(const Point3D &pt) const
Calculate the dot product of this and another point.
void extend(float distance)
Extend the vector by the specified distance.
static void getCentroid(const std::vector< Point3D > &pts, Point3D &p)
find the centroid of a set of points