![]() |
http://www.sim.no http://www.coin3d.org |
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-2007 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 http://www.coin3d.org/ for more information. 00021 * 00022 * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY. 00023 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org 00024 * 00025 \**************************************************************************/ 00026 00027 #include <stdio.h> 00028 00029 #include <Inventor/SbBasic.h> 00030 00031 class SbPlane; 00032 class SbVec3d; 00033 class SbVec3b; 00034 class SbVec3s; 00035 class SbVec3i32; 00036 00037 class COIN_DLL_API SbVec3f { 00038 public: 00039 SbVec3f(void) { } 00040 SbVec3f(const float v[3]); 00041 SbVec3f(const float x, const float y, const float z); 00042 SbVec3f(const SbPlane & p0, const SbPlane & p1, const SbPlane & p2); 00043 SbVec3f(const SbVec3d & v); 00044 explicit SbVec3f(const SbVec3b & v) { setValue(v); } 00045 explicit SbVec3f(const SbVec3s & v) { setValue(v); } 00046 explicit SbVec3f(const SbVec3i32 & v) { setValue(v); } 00047 00048 SbVec3f & setValue(const float v[3]); 00049 SbVec3f & setValue(const float x, const float y, const float z); 00050 SbVec3f & setValue(const SbVec3f & barycentric, 00051 const SbVec3f & v0, 00052 const SbVec3f & v1, 00053 const SbVec3f & v2); 00054 SbVec3f & setValue(const SbVec3d & v); 00055 SbVec3f & setValue(const SbVec3b & v); 00056 SbVec3f & setValue(const SbVec3s & v); 00057 SbVec3f & setValue(const SbVec3i32 & v); 00058 00059 SbVec3f cross(const SbVec3f & v) const; 00060 float dot(const SbVec3f & v) const; 00061 SbBool equals(const SbVec3f & v, const float tolerance) const; 00062 SbVec3f getClosestAxis(void) const; 00063 const float * getValue(void) const; 00064 void getValue(float & x, float & y, float & z) const; 00065 float length(void) const; 00066 float sqrLength() const; 00067 void negate(void); 00068 float normalize(void); 00069 float & operator [](const int i); 00070 const float & operator [](const int i) const; 00071 SbVec3f & operator *=(const float d); 00072 SbVec3f & operator /=(const float d); 00073 SbVec3f & operator +=(const SbVec3f & u); 00074 SbVec3f & operator -=(const SbVec3f & u); 00075 SbVec3f operator-(void) const; 00076 friend COIN_DLL_API SbVec3f operator *(const SbVec3f & v, const float d); 00077 friend COIN_DLL_API SbVec3f operator *(const float d, const SbVec3f & v); 00078 friend COIN_DLL_API SbVec3f operator /(const SbVec3f & v, const float d); 00079 friend COIN_DLL_API SbVec3f operator +(const SbVec3f & v1, const SbVec3f & v2); 00080 friend COIN_DLL_API SbVec3f operator -(const SbVec3f & v1, const SbVec3f & v2); 00081 friend COIN_DLL_API int operator ==(const SbVec3f & v1, const SbVec3f & v2); 00082 friend COIN_DLL_API int operator !=(const SbVec3f & v1, const SbVec3f & v2); 00083 00084 void print(FILE * fp) const; 00085 00086 private: 00087 float vec[3]; 00088 }; 00089 00090 COIN_DLL_API SbVec3f operator *(const SbVec3f & v, const float d); 00091 COIN_DLL_API SbVec3f operator *(const float d, const SbVec3f & v); 00092 COIN_DLL_API SbVec3f operator /(const SbVec3f & v, const float d); 00093 COIN_DLL_API SbVec3f operator +(const SbVec3f & v1, const SbVec3f & v2); 00094 COIN_DLL_API SbVec3f operator -(const SbVec3f & v1, const SbVec3f & v2); 00095 COIN_DLL_API int operator ==(const SbVec3f & v1, const SbVec3f & v2); 00096 COIN_DLL_API int operator !=(const SbVec3f & v1, const SbVec3f & v2); 00097 00098 00099 /* inlined methods ********************************************************/ 00100 00101 inline float & 00102 SbVec3f::operator [](const int i) 00103 { 00104 return this->vec[i]; 00105 } 00106 00107 inline const float & 00108 SbVec3f::operator [](const int i) const 00109 { 00110 return this->vec[i]; 00111 } 00112 00113 #endif // !COIN_SBVEC3F_H
Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.
Generated on Mon Feb 28 2011 10:11:53 for Coin by Doxygen. 1.7.3