Regina 7.4 Calculation Engine
|
Represents a vector in real three-dimensional space. More...
#include <maths/3d.h>
Public Member Functions | |
Vector3D ()=default | |
Creates a new vector whose coordinates are uninitialised. | |
constexpr | Vector3D (const Vector3D &)=default |
Creates a new copy of the given vector. | |
constexpr | Vector3D (Real x, Real y, Real z) |
Creates a new vector with the given coordinates. | |
constexpr | Vector3D (const std::array< Real, 3 > &coordinates) |
Creates a new vector with the given coordinates. | |
Vector3D & | operator= (const Vector3D &)=default |
Sets this to be a copy of the given vector. | |
constexpr bool | operator== (const Vector3D &other) const |
Determines if this and the given vector have the same coordinates. | |
constexpr Vector3D | operator+ (const Vector3D &rhs) const |
Returns the sum of this and the given vector. | |
constexpr Vector3D | operator- (const Vector3D &rhs) const |
Returns the difference obtained from this vector minus the given vector. | |
constexpr Vector3D | operator* (Real scale) const |
Returns a copy of this vector scaled up by the given factor. | |
constexpr Vector3D | operator/ (Real scale) const |
Returns a copy of this vector scaled down by the given factor. | |
Vector3D & | operator+= (const Vector3D &rhs) |
Adds the given vector to this vector. | |
Vector3D & | operator-= (const Vector3D &rhs) |
Subtracts the given vector from this vector. | |
Vector3D & | operator*= (Real scale) |
Scales this vector up by the given factor. | |
Vector3D & | operator/= (Real scale) |
Scales this vector down by the given factor. | |
constexpr Real | operator* (const Vector3D &rhs) const |
Returns the inner product of this and the given vector. | |
constexpr Real | length () const |
Returns the length of this vector. | |
constexpr Real | distance (const Vector3D &other) const |
Returns the distance between this and the given point in 3-D space. | |
constexpr Vector3D | midpoint (const Vector3D &other) const |
Returns the midpoint between this and the given point. | |
constexpr | operator std::array< Real, 3 > () const |
Casts this point to a standard C++ array. | |
Public Attributes | |
Real | x |
The first (x) coordinate of the vector. | |
Real | y |
The second (y) coordinate of the vector. | |
Real | z |
The third (z) coordinate of the vector. | |
Represents a vector in real three-dimensional space.
This class is also used to represent a single 3-D point.
See Regina's notes on 3-D geometry for important information, including the inexact floating-point nature of the Vector3D class, and the right-handedness of Regina's coordinate system.
These objects are small enough to pass by value and swap with std::swap(), with no need for any specialised move operations or swap functions.
double
.Real | the floating-point type to use for all storage and computation. |
|
default |
Creates a new vector whose coordinates are uninitialised.
|
constexprdefault |
Creates a new copy of the given vector.
|
inlineconstexpr |
Creates a new vector with the given coordinates.
x | the first (x) coordinate. |
y | the second (y) coordinate. |
z | the third (z) coordinate. |
|
inlineconstexpr |
Creates a new vector with the given coordinates.
coordinates | array whose three elements are the x, y and z coordinate respectively. |
|
inlineconstexpr |
Returns the distance between this and the given point in 3-D space.
The naming and description of this function assume that both this and other represent individual points in 3-D space.
Computing a.distance(b)
is equivalent to computing (a-b).length()
.
|
inlineconstexpr |
Returns the length of this vector.
If this object represents a single 3-D point, then this function returns the distance of this point from the origin.
|
inlineconstexpr |
Returns the midpoint between this and the given point.
The naming and description of this function assume that both this and other represent individual points in 3-D space.
Computing a.midpoint(b)
is equivalent to computing (a+b)/2
.
|
inlineconstexpr |
Casts this point to a standard C++ array.
|
inlineconstexpr |
Returns the inner product of this and the given vector.
rhs | the other vector to use in computing the inner product. |
|
inlineconstexpr |
Returns a copy of this vector scaled up by the given factor.
Specifically, the coordinates of the vector that is returned will be the coordinates of this vector multiplied by scale.
scale | the scaling factor to apply. |
|
inline |
Scales this vector up by the given factor.
Specifically, all coordinates of this vector will be multiplied by scale.
scale | the scaling factor to apply. |
|
inlineconstexpr |
Returns the sum of this and the given vector.
rhs | the vector to add to this vector. |
|
inline |
Adds the given vector to this vector.
rhs | the vector to add to this vector. |
|
inlineconstexpr |
Returns the difference obtained from this vector minus the given vector.
If both this and rhs represent 3-D points, then the result is the vector pointing from rhs to this point.
rhs | the vector to subtract from this vector. |
|
inline |
Subtracts the given vector from this vector.
rhs | the vector to subtract from this vector. |
|
inlineconstexpr |
Returns a copy of this vector scaled down by the given factor.
Specifically, the coordinates of the vector that is returned will be the coordinates of this vector divided by scale.
scale | the scaling factor to apply; this must be non-zero. |
|
inline |
Scales this vector down by the given factor.
Specifically, all coordinates of this vector will be divided by scale.
scale | the scaling factor to apply; this must be non-zero. |
|
default |
Sets this to be a copy of the given vector.
|
inlineconstexpr |
Determines if this and the given vector have the same coordinates.
other | the vector to compare with this. |
true
if and only if the two vectors are equal. Real regina::Vector3D< Real >::x |
The first (x) coordinate of the vector.
Real regina::Vector3D< Real >::y |
The second (y) coordinate of the vector.
Real regina::Vector3D< Real >::z |
The third (z) coordinate of the vector.