basic/geometry/geo_rangesensor/MgcVector3.h

Go to the documentation of this file.
00001 // Magic Software, Inc.
00002 // http://www.magic-software.com
00003 // Copyright (c) 2000, All Rights Reserved
00004 //
00005 // Source code from Magic Software is supplied under the terms of a license
00006 // agreement and may not be copied or disclosed except in accordance with the
00007 // terms of that agreement.  The various license agreements may be found at
00008 // the Magic Software web site.  This file is subject to the license
00009 //
00010 // FREE SOURCE CODE
00011 // http://www.magic-software.com/License.html/free.pdf
00012 
00013 #ifndef MGCVECTOR3_H
00014 #define MGCVECTOR3_H
00015 
00016 #include "MgcMath.h"
00017 
00018 
00019 class MgcVector3 
00020 {
00021 public:
00022     // construction
00023     MgcVector3 ();
00024     MgcVector3 (MgcReal fX, MgcReal fY, MgcReal fZ);
00025     MgcVector3 (MgcReal afCoordinate[3]);
00026     MgcVector3 (const MgcVector3& rkVector);
00027 
00028     // member access (allows V.x or V[0], V.y or V[1], V.z or V[2])
00029     MgcReal x, y, z;
00030     MgcReal& operator[] (int i) const;
00031     operator MgcReal* ();
00032 
00033     // assignment and comparison
00034     MgcVector3& operator= (const MgcVector3& rkVector);
00035     bool operator== (const MgcVector3& rkVector) const;
00036     bool operator!= (const MgcVector3& rkVector) const;
00037 
00038     // arithmetic operations
00039     MgcVector3 operator+ (const MgcVector3& rkVector) const;
00040     MgcVector3 operator- (const MgcVector3& rkVector) const;
00041     MgcVector3 operator* (MgcReal fScalar) const;
00042     MgcVector3 operator/ (MgcReal fScalar) const;
00043     MgcVector3 operator- () const;
00044     friend MgcVector3 operator* (MgcReal fScalar, const MgcVector3& rkVector);
00045 
00046     // arithmetic updates
00047     MgcVector3& operator+= (const MgcVector3& rkVector);
00048     MgcVector3& operator-= (const MgcVector3& rkVector);
00049     MgcVector3& operator*= (MgcReal fScalar);
00050     MgcVector3& operator/= (MgcReal fScalar);
00051 
00052     // vector operations
00053     MgcReal Length () const;
00054     MgcReal SquaredLength () const;
00055     MgcReal Dot (const MgcVector3& rkVector) const;
00056     MgcReal Unitize (MgcReal fTolerance = 1e-06);
00057     MgcVector3 Cross (const MgcVector3& rkVector) const;
00058     MgcVector3 UnitCross (const MgcVector3& rkVector) const;
00059 
00060     // Gram-Schmidt orthonormalization.
00061     static void Orthonormalize (MgcVector3 akVector[3]);
00062 
00063     // Input W must be initialize to a nonzero vector, output is {U,V,W}
00064     // an orthonormal basis.  A hint is provided about whether or not W
00065     // is already unit length.
00066     static void GenerateOrthonormalBasis (MgcVector3& rkU, MgcVector3& rkV,
00067         MgcVector3& rkW, bool bUnitLengthW = true);
00068 
00069     // special points
00070     static const MgcVector3 ZERO;
00071     static const MgcVector3 UNIT_X;
00072     static const MgcVector3 UNIT_Y;
00073     static const MgcVector3 UNIT_Z;
00074 };
00075 
00076 #endif

Generated on Sat Apr 1 21:30:31 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO