SbVec2i32.h Source File

| http://www.sim.no/ http://www.coin3d.org/

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

SbVec2i32.h
1 #ifndef COIN_SBVEC2I32_H
2 #define COIN_SBVEC2I32_H
3
4 /**************************************************************************\
5 *
6 * This file is part of the Coin 3D visualization library.
7 * Copyright (C) by Kongsberg Oil & Gas Technologies.
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 Kongsberg Oil & Gas Technologies
18 * about acquiring a Coin Professional Edition License.
19 *
20 * See http://www.coin3d.org/ for more information.
21 *
22 * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, 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 #include <Inventor/system/inttypes.h>
31 #ifndef NDEBUG
32 #include <Inventor/errors/SoDebugError.h>
33 #endif // !NDEBUG
34
35 class SbVec2ui32;
36 class SbVec2b;
37 class SbVec2s;
38 class SbVec2f;
39 class SbVec2d;
40
41 class COIN_DLL_API SbVec2i32 {
42 public:
43 SbVec2i32(void) { }
44 SbVec2i32(const int32_t v[2]) { vec[0] = v[0]; vec[1] = v[1]; }
45 SbVec2i32(int32_t x, int32_t y) { vec[0] = x; vec[1] = y; }
46 explicit SbVec2i32(const SbVec2ui32 & v) { setValue(v); }
47 explicit SbVec2i32(const SbVec2b & v) { setValue(v); }
48 explicit SbVec2i32(const SbVec2s & v) { setValue(v); }
49 explicit SbVec2i32(const SbVec2f & v) { setValue(v); }
50 explicit SbVec2i32(const SbVec2d & v) { setValue(v); }
51
52 SbVec2i32 & setValue(const int32_t v[2]) { vec[0] = v[0]; vec[1] = v[1]; return *this; }
53 SbVec2i32 & setValue(int32_t x, int32_t y) { vec[0] = x; vec[1] = y; return *this; }
54 SbVec2i32 & setValue(const SbVec2ui32 & v);
55 SbVec2i32 & setValue(const SbVec2b & v);
56 SbVec2i32 & setValue(const SbVec2s & v);
57 SbVec2i32 & setValue(const SbVec2f & v);
58 SbVec2i32 & setValue(const SbVec2d & v);
59
60 const int32_t * getValue(void) const { return vec; }
61 void getValue(int32_t & x, int32_t & y) const { x = vec[0]; y = vec[1]; }
62
63 int32_t & operator [] (const int i) { return vec[i]; }
64 const int32_t & operator [] (const int i) const { return vec[i]; }
65
66 int32_t dot(const SbVec2i32 & v) const { return vec[0] * v[0] + vec[1] * v[1]; }
67 void negate(void) { vec[0] = -vec[0]; vec[1] = -vec[1]; }
68
69 SbVec2i32 & operator *= (int d) { vec[0] *= d; vec[1] *= d; return *this; }
70 SbVec2i32 & operator *= (double d);
71 SbVec2i32 & operator /= (int d) { SbDividerChk("SbVec2i32::operator/=(int)", d); vec[0] /= d; vec[1] /= d; return *this; }
72 SbVec2i32 & operator /= (double d) { SbDividerChk("SbVec2i32::operator/=(double)", d); return operator *= (1.0 / d); }
73 SbVec2i32 & operator += (const SbVec2i32 & v) { vec[0] += v[0]; vec[1] += v[1]; return *this; }
74 SbVec2i32 & operator -= (const SbVec2i32 & v) { vec[0] -= v[0]; vec[1] -= v[1]; return *this; }
75 SbVec2i32 operator - (void) const { return SbVec2i32(-vec[0], -vec[1]); }
76
77 void print(FILE * fp) const;
78
79 protected:
80 int32_t vec[2];
81
82 }; // SbVec2i32
83
84 COIN_DLL_API inline SbVec2i32 operator * (const SbVec2i32 & v, int d) {
85 SbVec2i32 val(v); val *= d; return val;
86 }
87
88 COIN_DLL_API inline SbVec2i32 operator * (const SbVec2i32 & v, double d) {
89 SbVec2i32 val(v); val *= d; return val;
90 }
91
92 COIN_DLL_API inline SbVec2i32 operator * (int d, const SbVec2i32 & v) {
93 SbVec2i32 val(v); val *= d; return val;
94 }
95
96 COIN_DLL_API inline SbVec2i32 operator * (double d, const SbVec2i32 & v) {
97 SbVec2i32 val(v); val *= d; return val;
98 }
99
100 COIN_DLL_API inline SbVec2i32 operator / (const SbVec2i32 & v, int d) {
101 SbDividerChk("operator/(SbVec2i32,int)", d);
102 SbVec2i32 val(v); val /= d; return val;
103 }
104
105 COIN_DLL_API inline SbVec2i32 operator / (const SbVec2i32 & v, double d) {
106 SbDividerChk("operator/(SbVec2i32,double)", d);
107 SbVec2i32 val(v); val /= d; return val;
108 }
109
110 COIN_DLL_API inline SbVec2i32 operator + (const SbVec2i32 & v1, const SbVec2i32 & v2) {
111 SbVec2i32 v(v1); v += v2; return v;
112 }
113
114 COIN_DLL_API inline SbVec2i32 operator - (const SbVec2i32 & v1, const SbVec2i32 & v2) {
115 SbVec2i32 v(v1); v -= v2; return v;
116 }
117
118 COIN_DLL_API inline int operator == (const SbVec2i32 & v1, const SbVec2i32 & v2) {
119 return ((v1[0] == v2[0]) && (v1[1] == v2[1]));
120 }
121
122 COIN_DLL_API inline int operator != (const SbVec2i32& v1, const SbVec2i32& v2) {
123 return !(v1 == v2);
124 }
125
126 #endif // !COIN_SBVEC2I32_H
SbVec2f
The SbVec2f class is a 2 dimensional vector with floating point coordinates.This vector class is used...
Definition: SbVec2f.h:39
SbVec2i32::SbVec2i32
SbVec2i32(const SbVec2ui32 &v)
Definition: SbVec2i32.h:46
SbVec2i32::SbVec2i32
SbVec2i32(const SbVec2b &v)
Definition: SbVec2i32.h:47
SbVec2i32::SbVec2i32
SbVec2i32(const SbVec2s &v)
Definition: SbVec2i32.h:48
SbVec2b
a vector class for containing two byte integers.
Definition: SbVec2b.h:39
SbBox2d::operator!=
int operator!=(const SbBox2d &b1, const SbBox2d &b2)
Definition: SbBox2d.h:92
SbBox2d::operator==
int operator==(const SbBox2d &b1, const SbBox2d &b2)
Definition: SbBox2d.h:88
SbVec2i32::negate
void negate(void)
Definition: SbVec2i32.h:67
SbVec2ui32
Definition: SbVec2ui32.h:37
SbVec2i32::getValue
const int32_t * getValue(void) const
Definition: SbVec2i32.h:60
SbVec2i32::SbVec2i32
SbVec2i32(const SbVec2f &v)
Definition: SbVec2i32.h:49
SbVec2i32::getValue
void getValue(int32_t &x, int32_t &y) const
Definition: SbVec2i32.h:61
SbVec2i32::SbVec2i32
SbVec2i32(int32_t x, int32_t y)
Definition: SbVec2i32.h:45
SbVec2d
The SbVec2d class is a 2 dimensional vector with double precision floating point coordinates.This vector class is used by many other classes in Coin. It provides storage for a vector in 2 dimensions aswell as simple floating point arithmetic operations on this vector.
Definition: SbVec2d.h:39
SbVec2d::operator*
SbVec2d operator*(const SbVec2d &v, double d)
Definition: SbVec2d.h:82
SbVec2d::operator-
SbVec2d operator-(const SbVec2d &v1, const SbVec2d &v2)
Definition: SbVec2d.h:99
SbVec2i32
The SbVec2i32 class is a 2 dimensional vector with short integer coordinates.This vector class is use...
Definition: SbVec2i32.h:41
SbVec2i32::SbVec2i32
SbVec2i32(const int32_t v[2])
Definition: SbVec2i32.h:44
SbVec2d::operator/
SbVec2d operator/(const SbVec2d &v, double d)
Definition: SbVec2d.h:90
SbVec2i32::dot
int32_t dot(const SbVec2i32 &v) const
Definition: SbVec2i32.h:66
SbVec2i32::SbVec2i32
SbVec2i32(const SbVec2d &v)
Definition: SbVec2i32.h:50
SbVec2d::operator+
SbVec2d operator+(const SbVec2d &v1, const SbVec2d &v2)
Definition: SbVec2d.h:95
SbVec2i32::setValue
SbVec2i32 & setValue(const int32_t v[2])
Definition: SbVec2i32.h:52
SbVec2i32::setValue
SbVec2i32 & setValue(int32_t x, int32_t y)
Definition: SbVec2i32.h:53
SbVec2s
The SbVec2s class is a 2 dimensional vector with short integer coordinates.This vector class is used ...
Definition: SbVec2s.h:41
SbVec2i32::SbVec2i32
SbVec2i32(void)
Definition: SbVec2i32.h:43

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.