Vector3.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the VRender library.
3  Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr)
4  Version 1.0.0, released on June 27, 2005.
5 
6  http://artis.imag.fr/Members/Cyril.Soler/VRender
7 
8  VRender is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  VRender is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with VRender; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 
23 /****************************************************************************
24 
25  Copyright (C) 2002-2014 Gilles Debunne. All rights reserved.
26 
27  This file is part of the QGLViewer library version 2.6.3.
28 
29  http://www.libqglviewer.com - contact@libqglviewer.com
30 
31  This file may be used under the terms of the GNU General Public License
32  versions 2.0 or 3.0 as published by the Free Software Foundation and
33  appearing in the LICENSE file included in the packaging of this file.
34  In addition, as a special exception, Gilles Debunne gives you certain
35  additional rights, described in the file GPL_EXCEPTION in this package.
36 
37  libQGLViewer uses dual licensing. Commercial/proprietary software must
38  purchase a libQGLViewer Commercial License.
39 
40  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
41  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
42 
43 *****************************************************************************/
44 
45 #include <iostream>
46 #include "Vector3.h"
47 #include "NVector3.h"
48 #include <math.h>
49 #include <algorithm>
50 
51 #ifdef WIN32
52 # include <windows.h>
53 #endif
54 
55 using namespace vrender;
56 using namespace std;
57 
59 
61 {
62  _xyz[0] = 0.0;
63  _xyz[1] = 0.0;
64  _xyz[2] = 0.0;
65 }
66 
67 // -----------------------------------------------------------------------------
70 {
71 }
72 
73 // -----------------------------------------------------------------------------
76 {
77  setXYZ(u[0],u[1],u[2]);
78 }
79 
80 // -----------------------------------------------------------------------------
83 {
84  setXYZ(u[0],u[1],u[2]);
85 }
86 
87 // -----------------------------------------------------------------------------
89 Vector3::Vector3 (double x,double y,double z)
90 {
91  setXYZ(x,y,z);
92 }
93 // -----------------------------------------------------------------------------
96 {
97  _xyz[0] = u[0];
98  _xyz[1] = u[1];
99  _xyz[2] = u[2];
100  return ( *this );
101 }
102 
103 // -----------------------------------------------------------------------------
106 {
107  _xyz[0] += u[0];
108  _xyz[1] += u[1];
109  _xyz[2] += u[2];
110  return ( *this );
111 }
112 
113 // -----------------------------------------------------------------------------
116 {
117  _xyz[0] -= u[0];
118  _xyz[1] -= u[1];
119  _xyz[2] -= u[2];
120  return ( *this );
121 }
122 
123 // -----------------------------------------------------------------------------
125 Vector3 vrender::operator* (double r,const Vector3& u)
126 {
127  return ( Vector3(r*u[0], r*u[1], r*u[2]) );
128 }
129 
130 
131 // -----------------------------------------------------------------------------
133 double Vector3::norm () const
134 {
135  return sqrt( _xyz[0]*_xyz[0] + _xyz[1]*_xyz[1] + _xyz[2]*_xyz[2] );
136 }
137 
138 // -----------------------------------------------------------------------------
140 double Vector3::squareNorm () const
141 {
142  return _xyz[0]*_xyz[0] + _xyz[1]*_xyz[1] + _xyz[2]*_xyz[2];
143 }
144 
145 // -----------------------------------------------------------------------------
147 double Vector3::infNorm() const
148 {
149  return std::max(std::max(fabs(_xyz[0]),fabs(_xyz[1])),fabs(_xyz[2])) ;
150 }
151 
152 
153 // -----------------------------------------------------------------------------
155 std::ostream& vrender::operator<< (std::ostream& out,const Vector3& u)
156 {
157  out << u[0] << " " << u[1] << " " << u[2];
158  return ( out );
159 }
160 
161 Vector3 Vector3::mini(const Vector3& v1,const Vector3& v2)
162 {
163  return Vector3(std::min(v1[0],v2[0]),std::min(v1[1],v2[1]),std::min(v1[2],v2[2])) ;
164 }
165 
166 Vector3 Vector3::maxi(const Vector3& v1,const Vector3& v2)
167 {
168  return Vector3(std::max(v1[0],v2[0]),std::max(v1[1],v2[1]),std::max(v1[2],v2[2])) ;
169 }
170 
double squareNorm() const
Square norm (self dot product)
Definition: Vector3.cpp:140
#define FLT_MAX
Definition: Vector3.h:51
Vector3 & operator-=(const Vector3 &v)
Definition: Vector3.h:115
static Vector3 maxi(const Vector3 &, const Vector3 &)
Definition: Vector3.cpp:166
ostream & operator<<(ostream &o, const Quaternion &Q)
Definition: quaternion.cpp:528
static const Vector3 inf
Definition: Vector3.h:64
Vector2 operator*(double r, const Vector2 &u)
Left multiplication by a real value.
Definition: Vector2.cpp:102
static Vector3 mini(const Vector3 &, const Vector3 &)
Definition: Vector3.cpp:161
double infNorm() const
Infinite norm.
Definition: Vector3.cpp:147
Vector3 & operator=(const Vector3 &u)
Definition: Vector3.h:93
~Vector3()
Default destructor.
Definition: Vector3.cpp:69
Vector3 & operator+=(const Vector3 &v)
Definition: Vector3.h:107
double norm() const
Norm.
Definition: Vector3.cpp:133


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Wed Jun 5 2019 19:26:39