atomicrex  0.1
An advanced atomistic model building tool
Classes | Public Member Functions | Related Functions | List of all members
atomicrex::Point_3< T > Class Template Reference

A point in 3d space. More...

#include <Point3.h>

Inheritance diagram for atomicrex::Point_3< T >:

Classes

struct  Origin
 An empty type that denotes the point (0,0,0). More...
 

Public Member Functions

 Point_3 ()
 Constructs a point without initializing its components. The components will have an undefined value!
 
constexpr Point_3 (T val)
 Constructs a point with all three components initialized to the given value.
 

Related Functions

(Note that these are not member functions.)

using Point3 = Point_3< FloatType >
 Instantiation of the Point_3 class template with the default floating-point type.
 
using Point3I = Point_3< int >
 Instantiation of the Point_3 class template with the default integer type.
 
template<typename T >
constexpr Point_3< T > operator+ (const Point_3< T > &a, const Vector_3< T > &b)
 Computes the sum of a point and a vector. More...
 
template<typename T >
constexpr const Point_3< T > & operator+ (typename Point_3< T >::Origin, const Vector_3< T > &b)
 Converts a vector to a point. More...
 
template<typename T >
constexpr Point_3< T > operator+ (const Vector_3< T > &a, const Point_3< T > &b)
 Computes the sum of a vector and a point. More...
 
template<typename T >
constexpr Point_3< T > operator- (const Point_3< T > &a, const Vector_3< T > &b)
 Subtracts a vector from a point. More...
 
template<typename T >
constexpr Vector_3< T > operator- (const Point_3< T > &a, const Point_3< T > &b)
 Computes the vector connecting to two points. More...
 
template<typename T >
constexpr Point_3< T > operator* (const Point_3< T > &a, T s)
 Computes the component-wise product of a point and a scalar value. More...
 
template<typename T >
constexpr Point_3< T > operator* (T s, const Point_3< T > &a)
 Computes the component-wise product of a point and a scalar value. More...
 
template<typename T >
constexpr Point_3< T > operator/ (const Point_3< T > &a, T s)
 Computes the component-wise division of a point by a scalar value. More...
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const Point_3< T > &v)
 Writes a point to a text output stream. More...
 

Detailed Description

template<typename T>
class atomicrex::Point_3< T >

A point in 3d space.

Point_3 represents a point in three-dimensional space with three coordinates x,y, and z. Note that there exists a corresponding class Vector_3, which represents a vector in three-dimensional space.

The template parameter T specifies the data type of the points's components. Two standard instantiations of Point_3 for floating-point and integer coordinates are predefined:

typedef Point_3<FloatType> Point3;
typedef Point_3<int> Point3I;

Point_3 derives from std::array<T,3>. Thus, the point coordinates can be accessed via indices, but also via names:

p[1] = 10.0f;
p.y() = 10.0f;

Note that the default constructor does not initialize the components of the point for performance reasons. The nested type Origin can be used to construct the point (0,0,0):

Point3 p = Point3::Origin()

Origin can also be used to convert between points and vectors:

Vector3 v0(1, 2, 3);
Point3 p1 = Point3::Origin() + v0; // Vector to point conversion
Point3 p2 = p1 + v0; // Adding a vector to a point
Vector3 delta = p2 - p1; // Vector connecting two points
Vector3 v1 = p2 - Point3::Origin(); // Point to vector conversion
FloatType r = (p2 - p1).length(); // Distance between two points

Note that points and vectors behave differently under affine transformations:

AffineTransformation tm = AffineTransformation::rotationZ(angle) * AffineTransformation::translation(t);
Point3 p = tm * Point3(1,2,3); // Translates and rotates the point (1,2,3).
Vector3 v = tm * Vector3(1,2,3); // Only rotates the vector (1,2,3). Translation doesn't change a vector.
See also
Vector_3

Friends And Related Function Documentation

◆ operator*() [1/2]

template<typename T >
constexpr Point_3< T > operator* ( const Point_3< T > &  a,
s 
)
related

Computes the component-wise product of a point and a scalar value.

◆ operator*() [2/2]

template<typename T >
constexpr Point_3< T > operator* ( s,
const Point_3< T > &  a 
)
related

Computes the component-wise product of a point and a scalar value.

◆ operator+() [1/3]

template<typename T >
constexpr Point_3< T > operator+ ( const Point_3< T > &  a,
const Vector_3< T > &  b 
)
related

Computes the sum of a point and a vector.

◆ operator+() [2/3]

template<typename T >
constexpr const Point_3< T > & operator+ ( typename Point_3< T >::Origin  ,
const Vector_3< T > &  b 
)
related

Converts a vector to a point.

◆ operator+() [3/3]

template<typename T >
constexpr Point_3< T > operator+ ( const Vector_3< T > &  a,
const Point_3< T > &  b 
)
related

Computes the sum of a vector and a point.

◆ operator-() [1/2]

template<typename T >
constexpr Point_3< T > operator- ( const Point_3< T > &  a,
const Vector_3< T > &  b 
)
related

Subtracts a vector from a point.

◆ operator-() [2/2]

template<typename T >
constexpr Vector_3< T > operator- ( const Point_3< T > &  a,
const Point_3< T > &  b 
)
related

Computes the vector connecting to two points.

◆ operator/()

template<typename T >
constexpr Point_3< T > operator/ ( const Point_3< T > &  a,
s 
)
related

Computes the component-wise division of a point by a scalar value.

◆ operator<<()

template<typename T >
std::ostream & operator<< ( std::ostream &  os,
const Point_3< T > &  v 
)
related

Writes a point to a text output stream.


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