INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

coordinateframe.h

00001 #ifndef ORCAVIEW3D_COORDINATEFRAME_H
00002 #define ORCAVIEW3D_COORDINATEFRAME_H
00003 
00004 #include "vector3.h"
00005 #include "matrix4.h"
00006 #include <iostream>
00007 #include <string>
00008 
00009 namespace orcaqgui3d {
00010 
00011 //
00012 // @author Alex Brooks
00013 //
00014 // @brief This class represents a coordinate frame in the usual Orca sense:
00015 //        The default coordinate frame has x-y plane is parallel to the ground, z up.
00016 //        A local coordinate frame has the x-axis pointing forwards, y left, and z up.
00017 //
00019 //                   [ fwd.x left.x up.x ]   [ pos.x ]                        //
00020 // Coordinate Frame: [ fwd.y left.y up.y ] + [ pos.y ]                        //
00021 //                   [ fwd.z left.z up.z ]   [ pos.z ]                        //
00023 class CoordinateFrame
00024 {
00025 
00026 public: 
00027 
00028     // Initialises to identity
00029     CoordinateFrame();
00030     CoordinateFrame( const Vector3 &pos,
00031                      double         roll,
00032                      double         pitch,
00033                      double         yaw );
00034     // Create from homogeneous matrix
00035     CoordinateFrame( const Matrix4 &m );
00036     CoordinateFrame( const Vector3 &pos,
00037                      const Vector3 &fwd,
00038                      const Vector3 &up );
00039 
00040     const Vector3 &fwd()  const { return fwd_; }
00041     const Vector3 &left() const { return left_; }
00042     const Vector3 &up()   const { return up_; }
00043     const Vector3 &pos()  const { return pos_; }
00044 
00045     void setOrientation( const Vector3 &fwd, const Vector3 &up );
00046     void setPosition( const Vector3 &pos ) { pos_ = pos; }
00047 
00048     void translate( const Vector3 &offset );
00049     void rotate( const Vector3 &axis, double angle );
00050 
00051     // (roll, pitch, yaw) are NOT the native description of the coordinate frame!
00052     // These shouldn't normally need to be used.
00053     double roll() const;
00054     double pitch() const;
00055     double yaw() const;
00056 
00057     // The two versions of increaseYaw:
00058     //   - increaseYawSpace rotates around the frame's current z-axis
00059     //       (imagine yaw-ing a spaceship)
00060     //   - increaseYawPlanet rotates around the world's z-axis
00061     //       (imagine yaw-ing around the gravity vector on a planet)
00062     void increaseRoll( double angle );
00063     void increasePitch( double angle );
00064     void increaseYawSpace( double angle );
00065     void increaseYawPlanet( double angle );
00066 
00067     Matrix4 homogeneousMatrix() const;
00068 
00069     // Transform the coordinate frame by multiplying by another matrix
00070     void multMatrix( const Matrix4 &m );
00071 
00072     // Assumes the bottom row of m is '0,0,0,1'.
00073     void set( const Matrix4 &m );
00074 
00075 private: 
00076 
00077     Vector3 fwd_;
00078     Vector3 left_;
00079     Vector3 up_;
00080     Vector3 pos_;
00081 };
00082 
00083 std::string toString( const CoordinateFrame &c );
00084 inline std::ostream &operator<<( std::ostream &s, const CoordinateFrame &c )
00085 { return s << toString(c); }
00086 std::string toEulerString( const CoordinateFrame &c );
00087 }
00088 
00089 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5