Class to hold vectors in 3D cartesian co-ordinates. More...
#include <xyz.h>
Public Types | |
typedef float XYZ::* | ElementPtr |
Public Member Functions | |
XYZ () | |
Null constructor. More... | |
XYZ (const XYZ &v) | |
Copy constructor. | |
XYZ (float vx, float vy, float vz) | |
Initialise from separate components. | |
~XYZ () | |
Destructor. | |
const float & | element (uint e) const |
Access by number. | |
float & | element (uint e) |
Access by number. | |
void | operator*= (float k) |
Multiply by scalar. | |
void | operator/= (float k) |
Divide by scalar. More... | |
void | operator+= (const XYZ &v) |
Vector addition. | |
void | operator-= (const XYZ &v) |
Vector subtraction. | |
void | assign (const XYZ &v) |
Assignment. | |
const XYZ | operator- () const |
Negation. | |
float | magnitude2 () const |
Return the square of the magnitude. | |
float | magnitude () const |
Return the magnitude. | |
const XYZ | normalised () const |
Return the vector normalised. More... | |
void | normalise () |
Normalise this vector. More... | |
std::ostream & | write (std::ostream &) const |
Write the vector (spaces as separators). | |
const std::string | format_comma () const |
Alternate formatting. | |
const std::string | format_blender () const |
Alternate formatting. | |
const std::string | format_pov () const |
Alternate formatting. More... | |
Public Attributes | |
float | x |
float | y |
float | z |
Static Public Attributes | |
static ElementPtr | element_table [3] ={&XYZ::x,&XYZ::y,&XYZ::z} |
Class to hold vectors in 3D cartesian co-ordinates.
Direct access to the x,y,z members is permitted. There is a general assumption that the co-ordinate system will be right handed, and that for terrain type applications x and y will be plan position and z will be height.
|
inline |
Null constructor.
NB The components are not cleared to zero.
const std::string XYZ::format_pov | ( | ) | const |
Alternate formatting.
Also transposes y and z co-ordinates because of POV-Rays idea of up.
|
inline |
Normalise this vector.
Will fail assertion if the co-ordinate has zero magnitude.
|
inline |
Return the vector normalised.
Will fail assertion if the co-ordinate has zero magnitude.
|
inline |
Divide by scalar.
Implemented assuming one divide and three multiplies is faster than three divides.
|
static |
Table so we can look up by element number.