Vector3.cpp
Go to the documentation of this file.
00001 /*
00002  This file is part of the VRender library.
00003  Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr)
00004  Version 1.0.0, released on June 27, 2005.
00005 
00006  http://artis.imag.fr/Members/Cyril.Soler/VRender
00007 
00008  VRender is free software; you can redistribute it and/or modify
00009  it under the terms of the GNU General Public License as published by
00010  the Free Software Foundation; either version 2 of the License, or
00011  (at your option) any later version.
00012 
00013  VRender is distributed in the hope that it will be useful,
00014  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  GNU General Public License for more details.
00017 
00018  You should have received a copy of the GNU General Public License
00019  along with VRender; if not, write to the Free Software Foundation, Inc.,
00020  51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
00021 */
00022 
00023 /****************************************************************************
00024 
00025  Copyright (C) 2002-2013 Gilles Debunne. All rights reserved.
00026 
00027  This file is part of the QGLViewer library version 2.4.0.
00028 
00029  http://www.libqglviewer.com - contact@libqglviewer.com
00030 
00031  This file may be used under the terms of the GNU General Public License 
00032  versions 2.0 or 3.0 as published by the Free Software Foundation and
00033  appearing in the LICENSE file included in the packaging of this file.
00034  In addition, as a special exception, Gilles Debunne gives you certain 
00035  additional rights, described in the file GPL_EXCEPTION in this package.
00036 
00037  libQGLViewer uses dual licensing. Commercial/proprietary software must
00038  purchase a libQGLViewer Commercial License.
00039 
00040  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00041  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00042 
00043 *****************************************************************************/
00044 
00045 #include <iostream>
00046 #include "Vector3.h"
00047 #include "NVector3.h"
00048 #include <math.h>
00049 
00050 #ifdef WIN32
00051 # include <windows.h>
00052 #endif
00053 
00054 using namespace vrender;
00055 using namespace std;
00056 
00057 const Vector3 Vector3::inf(FLT_MAX, FLT_MAX, FLT_MAX); 
00058 
00059 Vector3::Vector3 ()
00060 {
00061   _xyz[0] = 0.0;
00062   _xyz[1] = 0.0;
00063   _xyz[2] = 0.0;
00064 }
00065 
00066 // -----------------------------------------------------------------------------
00068 Vector3::~Vector3 ()
00069 {
00070 }
00071 
00072 // -----------------------------------------------------------------------------
00074 Vector3::Vector3 (const Vector3& u)
00075 {
00076   setXYZ(u[0],u[1],u[2]);
00077 }
00078 
00079 // -----------------------------------------------------------------------------
00081 Vector3::Vector3 (const NVector3& u)
00082 {
00083   setXYZ(u[0],u[1],u[2]);
00084 }
00085 
00086 // -----------------------------------------------------------------------------
00088 Vector3::Vector3 (double x,double y,double z)
00089 {
00090   setXYZ(x,y,z);
00091 }
00092 // -----------------------------------------------------------------------------
00094 Vector3& Vector3::operator= (const NVector3& u)
00095 {
00096   _xyz[0] = u[0];
00097   _xyz[1] = u[1];
00098   _xyz[2] = u[2];
00099   return ( *this );
00100 }
00101 
00102 // -----------------------------------------------------------------------------
00104 Vector3& Vector3::operator+= (const NVector3& u)
00105 {
00106   _xyz[0] += u[0];
00107   _xyz[1] += u[1];
00108   _xyz[2] += u[2];
00109   return ( *this );
00110 }
00111 
00112 // -----------------------------------------------------------------------------
00114 Vector3& Vector3::operator-= (const NVector3& u)
00115 {
00116   _xyz[0] -= u[0];
00117   _xyz[1] -= u[1];
00118   _xyz[2] -= u[2];
00119   return ( *this );
00120 }
00121 
00122 // -----------------------------------------------------------------------------
00124 Vector3 vrender::operator* (double r,const Vector3& u)
00125 {
00126   return ( Vector3(r*u[0], r*u[1], r*u[2]) );
00127 }
00128 
00129 
00130 // -----------------------------------------------------------------------------
00132 double Vector3::norm () const
00133 {
00134   return sqrt( _xyz[0]*_xyz[0] + _xyz[1]*_xyz[1] + _xyz[2]*_xyz[2] );
00135 }
00136 
00137 // -----------------------------------------------------------------------------
00139 double Vector3::squareNorm () const
00140 {
00141   return _xyz[0]*_xyz[0] + _xyz[1]*_xyz[1] + _xyz[2]*_xyz[2];
00142 }
00143 
00144 // -----------------------------------------------------------------------------
00146 double Vector3::infNorm() const
00147 {
00148   return max(max(fabs(_xyz[0]),fabs(_xyz[1])),fabs(_xyz[2])) ;
00149 }
00150 
00151 
00152 // -----------------------------------------------------------------------------
00154 std::ostream& vrender::operator<< (std::ostream& out,const Vector3& u)
00155 {
00156   out << u[0] << " " << u[1] << " " << u[2];
00157   return ( out );
00158 }
00159 
00160 Vector3 Vector3::mini(const Vector3& v1,const Vector3& v2)
00161 {
00162   return Vector3(min(v1[0],v2[0]),min(v1[1],v2[1]),min(v1[2],v2[2])) ;
00163 }
00164 
00165 Vector3 Vector3::maxi(const Vector3& v1,const Vector3& v2)
00166 {
00167   return Vector3(max(v1[0],v2[0]),max(v1[1],v2[1]),max(v1[2],v2[2])) ;
00168 }
00169 


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Jun 6 2019 17:31:58