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

SbVec2f.h
1 #ifndef COIN_SBVEC2F_H
2 #define COIN_SBVEC2F_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 SbVec2d;
32 class SbVec2b;
33 class SbVec2s;
34 class SbVec2i32;
35 
36 class COIN_DLL_API SbVec2f {
37 public:
38  SbVec2f(void);
39  SbVec2f(const float v[2]);
40  SbVec2f(const float x, const float y);
41  explicit SbVec2f(const SbVec2d & v) { setValue(v); }
42  explicit SbVec2f(const SbVec2b & v) { setValue(v); }
43  explicit SbVec2f(const SbVec2s & v) { setValue(v); }
44  explicit SbVec2f(const SbVec2i32 & v) { setValue(v); }
45 
46  SbVec2f & setValue(const float v[2]);
47  SbVec2f & setValue(const float x, const float y);
48  SbVec2f & setValue(const SbVec2d & v);
49  SbVec2f & setValue(const SbVec2b & v);
50  SbVec2f & setValue(const SbVec2s & v);
51  SbVec2f & setValue(const SbVec2i32 & v);
52 
53  float dot(const SbVec2f & v) const;
54  SbBool equals(const SbVec2f & v, const float tolerance) const;
55  const float * getValue(void) const;
56  void getValue(float & x, float & y) const;
57  float length(void) const;
58  float sqrLength(void) const;
59  void negate(void);
60  float normalize(void);
61  float & operator [] (const int i);
62  const float & operator [] (const int i) const;
63  SbVec2f & operator *= (const float d);
64  SbVec2f & operator /= (const float d);
65  SbVec2f & operator += (const SbVec2f & u);
66  SbVec2f & operator -= (const SbVec2f & u);
67  SbVec2f operator-(void) const;
68 
69  friend COIN_DLL_API SbVec2f operator * (const SbVec2f & v, const float d);
70  friend COIN_DLL_API SbVec2f operator * (const float d, const SbVec2f & v);
71  friend COIN_DLL_API SbVec2f operator / (const SbVec2f & v, const float d);
72  friend COIN_DLL_API SbVec2f operator + (const SbVec2f & v1, const SbVec2f & v2);
73  friend COIN_DLL_API SbVec2f operator - (const SbVec2f & v1, const SbVec2f & v2);
74  friend COIN_DLL_API int operator == (const SbVec2f & v1, const SbVec2f & v2);
75  friend COIN_DLL_API int operator != (const SbVec2f & v1, const SbVec2f & v2);
76 
77  void print(FILE * fp) const;
78 
79 private:
80  float vec[2];
81 };
82 
83 COIN_DLL_API SbVec2f operator * (const SbVec2f & v, const float d);
84 COIN_DLL_API SbVec2f operator * (const float d, const SbVec2f & v);
85 COIN_DLL_API SbVec2f operator / (const SbVec2f & v, const float d);
86 COIN_DLL_API SbVec2f operator + (const SbVec2f & v1, const SbVec2f & v2);
87 COIN_DLL_API SbVec2f operator - (const SbVec2f & v1, const SbVec2f & v2);
88 COIN_DLL_API int operator == (const SbVec2f & v1, const SbVec2f & v2);
89 COIN_DLL_API int operator != (const SbVec2f & v1, const SbVec2f & v2);
90 
91 // *************************************************************************
92 
93 #endif // !COIN_SBVEC2F_H
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition: SbVec2f.h:36
The SbVec2b class is a 2 dimensional vector with 8-bit integer coordinates.
Definition: SbVec2b.h:37
SbVec2f(const SbVec2i32 &v)
Definition: SbVec2f.h:44
SbVec2f(const SbVec2s &v)
Definition: SbVec2f.h:43
int operator!=(const SbBox2i32 &b1, const SbBox2i32 &b2)
Definition: SbBox2i32.h:91
SbVec2f(const SbVec2d &v)
Definition: SbVec2f.h:41
The SbVec2d class is a 2 dimensional vector with double precision floating point coordinates.
Definition: SbVec2d.h:36
The SbVec2i32 class is a 2 dimensional vector with 32-bit integer coordinates.
Definition: SbVec2i32.h:39
The SbVec2s class is a 2 dimensional vector with short integer coordinates.This vector class is used ...
Definition: SbVec2s.h:37
SbVec2f(const SbVec2b &v)
Definition: SbVec2f.h:42
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