# SbVec3f.h

    00001 #ifndef COIN_SBVEC3F_H
    00002 #define COIN_SBVEC3F_H
    00003
    00004 /**************************************************************************\
    00005  *
    00006  *  This file is part of the Coin 3D visualization library.
    00007  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU General Public License
    00011  *  ("GPL") version 2 as published by the Free Software Foundation.
    00012  *  See the file LICENSE.GPL at the root directory of this source
    00013  *  distribution for additional information about the GNU GPL.
    00014  *
    00015  *  For using Coin with software that can not be combined with the GNU
    00016  *  GPL, and for taking advantage of the additional benefits of our
    00017  *  support services, please contact Systems in Motion about acquiring
    00018  *  a Coin Professional Edition License.
    00019  *
    00020  *  See <URL:http://www.coin3d.org> for  more information.
    00021  *
    00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
    00023  *  <URL:http://www.sim.no>.
    00024  *
    00025 \**************************************************************************/
    00026
    00027 #include <stdio.h>
    00028
    00029 #include <Inventor/SbBasic.h>
    00030
    00031 class SbPlane;
    00032 class SbVec3d;
    00033
    00034 class COIN_DLL_API SbVec3f {
    00035 public:
    00036   SbVec3f(void) { }
    00037   SbVec3f(const float v[3]);
    00038   SbVec3f(const float x, const float y, const float z);
    00039   SbVec3f(const SbPlane & p0, const SbPlane & p1, const SbPlane & p2);
    00040   SbVec3f(const SbVec3d & v);
    00041   SbVec3f cross(const SbVec3f & v) const;
    00042   float dot(const SbVec3f & v) const;
    00043   SbBool equals(const SbVec3f & v, const float tolerance) const;
    00044   SbVec3f getClosestAxis(void) const;
    00045   const float * getValue(void) const;
    00046   void getValue(float & x, float & y, float & z) const;
    00047   float length(void) const;
    00048   float sqrLength() const;
    00049   void negate(void);
    00050   float normalize(void);
    00051   SbVec3f & setValue(const float v[3]);
    00052   SbVec3f & setValue(const float x, const float y, const float z);
    00053   SbVec3f & setValue(const SbVec3f & barycentric,
    00054                      const SbVec3f & v0,
    00055                      const SbVec3f & v1,
    00056                      const SbVec3f & v2);
    00057   SbVec3f & setValue(const SbVec3d & v);
    00058   float & operator [](const int i);
    00059   const float & operator [](const int i) const;
    00060   SbVec3f & operator *=(const float d);
    00061   SbVec3f & operator /=(const float d);
    00062   SbVec3f & operator +=(const SbVec3f & u);
    00063   SbVec3f & operator -=(const SbVec3f & u);
    00064   SbVec3f operator-(void) const;
    00065   friend COIN_DLL_API SbVec3f operator *(const SbVec3f & v, const float d);
    00066   friend COIN_DLL_API SbVec3f operator *(const float d, const SbVec3f & v);
    00067   friend COIN_DLL_API SbVec3f operator /(const SbVec3f & v, const float d);
    00068   friend COIN_DLL_API SbVec3f operator +(const SbVec3f & v1, const SbVec3f & v2);
    00069   friend COIN_DLL_API SbVec3f operator -(const SbVec3f & v1, const SbVec3f & v2);
    00070   friend COIN_DLL_API int operator ==(const SbVec3f & v1, const SbVec3f & v2);
    00071   friend COIN_DLL_API int operator !=(const SbVec3f & v1, const SbVec3f & v2);
    00072
    00073   void print(FILE * fp) const;
    00074
    00075 private:
    00076   float vec[3];
    00077 };
    00078
    00079 COIN_DLL_API SbVec3f operator *(const SbVec3f & v, const float d);
    00080 COIN_DLL_API SbVec3f operator *(const float d, const SbVec3f & v);
    00081 COIN_DLL_API SbVec3f operator /(const SbVec3f & v, const float d);
    00082 COIN_DLL_API SbVec3f operator +(const SbVec3f & v1, const SbVec3f & v2);
    00083 COIN_DLL_API SbVec3f operator -(const SbVec3f & v1, const SbVec3f & v2);
    00084 COIN_DLL_API int operator ==(const SbVec3f & v1, const SbVec3f & v2);
    00085 COIN_DLL_API int operator !=(const SbVec3f & v1, const SbVec3f & v2);
    00086
    00087
    00088 /* inlined methods ********************************************************/
    00089
    00090 inline float &
    00091 SbVec3f::operator [](const int i)
    00092 {
    00093   return this->vec[i];
    00094 }
    00095
    00096 inline const float &
    00097 SbVec3f::operator [](const int i) const
    00098 {
    00099   return this->vec[i];
    00100 }
    00101
    00102 #endif // !COIN_SBVEC3F_H