orca-robotics


INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

REPOSITORY
Interfaces
Components
Libraries
Utilities
Software Map

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard
Wiki
login/pass: orca/orca

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

vector3.h

00001 #ifndef ORCAQGUI3D_VECTOR3_H
00002 #define ORCAQGUI3D_VECTOR3_H
00003 
00004 #include <string>
00005 
00006 //
00007 // From http://student.kuleuven.be/~m0216922/CG/3dbasics.html
00008 //
00009 
00010 namespace orcaqgui3d {
00011 
00013 //               [ x ]                                                        //
00014 // Vector Class  [ y ]                                                        //
00015 //               [ z ]                                                        //
00017 class Vector3
00018 {
00019 public:
00020 
00021     Vector3(double x, double y, double z)
00022         { v_[0]=x; v_[1]=y; v_[2]=z; }
00023     Vector3()
00024         { v_[0]=0; v_[1]=0; v_[2]=0; }
00025     
00026     double x() const { return v_[0]; }
00027     double y() const { return v_[1]; }
00028     double z() const { return v_[2]; }
00029 
00030     double &x() { return v_[0]; }
00031     double &y() { return v_[1]; }
00032     double &z() { return v_[2]; }
00033 
00034     double operator[](int i) const { return v_[i]; }
00035     double &operator[](int i) { return v_[i]; }
00036     
00037     double length() const;
00038     void normalise();
00039     double distance(const Vector3 &v) const;
00040     double dot(const Vector3 &v) const;
00041     Vector3 cross(const Vector3 &v) const;
00042 
00043 private:
00044     double v_[3];
00045 };
00046 
00047 double length(const Vector3 &v);
00048 Vector3 normalise(const Vector3 &v);
00049 double distance(const Vector3 &v, const Vector3 &w);       
00050 double dot(const Vector3 &v, const Vector3 &w);
00051 Vector3 cross(const Vector3 &v, const Vector3 &w);
00052 Vector3 operator-(const Vector3 &v, const Vector3 &w);
00053 Vector3 operator-(const Vector3 &v);
00054 Vector3 operator+(const Vector3 &v, const Vector3 &w);
00055 Vector3 operator*(const Vector3 &v, double a);
00056 Vector3 operator*(double a, const Vector3 &v);
00057 Vector3 operator/(const Vector3 &v, double a);
00058 
00059 // Gives the angle between two 3D vectors (in radians)
00060 double vectorAngle(const Vector3 &v, const Vector3 &w);
00061 
00062 // Rotate vector v around arbitrary axis for angle radians.  It can only
00063 // rotate around an axis through our object, to rotate around another
00064 // axis: first translate the object to the axis, then use this
00065 // function, then translate back in the new direction.
00066 Vector3 rotateAroundArbitrary(const Vector3 &v, const Vector3 &axis, double angle);
00067 
00068 std::string toString( const Vector3 &v );
00069 inline std::ostream &operator<<( std::ostream &s, const Vector3 &v )
00070 { return s << toString(v); }
00071 
00072 }
00073 
00074 #endif
 

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


Generated for Orca Robotics by  doxygen 1.4.5