Coin Logo http://www.sim.no
http://www.coin3d.org

SbVec3f.h
1 #ifndef COIN_SBVEC3F_H
2 #define COIN_SBVEC3F_H
3 
4 /**************************************************************************\
5  *
6  * This file is part of the Coin 3D visualization library.
7  * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.GPL at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using Coin with software that can not be combined with the GNU
16  * GPL, and for taking advantage of the additional benefits of our
17  * support services, please contact Systems in Motion about acquiring
18  * a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
23  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24  *
25 \**************************************************************************/
26 
27 #include <stdio.h>
28 
29 #include <Inventor/SbBasic.h>
30 
31 class SbPlane;
32 class SbVec3d;
33 class SbVec3b;
34 class SbVec3s;
35 class SbVec3i32;
36 
37 class COIN_DLL_API SbVec3f {
38 public:
39  SbVec3f(void) { }
40  SbVec3f(const float v[3]);
41  SbVec3f(const float x, const float y, const float z);
42  SbVec3f(const SbPlane & p0, const SbPlane & p1, const SbPlane & p2);
43  SbVec3f(const SbVec3d & v);
44  explicit SbVec3f(const SbVec3b & v) { setValue(v); }
45  explicit SbVec3f(const SbVec3s & v) { setValue(v); }
46  explicit SbVec3f(const SbVec3i32 & v) { setValue(v); }
47 
48  SbVec3f & setValue(const float v[3]);
49  SbVec3f & setValue(const float x, const float y, const float z);
50  SbVec3f & setValue(const SbVec3f & barycentric,
51  const SbVec3f & v0,
52  const SbVec3f & v1,
53  const SbVec3f & v2);
54  SbVec3f & setValue(const SbVec3d & v);
55  SbVec3f & setValue(const SbVec3b & v);
56  SbVec3f & setValue(const SbVec3s & v);
57  SbVec3f & setValue(const SbVec3i32 & v);
58 
59  SbVec3f cross(const SbVec3f & v) const;
60  float dot(const SbVec3f & v) const;
61  SbBool equals(const SbVec3f & v, const float tolerance) const;
62  SbVec3f getClosestAxis(void) const;
63  const float * getValue(void) const;
64  void getValue(float & x, float & y, float & z) const;
65  float length(void) const;
66  float sqrLength() const;
67  void negate(void);
68  float normalize(void);
69  float & operator [](const int i);
70  const float & operator [](const int i) const;
71  SbVec3f & operator *=(const float d);
72  SbVec3f & operator /=(const float d);
73  SbVec3f & operator +=(const SbVec3f & u);
74  SbVec3f & operator -=(const SbVec3f & u);
75  SbVec3f operator-(void) const;
76  friend COIN_DLL_API SbVec3f operator *(const SbVec3f & v, const float d);
77  friend COIN_DLL_API SbVec3f operator *(const float d, const SbVec3f & v);
78  friend COIN_DLL_API SbVec3f operator /(const SbVec3f & v, const float d);
79  friend COIN_DLL_API SbVec3f operator +(const SbVec3f & v1, const SbVec3f & v2);
80  friend COIN_DLL_API SbVec3f operator -(const SbVec3f & v1, const SbVec3f & v2);
81  friend COIN_DLL_API int operator ==(const SbVec3f & v1, const SbVec3f & v2);
82  friend COIN_DLL_API int operator !=(const SbVec3f & v1, const SbVec3f & v2);
83 
84  void print(FILE * fp) const;
85 
86 private:
87  float vec[3];
88 };
89 
90 COIN_DLL_API SbVec3f operator *(const SbVec3f & v, const float d);
91 COIN_DLL_API SbVec3f operator *(const float d, const SbVec3f & v);
92 COIN_DLL_API SbVec3f operator /(const SbVec3f & v, const float d);
93 COIN_DLL_API SbVec3f operator +(const SbVec3f & v1, const SbVec3f & v2);
94 COIN_DLL_API SbVec3f operator -(const SbVec3f & v1, const SbVec3f & v2);
95 COIN_DLL_API int operator ==(const SbVec3f & v1, const SbVec3f & v2);
96 COIN_DLL_API int operator !=(const SbVec3f & v1, const SbVec3f & v2);
97 
98 
99 /* inlined methods ********************************************************/
100 
101 inline float &
103 {
104  return this->vec[i];
105 }
106 
107 inline const float &
108 SbVec3f::operator [](const int i) const
109 {
110  return this->vec[i];
111 }
112 
113 #endif // !COIN_SBVEC3F_H
SbVec3f(void)
Definition: SbVec3f.h:39
The SbVec3d class is a 3 dimensional vector with double precision floating point coordinates.
Definition: SbVec3d.h:35
SbVec3f(const SbVec3i32 &v)
Definition: SbVec3f.h:46
The SbVec3s class is a 3 dimensional vector with short integer coordinates.
Definition: SbVec3s.h:36
SbVec3f(const SbVec3s &v)
Definition: SbVec3f.h:45
int operator!=(const SbBox2i32 &b1, const SbBox2i32 &b2)
Definition: SbBox2i32.h:91
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition: SbVec3f.h:37
SbVec3f(const SbVec3b &v)
Definition: SbVec3f.h:44
float & operator[](const int i)
Definition: SbVec3f.h:102
The SbVec3b class is a 3 dimensional vector with 8-bit integer coordinates.
Definition: SbVec3b.h:37
The SbVec3i32 class is a 3 dimensional vector with 32-bit integer coordinates.
Definition: SbVec3i32.h:39
The SbPlane class represents a plane in 3D space.SbPlane is used by many other classes in Coin...
Definition: SbPlane.h:34
int operator==(const SbBox2i32 &b1, const SbBox2i32 &b2)
Definition: SbBox2i32.h:87

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Fri Jul 20 2018 for Coin by Doxygen. 1.8.14