|
geomc 1.0
A c++ linear algebra template library
|
3D specialization of vector class. More...
#include <geomc/linalg/vecdetail/Vec3.h>
Public Types | |
| using | elem_t |
| The coordinate type of this object. | |
| using | point_t |
| The type of a point in this object's space. | |
| typedef Vec< T, N > | self_t |
Self type. I.e., Vec<T,N> if a vector, Quat<T> if a quaternion. | |
Public Member Functions | |
| constexpr | Vec () |
| constexpr | Vec () |
| Construct vector with all elements set to 0. | |
| Vec (const std::initializer_list< T > &items) | |
| constexpr | Vec (const T a[N]) |
| constexpr | Vec (const T v[3]) |
Construct a vector with elements copied from the 3-element array v. | |
| constexpr | Vec (const Vec< T, M > &...vecs) |
| Construct a new vector by concatenating two or more vectors. | |
| constexpr | Vec (const Vec< U, N-1 > &v, T a) |
| Vec (detail::MtxColIterator< Mx, Ref > mtx_col) | |
| constexpr | Vec (T a) |
| constexpr | Vec (T a) |
Construct a vector with all elements set to a. | |
| constexpr | Vec (T x, T y, T z) |
Construct a vector with elements (x, y, z). | |
| template<typename U> | |
| constexpr | Vec (Vec< U, 2 > xy, T z) |
Construct a vector with (x, y) taken from the 2D vector xy, and z as the final element. | |
| self_t | abs () const |
| Element-wise absolute value. | |
| self_t | add (const self_t &v) const |
| Vector addition. | |
| self_t | add (const self_t &v) const |
| Vector addition. | |
| Vec< T, 3 > | add (T dx, T dy, T dz) const |
| self_t | align (const self_t &from, const self_t &to) const |
Apply a rotation to this which aligns the unit vectors from with to. | |
| self_t | align (const self_t &from, const self_t &to) const |
Apply a rotation to this which aligns the unit vectors from with to. | |
| Vec< T, 3 > | align (const Vec< T, 3 > &from, const Vec< T, 3 > &to) |
| T | angle_to (const self_t &v) const |
| Angle between vectors. | |
| T | angle_to (const self_t &v) const |
| Angle between vectors. | |
| index_t | argmax () const |
| Return the index of the coordinate with the largest absolute value. | |
| index_t | argmin () const |
| Return the index of the coordinate with the smallest absolute value. | |
| T * | begin () |
| const T * | begin () const |
| self_t | bounce_on (const self_t &normal) const |
| Elastic collision. | |
| self_t | bounce_on (const self_t &normal) const |
| Elastic collision. | |
| self_t | ceil () const |
| Element-wise ceiling function. | |
| self_t | clamp (const self_t &lo, const self_t &hi) const |
| Element-wise clamp. | |
| self_t | clamp (const self_t &lo, const self_t &hi) const |
| Element-wise clamp. | |
| Vec< T, 3 > | cross (Vec< T, 3 > v) const |
| T | dist (const self_t &pt) const |
| Distance between points. | |
| T | dist (const self_t &pt) const |
| Distance between points. | |
| T | dist2 (const self_t &pt) const |
| Distance squared to a point. | |
| T | dist2 (const self_t &pt) const |
| Distance squared to a point. | |
| T | dot (const self_t &v) const |
| Dot product. | |
| T | dot (const self_t &v) const |
| Dot product. | |
| T | dot (T xx, T yy, T zz) const |
| T * | end () |
| const T * | end () const |
| self_t | floor () const |
| Element-wise floor function. | |
| T | fraction_on (const self_t &axis) const |
Return the component of this that projects to axis, as a fraction of axis's length. | |
| T | fraction_on (const self_t &axis) const |
Return the component of this that projects to axis, as a fraction of axis's length. | |
| T & | get (index_t idx) |
| const T & | get (index_t idx) const |
| bool | is_finite_real () const |
| bool | is_zero () const |
Return true if all elements are zero. | |
| T | mag () const |
| Euclidean norm (magnitude). | |
| T | mag2 () const |
| Squared magnitude. | |
| self_t | max (const self_t &v) const |
Element-wise maximum of two Vecs. | |
| T | max () const |
| Maximum element. | |
| self_t | max (const self_t &v) const |
Element-wise maximum of two Vecs. | |
| self_t | min (const self_t &v) const |
Element-wise minimum of two Vecs. | |
| T | min () const |
| Minimum element. | |
| self_t | min (const self_t &v) const |
Element-wise minimum of two Vecs. | |
| self_t | mix (const self_t &v, T mix) const |
| Linear interpolation. | |
| self_t | mix (const self_t &v, T mix) const |
| Linear interpolation. | |
| operator Vec< U, N > () const | |
| Element typecast. | |
| bool | operator!= (const self_t &vv) const |
| Inequality test. | |
| bool | operator!= (const self_t &vv) const |
| Inequality test. | |
| self_t & | operator*= (const self_t &vv) |
| Element-wise multiplication and assignment. | |
| self_t & | operator*= (const self_t &vv) |
| Element-wise multiplication and assignment. | |
| self_t & | operator*= (T s) |
| Scalar multiplication and assignment. | |
| self_t | operator+ (const self_t &v) const |
| Element-wise addition. | |
| self_t | operator+ (const self_t &v) const |
| Element-wise addition. | |
| self_t & | operator+= (const self_t &vv) |
| Element-wise addition and assignment. | |
| self_t & | operator+= (const self_t &vv) |
| Element-wise addition and assignment. | |
| self_t | operator- (const self_t &v) const |
| Element-wise subtraction. | |
| self_t | operator- () const |
| Negation. | |
| self_t | operator- (const self_t &v) const |
| Element-wise subtraction. | |
| self_t & | operator-= (const self_t &vv) |
| Subtraction and assignment. | |
| self_t & | operator-= (const self_t &vv) |
| Subtraction and assignment. | |
| self_t & | operator/= (T s) |
| Scalar division and assignment. | |
| bool | operator== (const self_t &vv) const |
| Equality test. | |
| bool | operator== (const self_t &vv) const |
| Equality test. | |
| T & | operator[] (index_t idx) |
| Vector element access. | |
| const T & | operator[] (index_t idx) const |
| Vector element access. | |
| Vec< T, 3 > | operator^ (Vec< T, 3 > v) const |
| Vector cross product. | |
| T | product () const |
| Multiply all elements together. | |
| self_t | project_on (const self_t &axis) const |
| Orthogonal projection to an axis. | |
| self_t | project_on (const self_t &axis) const |
| Orthogonal projection to an axis. | |
| self_t | reflect_about (self_t normal) const |
| Reflection about a normal. | |
| self_t | reflect_about (self_t normal) const |
| Reflection about a normal. | |
| Vec< T, 3 > | reflected_x () const |
| Vec< T, 3 > | reflected_y () const |
| Vec< T, 3 > | reflected_z () const |
| PointType< T, M >::point_t | resized () const |
| Resized copy of a vector. | |
| Vec< T, 3 > | rotate (T u, T v, T w, T a, T b, T c, T radians) |
| Vec< T, 3 > | rotate (T u, T v, T w, T radians) const |
| Vec< T, 3 > | rotate (Vec< T, 3 > axis, T radians) const |
| Vec< T, 3 > | rotate (Vec< T, 3 > axis, Vec< T, 3 > center, T radians) |
| self_t | round () const |
| Round each element to the nearest integer. | |
| self_t | scale (const self_t &v) const |
| Element-wise multiplication. | |
| self_t | scale (const self_t &v) const |
| Element-wise multiplication. | |
| self_t | scale (T a) const |
| Scalar multiple. | |
| Vec< T, 3 > | scale (T a, T b, T c) const |
| index_t | size () const |
The number of elements in this vector. Always equal to N. | |
| self_t | sub (const self_t &v) const |
| Vector subtraction. | |
| self_t | sub (const self_t &v) const |
| Vector subtraction. | |
| Vec< T, 3 > | sub (T dx, T dy, T dz) const |
| T | sum () const |
| Sum the elements of the vector. | |
| Vec< T, 3 > | to_spherical () const |
| self_t | unit () const |
| Vector normalization. | |
| self_t | with_length (T mag) const |
Compute a vector with the direction of this and a new magnitude mag. | |
Static Public Member Functions | |
| static Vec< T, 3 > | from_spherical (T r, T elev, T azi) |
Static Public Attributes | |
| static constexpr index_t | N |
| The dimension of this object. | |
| static const self_t | ones |
| static const self_t | unit_x |
| static const Vec< T, 3 > | X_AXIS |
| (1, 0, 0) constant | |
| static const Vec< T, 3 > | Y_AXIS |
| (0, 1, 0) constant | |
| static const Vec< T, 3 > | Z_AXIS |
| (0, 0, 1) constant | |
| static const self_t | zeros |
Protected Attributes | |
| T | v [N] |
Related Symbols | |
(Note that these are not member symbols.) | |
| geom::Vec< T, N > | abs (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | abs (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | ceil (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | ceil (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | cos (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | cos (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | exp (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | exp (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | floor (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | floor (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | log (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | log (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | max (const geom::Vec< T, N > &a, const geom::Vec< T, N > &b) |
| geom::Vec< T, N > | max (const geom::Vec< T, N > &a, const geom::Vec< T, N > &b) |
| geom::Vec< T, N > | min (const geom::Vec< T, N > &a, const geom::Vec< T, N > &b) |
| geom::Vec< T, N > | min (const geom::Vec< T, N > &a, const geom::Vec< T, N > &b) |
| const Vec< T, N > | operator* (const Vec< T, N > &a, const Vec< T, N > &b) |
| const Vec< T, N > | operator* (const Vec< T, N > &a, const Vec< T, N > &b) |
| Vec< T, N > | operator* (const Vec< T, N > &v, U d) |
| Vec< T, N > | operator* (const Vec< T, N > &v, U d) |
| Vec< T, N > | operator* (U d, const Vec< T, N > &v) |
| Vec< T, N > | operator* (U d, const Vec< T, N > &v) |
| const Vec< T, N > | operator/ (const Vec< T, N > &a, const Vec< T, N > &b) |
| const Vec< T, N > | operator/ (const Vec< T, N > &a, const Vec< T, N > &b) |
| Vec< T, N > | operator/ (const Vec< T, N > &v, U d) |
| Vec< T, N > | operator/ (const Vec< T, N > &v, U d) |
| Vec< T, N > | operator/ (const Vec< T, N > &v, U d) |
| Vec< T, N > | operator/ (const Vec< T, N > &v, U d) |
| geom::Vec< T, N > | sin (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | sin (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | sqrt (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | sqrt (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | tan (const geom::Vec< T, N > &v) |
| geom::Vec< T, N > | tan (const geom::Vec< T, N > &v) |
3D specialization of vector class.
Vec<T,3>'s elements may be accessed under these equivalent naming schemes:
v.{x,y,z} // conventional Euclidean coordinate names
v.{s,t,u} // conventional parameterization coordinate names
v.{r,g,b} // conventional color tuple coordinate names
x, s, and r all refer to the same element.
| using point_t |
The type of a point in this object's space.
An N-vector of T if N > 1, otherwise a T.
|
inlineconstexpr |
Construct a new vector with all elements set to zero.
|
inlineconstexpr |
Construct a new vector with all elements set to the value of a.
| a | Scalar value |
|
inlineconstexpr |
Construct a new vector with elements copied from a.
| a | An array of length N. |
Construct a new vector with the elements from v, with a as the last element.
| v | A vector of dimension N - 1 |
| a | The value of the last element |
|
inline |
Construct a vector from a column of a matrix.
| mtx_col | A matrix column iterator (obtained via mtx.col(i)). |
|
inline |
Construct a vector from a brace-initialization list.
Example: Vec<int,3> v = {2, 5, 8};
| items | A brace-initializer list. |
|
inline |
Element-wise absolute value.
x such that x[i] = abs(this[i]). Vector addition.
| v | Another vector. |
x such that x[i] = this[i] + v[i]. Vector addition.
| v | Another vector. |
x such that x[i] = this[i] + v[i].
|
inline |
(dx, dy, dz) added with this Compute a transform aligning from with to and apply it to this.
|
inlineinherited |
Angle between vectors.
| v | Another vector. |
this and v, between 0 and pi.
|
inline |
Angle between vectors.
| v | Another vector. |
this and v, between 0 and pi.
|
inline |
|
inline |
Elastic collision.
Treat this as a velocity vector or incident ray; this function returns the velocity reflected off of a surface with normal normal. Convenience for -reflect_about(normal).
| normal | Normal of surface to "bounce" on. |
Elastic collision.
Treat this as a velocity vector or incident ray; this function returns the velocity reflected off of a surface with normal normal. Convenience for -reflect_about(normal).
| normal | Normal of surface to "bounce" on. |
|
inline |
Element-wise ceiling function.
x such that x[i] = ceil(this[i]). Element-wise clamp.
| lo | Element-wise lower extremes. |
| hi | Element-wise upper extremes. |
x[i] is clamped between lo[i] and hi[i]. Element-wise clamp.
| lo | Element-wise lower extremes. |
| hi | Element-wise upper extremes. |
x[i] is clamped between lo[i] and hi[i]. this by v, in the order shown.
|
inlineinherited |
Distance between points.
| pt | Another point. |
this and pt.
|
inline |
Distance between points.
| pt | Another point. |
this and pt.
|
inlineinherited |
Distance squared to a point.
| pt | Another point. |
this and pt.
|
inline |
Distance squared to a point.
| pt | Another point. |
this and pt.
|
inlineinherited |
Dot product.
| v | Another vector. |
this with v.
|
inline |
Dot product.
| v | Another vector. |
this with v.
|
inline |
this with the vector (xx, yy, zz)
|
inline |
|
inline |
|
inline |
Element-wise floor function.
x such that x[i] = floor(this[i]).
|
inlineinherited |
Return the component of this that projects to axis, as a fraction of axis's length.
| axis | An arbitrary basis vector. |
|
inline |
Return the component of this that projects to axis, as a fraction of axis's length.
| axis | An arbitrary basis vector. |
|
inlinestatic |
Construct a point from spherical coordinates (r, elevation, azimuth), to euclidean coordinates, where r is the radius, eleveation is the angle from the +z axis, and azimuth is the angle about z+ from the x+ axis.
|
inline |
Get the element at index idx.
| idx | Index of element. |
idx.
|
inline |
Get the element at index idx.
| idx | Index of element. |
idx.
|
inline |
true if no elements are an infinity or NaN.
|
inline |
Euclidean norm (magnitude).
|
inline |
Squared magnitude.
Element-wise maximum of two Vecs.
| v | Another vector. |
x such that x[i] = max(this[i], v[i]).
|
inline |
Maximum element.
Element-wise maximum of two Vecs.
| v | Another vector. |
x such that x[i] = max(this[i], v[i]). Element-wise minimum of two Vecs.
| v | Another vector. |
x such that x[i] = min(this[i], v[i]).
|
inline |
Minimum element.
Element-wise minimum of two Vecs.
| v | Another vector. |
x such that x[i] = min(this[i], v[i]). Linear interpolation.
A mix parameter of 0 evaluates to this, while 1 is v.
| v | Another vector. |
| mix | A mixing factor between 0 and 1. |
this with v. Linear interpolation.
A mix parameter of 0 evaluates to this, while 1 is v.
| v | Another vector. |
| mix | A mixing factor between 0 and 1. |
this with v. Element typecast.
U.
|
inlineinherited |
Inequality test.
true if any corresponding elements of this and vv are unequal, false otherwise.
|
inline |
Inequality test.
true if any corresponding elements of this and vv are unequal, false otherwise.
|
inline |
Negation.
|
inlineinherited |
Equality test.
true if all corresponding elements of this and vv are equal, false otherwise.
|
inline |
Equality test.
true if all corresponding elements of this and vv are equal, false otherwise.
|
inline |
Vector element access.
| idx | Index of element to retrieve. |
idx.
|
inline |
Vector element access.
| idx | Index of element to retrieve. |
idx. Orthogonal projection to an axis.
| axis | A direction vector. |
axis with magnitude equal to the component of this aligned with axis. Orthogonal projection to an axis.
| axis | A direction vector. |
axis with magnitude equal to the component of this aligned with axis. Reflection about a normal.
| normal | Axis of reflection. |
Reflection about a normal.
| normal | Axis of reflection. |
|
inline |
|
inline |
|
inline |
Resized copy of a vector.
| M | Dimension of new vector. |
M. If M is larger than N, the new elements will be set to zero. If M is 1, then the return type is T.
|
inline |
radians about the axis (u, v, w), and centerpoint (a, b, c).
|
inline |
radians about the axis (u, v, w). radians about axis. radians about rotation axis axis and centerpoint center. Element-wise multiplication.
| v | Another vector. |
x such that x[i] = this[i] * v[i]. Element-wise multiplication.
| v | Another vector. |
x such that x[i] = this[i] * v[i].
|
inline |
Scalar multiple.
| a | A constant scale factor. |
x such that x[i] = this[i] * a.
|
inline |
Vector subtraction.
| v | Another vector. |
x such that x[i] = this[i] - v[i]. Vector subtraction.
| v | Another vector. |
x such that x[i] = this[i] - v[i].
|
inline |
(dx, dy, dz) subtracted from this
|
inline |
Convert this euclidean point to spherical coordinates (r, elevation, azimuth), with both angles in radians. Elevation is the angle from the +z axis in the range (0, pi), and azimuth is the angle about +z from the +x axis in the range (-pi, pi).
|
inline |
Vector normalization.
|
inline |
Compute a vector with the direction of this and a new magnitude mag.
If this is the zero vector, it will remain unchanged.
Element-wise maximum.
Element-wise maximum.
Element-wise minimum.
Element-wise minimum.
Element-wise vector multiplication
| a | A vector |
| b | A vector |
x such that x[i] = a[i] * b[i] Element-wise vector multiplication
| a | A vector |
| b | A vector |
x such that x[i] = a[i] * b[i] Vector-scalar multiplication
| v | A vector |
| d | Scalar value of type satisfying std::is_scalar |
x such that x[i] = v[i] * d Vector-scalar multiplication
| v | A vector |
| d | Scalar value of type satisfying std::is_scalar |
x such that x[i] = v[i] * d Vector-scalar multiplication
| d | Scalar value of type satisfying std::is_scalar |
| v | A vector |
x such that x[i] = d * v[i] Vector-scalar multiplication
| d | Scalar value of type satisfying std::is_scalar |
| v | A vector |
x such that x[i] = d * v[i] Element-wise vector division
| a | A vector |
| b | A vector |
x such that x[i] = a[i] / b[i] Element-wise vector division
| a | A vector |
| b | A vector |
x such that x[i] = a[i] / b[i] Vector division by a scalar
| v | A vector |
| d | Scalar value |
x such that x[i] = v[i] / d Vector division by a scalar
| v | A vector |
| d | Scalar value |
x such that x[i] = v[i] / d Scalar division by a vector
| d | Scalar value |
| v | A vector |
x such that x[i] = d / v[i] Scalar division by a vector
| d | Scalar value |
| v | A vector |
x such that x[i] = d / v[i]