Antiprism 0.23
|
Vector with 4 components. More...
#include <vec4d.h>
Public Member Functions | |
vec4d () | |
Constructor. | |
vec4d (double x, double y, double z, double w) | |
Constructor. | |
vec4d & | to_unit () |
Convert into a unit vector with the same direction. | |
vec4d | unit () const |
Get a unit vector with the same direction. | |
double | mag () const |
Get the magnitude of the vector. | |
double | mag2 () const |
Get the square of the magnitude of the vector. | |
vec4d & | operator*= (double n) |
Multiply this vector by a scalar. | |
vec4d & | operator/= (double n) |
Divide this vector by a scalar. | |
vec4d & | operator+= (vec4d v) |
Add a vector to this vector. | |
vec4d & | operator-= (vec4d v) |
Subtract a vector from this vector. | |
double | operator[] (int idx) const |
Get the vector components. | |
double & | operator[] (int idx) |
Get the vector components. | |
double | x () const |
Get the x component. | |
double & | x () |
Get the x component. | |
double | y () const |
Get the y component. | |
double & | y () |
Get the x component. | |
double | z () const |
Get the z component. | |
double & | z () |
Get the x component. | |
double | w () const |
Get the w component. | |
double & | w () |
Get the w component. | |
void | unset () |
Unset the vector. | |
bool | is_set () const |
Check whether a vector has been set. | |
bool | read (const char *str, char *errmsg=0) |
Read a vector from a string. | |
void | dump (const char *var="", FILE *file=stderr) const |
Debugging print of a vector variable. | |
Static Public Member Functions | |
static vec4d | random (rand_gen &rnd) |
Get a random vector. |
Vector with 4 components.
vec4d::vec4d | ( | ) | [inline] |
Constructor.
The vector is initialised to the unset state
vec4d::vec4d | ( | double | x, |
double | y, | ||
double | z, | ||
double | w | ||
) | [inline] |
Constructor.
x | first component |
y | second component |
z | third component |
w | fourth component |
void vec4d::dump | ( | const char * | var = "" , |
FILE * | file = stderr |
||
) | const |
Debugging print of a vector variable.
var | a string to identify the vector variable. |
file | file stream to print the variable. |
bool vec4d::is_set | ( | ) | const [inline] |
Check whether a vector has been set.
true
if set, otherwise false
double vec4d::mag | ( | ) | const [inline] |
Get the magnitude of the vector.
double vec4d::mag2 | ( | ) | const [inline] |
Get the square of the magnitude of the vector.
vec4d & vec4d::operator*= | ( | double | n | ) | [inline] |
Multiply this vector by a scalar.
Add a vector to this vector.
Subtract a vector from this vector.
vec4d & vec4d::operator/= | ( | double | n | ) | [inline] |
Divide this vector by a scalar.
double vec4d::operator[] | ( | int | idx | ) | const [inline] |
Get the vector components.
idx | the component index. |
double& vec4d::operator[] | ( | int | idx | ) | [inline] |
Get the vector components.
idx | the component index. |
vec4d vec4d::random | ( | rand_gen & | rnd | ) | [inline, static] |
Get a random vector.
bool vec4d::read | ( | const char * | str, |
char * | errmsg = 0 |
||
) |
Read a vector from a string.
str | a string containing three decimals separated by commas or spaces. |
errmsg | an array at least MSG_SZ chars long to return any error message. |
vec4d & vec4d::to_unit | ( | ) | [inline] |
Convert into a unit vector with the same direction.
vec4d vec4d::unit | ( | ) | const [inline] |
Get a unit vector with the same direction.
void vec4d::unset | ( | ) |
Unset the vector.
Put the vector into the initial unset state. The vector will return false
if tested
double& vec4d::w | ( | ) | [inline] |
Get the w component.
double vec4d::w | ( | ) | const [inline] |
Get the w component.
double vec4d::x | ( | ) | const [inline] |
Get the x component.
double& vec4d::x | ( | ) | [inline] |
Get the x component.
double& vec4d::y | ( | ) | [inline] |
Get the x component.
double vec4d::y | ( | ) | const [inline] |
Get the y component.
double vec4d::z | ( | ) | const [inline] |
Get the z component.
double& vec4d::z | ( | ) | [inline] |
Get the x component.