Three dimensional vector. More...
#include <vec3d.hpp>
Public Member Functions | |
Vec3D () | |
Vec3D (double x) | |
Vec3D (double x, double y) | |
Vec3D (double x, double y, double z) | |
Vec3D (const class Vec4D &vec) | |
Vec3D (std::istream &s) | |
~Vec3D () | |
double & | operator[] (int i) |
const double & | operator[] (int i) const |
double & | operator() (int i) |
const double & | operator() (int i) const |
Vec3D | operator+ (const Vec3D &vec) const |
Vector addition | |
Vec3D | operator- (const Vec3D &vec) const |
Vector difference | |
Vec3D & | operator+= (const Vec3D &vec) |
Vector accumulation | |
double | operator* (const Vec3D &vec) const |
Dot product. | |
Vec3D | operator* (double x) const |
Vector scaling. | |
Vec3D | operator- (void) const |
Unary minus. | |
Vec3D & | operator*= (double x) |
Vector scaling. | |
Vec3D & | operator/= (double x) |
Vector scaling with divisor. | |
bool | operator!= (const Vec3D &x) const |
Inequality test. | |
bool | operator== (const Vec3D &x) const |
Equality test. | |
bool | approx (const Vec3D &x, double eps=1.0e-6) const |
Approximate equality test. | |
Vec3D & | operator= (const Vec3D &x) |
Assignment. | |
Vec3D & | operator= (const double &x) |
Assignment of every coordinate. | |
void | abs (void) |
Calculate absolute value of each component. | |
void | normalize (void) |
Normalize vector. | |
double | norm2 (void) const |
Returns 2-norm of vector. | |
double | ssqr (void) const |
Returns square of 2-norm of vector. | |
int | min_element (void) const |
Returns the index of element with minimum magnitude (abs). | |
Vec3D | arb_perpendicular (void) const |
Returns arbitrary vector perpendicular to input vector. | |
void | save (std::ostream &os) const |
Saves data to stream os. |
Static Public Member Functions | |
static Vec3D | standard_basis (int i) |
Returns standard basis vector i. |
Friends | |
Vec3D | cross (const Vec3D &vec1, const Vec3D &vec2) |
Cross product. | |
double | norm2 (const Vec3D &vec) |
Second norm of vector. | |
Vec3D | operator* (double x, const Vec3D &vec) |
Vector scaling. | |
Vec3D | operator* (double x, const class Int3D &i) |
Vector scaling for integer vector. | |
std::ostream & | operator<< (std::ostream &os, const Vec3D &vec) |
Outputting to stream. |
Three dimensional vector.
|
inline |
|
inline |
|
inline |
|
inline |
Vec3D::Vec3D | ( | const class Vec4D & | vec | ) |
|
inline |
|
inline |
|
inline |
Calculate absolute value of each component.
bool Vec3D::approx | ( | const Vec3D & | x, |
double | eps = 1.0e-6 |
||
) | const |
Approximate equality test.
Does not require exact equality, but absolute or relative error less than eps (which ever is less strict). Be careful using this function!
Vec3D Vec3D::arb_perpendicular | ( | void | ) | const |
Returns arbitrary vector perpendicular to input vector.
int Vec3D::min_element | ( | void | ) | const |
Returns the index of element with minimum magnitude (abs).
|
inline |
Returns 2-norm of vector.
|
inline |
Normalize vector.
bool Vec3D::operator!= | ( | const Vec3D & | x | ) | const |
Inequality test.
Require exact equality.
|
inline |
|
inline |
|
inline |
Dot product.
|
inline |
Vector scaling.
|
inline |
Vector scaling.
|
inline |
Unary minus.
|
inline |
Vector scaling with divisor.
|
inline |
Assignment of every coordinate.
bool Vec3D::operator== | ( | const Vec3D & | x | ) | const |
Equality test.
Requires exact equality.
|
inline |
|
inline |
|
inline |
Saves data to stream os.
|
inline |
Returns square of 2-norm of vector.
|
static |
Returns standard basis vector i.
|
friend |
Second norm of vector.
|
friend |
Outputting to stream.