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

SbVec3d.h
1#ifndef COIN_SBVEC3D_H
2#define COIN_SBVEC3D_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#include <Inventor/SbBasic.h>
29
30class SbVec3f;
31class SbVec3b;
32class SbVec3s;
33class SbVec3i32;
34
35class COIN_DLL_API SbVec3d {
36public:
37 SbVec3d(void) { }
38 SbVec3d(const double v[3]);
39 SbVec3d(const double x, const double y, const double z);
40 SbVec3d(const SbVec3f & v);
41 explicit SbVec3d(const SbVec3b & v) { setValue(v); }
42 explicit SbVec3d(const SbVec3s & v) { setValue(v); }
43 explicit SbVec3d(const SbVec3i32 & v) { setValue(v); }
44
45 SbVec3d & setValue(const double v[3]);
46 SbVec3d & setValue(const double x, const double y, const double z);
47 SbVec3d & setValue(const SbVec3d & barycentric,
48 const SbVec3d & v0,
49 const SbVec3d & v1,
50 const SbVec3d & v2);
51 SbVec3d & setValue(const SbVec3f & v);
52 SbVec3d & setValue(const SbVec3b & v);
53 SbVec3d & setValue(const SbVec3s & v);
54 SbVec3d & setValue(const SbVec3i32 & v);
55
56 SbVec3d cross(const SbVec3d & v) const;
57 double dot(const SbVec3d & v) const;
58 SbBool equals(const SbVec3d & v, const double tolerance) const;
59 SbVec3d getClosestAxis(void) const;
60 const double * getValue(void) const;
61 void getValue(double & x, double & y, double & z) const;
62 double length(void) const;
63 double sqrLength() const;
64 void negate(void);
65 double normalize(void);
66 double & operator [](const int i);
67 const double & operator [](const int i) const;
68 SbVec3d & operator *=(const double d);
69 SbVec3d & operator /=(const double d);
70 SbVec3d & operator +=(const SbVec3d & u);
71 SbVec3d & operator -=(const SbVec3d & u);
72 SbVec3d operator -(void) const;
73 friend COIN_DLL_API SbVec3d operator *(const SbVec3d & v, const double d);
74 friend COIN_DLL_API SbVec3d operator *(const double d, const SbVec3d & v);
75 friend COIN_DLL_API SbVec3d operator /(const SbVec3d & v, const double d);
76 friend COIN_DLL_API SbVec3d operator +(const SbVec3d & v1, const SbVec3d & v2);
77 friend COIN_DLL_API SbVec3d operator -(const SbVec3d & v1, const SbVec3d & v2);
78 friend COIN_DLL_API int operator ==(const SbVec3d & v1, const SbVec3d & v2);
79 friend COIN_DLL_API int operator !=(const SbVec3d & v1, const SbVec3d & v2);
80
81 void print(FILE * fp) const;
82
83private:
84 double vec[3];
85};
86
87COIN_DLL_API SbVec3d operator *(const SbVec3d & v, const double d);
88COIN_DLL_API SbVec3d operator *(const double d, const SbVec3d & v);
89COIN_DLL_API SbVec3d operator /(const SbVec3d & v, const double d);
90COIN_DLL_API SbVec3d operator +(const SbVec3d & v1, const SbVec3d & v2);
91COIN_DLL_API SbVec3d operator -(const SbVec3d & v1, const SbVec3d & v2);
92COIN_DLL_API int operator ==(const SbVec3d & v1, const SbVec3d & v2);
93COIN_DLL_API int operator !=(const SbVec3d & v1, const SbVec3d & v2);
94
95
96/* inlined methods ********************************************************/
97
98inline double &
100{
101 return this->vec[i];
102}
103
104inline const double &
105SbVec3d::operator [](const int i) const
106{
107 return this->vec[i];
108}
109
110#endif // !COIN_SBVEC3D_H
int operator==(const SbBox2s &b1, const SbBox2s &b2)
Definition: SbBox2s.cpp:432
int operator!=(const SbBox2s &b1, const SbBox2s &b2)
Definition: SbBox2s.cpp:443
SbMatrix operator*(const SbMatrix &m1, const SbMatrix &m2)
Definition: SbMatrix.cpp:690
SbTime operator+(const SbTime &t0, const SbTime &t1)
Definition: SbTime.cpp:762
SbTime operator/(const SbTime &tm, const double s)
Definition: SbTime.cpp:841
SbTime operator-(const SbTime &t0, const SbTime &t1)
Definition: SbTime.cpp:775
The SbVec3b class is a 3 dimensional vector with 8-bit integer coordinates.
Definition: SbVec3b.h:37
The SbVec3d class is a 3 dimensional vector with double precision floating point coordinates.
Definition: SbVec3d.h:35
SbVec3d(const SbVec3b &v)
Definition: SbVec3d.h:41
SbVec3d(const SbVec3s &v)
Definition: SbVec3d.h:42
double & operator[](const int i)
Definition: SbVec3d.h:99
SbVec3d(void)
Definition: SbVec3d.h:37
SbVec3d(const SbVec3i32 &v)
Definition: SbVec3d.h:43
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition: SbVec3f.h:37
The SbVec3i32 class is a 3 dimensional vector with 32-bit integer coordinates.
Definition: SbVec3i32.h:39
The SbVec3s class is a 3 dimensional vector with short integer coordinates.
Definition: SbVec3s.h:36

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

Generated on Wed Jul 20 2022 for Coin by Doxygen. 1.9.4