My Project
 All Classes Files Functions Variables Enumerations Pages
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
XYZ Class Reference

Class to hold vectors in 3D cartesian co-ordinates. More...

#include <xyz.h>

Inheritance diagram for XYZ:
RandomXYZInBox RandomXYZInEllipsoid RandomXYZInSphere RandomXYZInUnitCube RandomXYZSphereNormal

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}
 

Detailed Description

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.

Constructor & Destructor Documentation

XYZ::XYZ ( )
inline

Null constructor.

NB The components are not cleared to zero.

Member Function Documentation

const std::string XYZ::format_pov ( ) const

Alternate formatting.

Also transposes y and z co-ordinates because of POV-Rays idea of up.

void XYZ::normalise ( )
inline

Normalise this vector.

Will fail assertion if the co-ordinate has zero magnitude.

const XYZ XYZ::normalised ( ) const
inline

Return the vector normalised.

Will fail assertion if the co-ordinate has zero magnitude.

void XYZ::operator/= ( float  k)
inline

Divide by scalar.

Implemented assuming one divide and three multiplies is faster than three divides.

Member Data Documentation

XYZ::ElementPtr XYZ::element_table ={&XYZ::x,&XYZ::y,&XYZ::z}
static

Table so we can look up by element number.


The documentation for this class was generated from the following files: