DubiousEngine  0.2.0
Simple Game Engine
Dubious::Math::Coordinate_space Class Reference

Representation of a position and rotation. More...

#include <Coordinate_space.h>

Public Member Functions

 Coordinate_space ()=default
 
std::tuple< Unit_vector, Unit_vector, Unit_vectorget_axes () const
 Get 3 axis. More...
 
void get_matrix (float matrix[16]) const
 Get the OpenGL rotation Matrix. More...
 
const Pointposition () const
 Position accessor. More...
 
Pointposition ()
 
const Unit_quaternionrotation () const
 Rotation accessor. More...
 
Unit_quaternionrotation ()
 
void translate (const Vector &diff)
 Move by the amount specified. More...
 
void translate (const Local_vector &diff)
 Move by the amount specified. More...
 
void rotate (const Unit_quaternion &diff)
 Rotate the coordinate space. More...
 
void rotate (const Local_unit_quaternion &diff)
 Rotate the coordinate space. More...
 
Vector transform (const Local_vector &v) const
 Converts the local vector to the global coord space. More...
 
Local_vector transform (const Vector &v) const
 Converts the vector to the local coord space. More...
 
Point transform (const Local_point &p) const
 Converts the local point to the global coord space. More...
 
Local_point transform (const Point &p) const
 Converts the point to the local coord space. More...
 

Friends

class Physics_test::Collision_solver_test
 

Detailed Description

Representation of a position and rotation.

The Coordinate_space is meant to represent a position and rotation. It allows you to hide the complexities of world versus local rotation and position. You can easily specify that you want to move along the global X OR local X axis. Likewise you can rotate around the global OR local Z axis.

The system uses a "Right Handed" coordinate space, the same as OpenGL and Bullet Physics. This means that as you are reading this, positive X is to your right, positive Y is up, and positive Z is going from this text to your eye. If you hold up your right hand and place your thumb along positive X and your index finger along positive Y then your middle finger is pointing along positive Z (at you).

Constructor & Destructor Documentation

Dubious::Math::Coordinate_space::Coordinate_space ( )
default

Member Function Documentation

std::tuple< Unit_vector, Unit_vector, Unit_vector > Dubious::Math::Coordinate_space::get_axes ( ) const

Get 3 axis.

It's common to want the X, Y, and Z axis that make up a coordinate system

Returns
a tuple with X, Y, and Z Unit_vectors
void Dubious::Math::Coordinate_space::get_matrix ( float  matrix[16]) const

Get the OpenGL rotation Matrix.

Get the rotation matrix from the Quaternion. This is directly usable by openGL

Parameters
matrix- [out] The rotation matrix
const Point& Dubious::Math::Coordinate_space::position ( ) const
inline

Position accessor.

Point& Dubious::Math::Coordinate_space::position ( )
inline
void Dubious::Math::Coordinate_space::rotate ( const Unit_quaternion diff)

Rotate the coordinate space.

This version takes a global quaternion, therefore it rotates relative to global space

Parameters
diff- [in] The amount to rotate
void Dubious::Math::Coordinate_space::rotate ( const Local_unit_quaternion diff)

Rotate the coordinate space.

This version takes a local quaternion, therefore it rotates relative to local space

Parameters
diff- [in] The amount to rotate
const Unit_quaternion& Dubious::Math::Coordinate_space::rotation ( ) const
inline

Rotation accessor.

Unit_quaternion& Dubious::Math::Coordinate_space::rotation ( )
inline
Vector Dubious::Math::Coordinate_space::transform ( const Local_vector v) const

Converts the local vector to the global coord space.

Parameters
v- [in] a vector in local coordinate space
Returns
The same vector in world coordinate space
Local_vector Dubious::Math::Coordinate_space::transform ( const Vector v) const

Converts the vector to the local coord space.

Parameters
v- [in] a vector in world coordinate space
Returns
The same vector in local coordinate space
Point Dubious::Math::Coordinate_space::transform ( const Local_point p) const

Converts the local point to the global coord space.

Note that this is not a vector, it's a point. As such this takes the coordinate space position into account.

Parameters
p- [in] a point in local coordinate space
Returns
The same point in world coordinate space
Local_point Dubious::Math::Coordinate_space::transform ( const Point p) const

Converts the point to the local coord space.

Note that this is not a vector, it's a point. As such this takes the coordinate space position into account.

Parameters
p- [in] a point in world coordinate space
Returns
The same point in local coordinate space
void Dubious::Math::Coordinate_space::translate ( const Vector diff)

Move by the amount specified.

This version takes a global vector, therefore it moves relative to global space.

Parameters
diff- [in] The amount to move
void Dubious::Math::Coordinate_space::translate ( const Local_vector diff)

Move by the amount specified.

This version takes a local vector, therefore it moves relative to local space.

Parameters
diff- [in] The amount to move

Friends And Related Function Documentation

friend class Physics_test::Collision_solver_test
friend

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