|
scsl 1.0.1
Shimmering Clarity Standard Library
|
Vectors represent a direction and Magnitude. More...
#include <Vector.h>
Public Member Functions | |
| Vector () | |
| Construct a unit vector of a given type and size. | |
| Vector (std::initializer_list< T > ilst) | |
| Construct a Vector with initial values. | |
| T | At (size_t index) const |
| Return the element At index i. | |
| void | Set (size_t index, T value) |
| Set a new value for the vector. | |
| T | Magnitude () const |
| Compute the length of the vector. | |
| void | SetEpsilon (T eps) |
| Set equivalence tolerance. | |
| bool | IsZero () const |
| Determine whether this is a zero vector. | |
| Vector | UnitVector () const |
| Obtain the unit vector for this vector. | |
| bool | IsUnitVector () const |
| Determine if this is a unit vector. | |
| T | Angle (const Vector< T, N > &other) const |
| Compute the Angle between two vectors. | |
| bool | IsParallel (const Vector< T, N > &other) const |
| Determine whether two vectors are parallel. | |
| bool | IsOrthogonal (const Vector< T, N > &other) const |
| Determine if two vectors are orthogonal or perpendicular to each other. | |
| Vector | ProjectParallel (const Vector< T, N > &basis) const |
| Project this vector onto some basis vector. | |
| Vector | ProjectOrthogonal (const Vector< T, N > &basis) |
| Project this vector perpendicularly onto some basis vector. | |
| Vector | Cross (const Vector< T, N > &other) const |
| Compute the cross product of two vectors. | |
| Vector | operator+ (const Vector< T, N > &other) const |
| Vector addition. | |
| Vector | operator- (const Vector< T, N > &other) const |
| Vector subtraction. | |
| Vector | operator* (const T k) const |
| Scalar multiplication. | |
| Vector | operator/ (const T k) const |
| Scalar division. | |
| T | operator* (const Vector< T, N > &other) const |
| Compute the Dot product between two vectors. | |
| bool | operator== (const Vector< T, N > &other) const |
| Vector equivalence. | |
| bool | operator!= (const Vector< T, N > &other) const |
| Vector non-equivalence. | |
| const T & | operator[] (size_t i) const |
| Array indexing into vector. | |
Friends | |
| std::ostream & | operator<< (std::ostream &outs, const Vector< T, N > &vec) |
| Write a vector a stream in the form "<i, j, ...>". | |
Vectors represent a direction and Magnitude.
Vector provides a standard interface for dimensionless fixed-size vectors. Once instantiated, they cannot be modified.
Note that while the class is templated, it's intended to be used with floating-point types.
Vectors can be indexed like arrays, and they contain an epsilon value that defines a tolerance for equality.
Construct a unit vector of a given type and size.
|
inline |
Construct a Vector with initial values.
If given an initializer_list, the vector is created with those values. There must be exactly N elements in the list.
| ilst | An intializer list with N elements of type T. |
Compute the Angle between two vectors.
| other | Another vector. |
Return the element At index i.
| std::out_of_range | if the index is out of bounds. |
| index | The index of the item to retrieve. |
Compute the cross product of two vectors.
This is only defined over three-dimensional vectors.
| std::out_of_range | if this is not a three-dimensional vector. |
| other | Another 3D vector. |
Determine if two vectors are orthogonal or perpendicular to each other.
| other | Another vector |
Determine whether two vectors are parallel.
| other | Another vector |
Determine if this is a unit vector.
Determine whether this is a zero vector.
Compute the length of the vector.
|
inline |
Vector non-equivalence.
| other | The other vector. |
|
inline |
Scalar multiplication.
| k | The scaling value. |
|
inline |
Compute the Dot product between two vectors.
| other | The other vector. |
|
inline |
Vector addition.
| other | The vector to be added. |
|
inline |
Vector subtraction.
| other | The vector to be subtracted from this vector. |
|
inline |
Scalar division.
| k | The scaling value |
|
inline |
Vector equivalence.
| other | The other vector. |
|
inline |
Array indexing into vector.
Note that the values of the vector cannot be modified. Instead, something like the following must be done:
| i | The component index. |
Project this vector perpendicularly onto some basis vector.
This is also called the rejection of the vector.
| basis | The basis vector to be projected onto. |
Project this vector onto some basis vector.
| basis | The basis vector to be projected onto. |
Set a new value for the vector.
This is used to modify the vector in place.
| std::out_of_range | if the index is out of bounds. |
| index | The index to insert the value At. |
| value |
Set equivalence tolerance.
Set the tolerance for equality checks. At a minimum, this accounts for systemic errors in floating math arithmetic.
| eps | is the maximum difference between this vector and another. |
Obtain the unit vector for this vector.
Write a vector a stream in the form "<i, j, ...>".
| outs | An output stream. |
| vec | The vector to be formatted. |