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

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
35class SbVec2ui32;
36class SbVec2b;
37class SbVec2s;
38class SbVec2f;
39class SbVec2d;
40
41class COIN_DLL_API SbVec2i32 {
42public:
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
79protected:
80 int32_t vec[2];
81
82}; // SbVec2i32
83
84COIN_DLL_API inline SbVec2i32 operator * (const SbVec2i32 & v, int d) {
85 SbVec2i32 val(v); val *= d; return val;
86}
87
88COIN_DLL_API inline SbVec2i32 operator * (const SbVec2i32 & v, double d) {
89 SbVec2i32 val(v); val *= d; return val;
90}
91
92COIN_DLL_API inline SbVec2i32 operator * (int d, const SbVec2i32 & v) {
93 SbVec2i32 val(v); val *= d; return val;
94}
95
96COIN_DLL_API inline SbVec2i32 operator * (double d, const SbVec2i32 & v) {
97 SbVec2i32 val(v); val *= d; return val;
98}
99
100COIN_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
105COIN_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
110COIN_DLL_API inline SbVec2i32 operator + (const SbVec2i32 & v1, const SbVec2i32 & v2) {
111 SbVec2i32 v(v1); v += v2; return v;
112}
113
114COIN_DLL_API inline SbVec2i32 operator - (const SbVec2i32 & v1, const SbVec2i32 & v2) {
115 SbVec2i32 v(v1); v -= v2; return v;
116}
117
118COIN_DLL_API inline int operator == (const SbVec2i32 & v1, const SbVec2i32 & v2) {
119 return ((v1[0] == v2[0]) && (v1[1] == v2[1]));
120}
121
122COIN_DLL_API inline int operator != (const SbVec2i32& v1, const SbVec2i32& v2) {
123 return !(v1 == v2);
124}
125
126#endif // !COIN_SBVEC2I32_H
a vector class for containing two byte integers.
Definition SbVec2b.h:39
The SbVec2d class is a 2 dimensional vector with double precision floating point coordinates.
Definition SbVec2d.h:39
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition SbVec2f.h:39
The SbVec2i32 class is a 2 dimensional vector with short integer coordinates.
Definition SbVec2i32.h:41
void getValue(int32_t &x, int32_t &y) const
Definition SbVec2i32.h:61
SbVec2i32(const SbVec2s &v)
Definition SbVec2i32.h:48
SbVec2i32(const SbVec2f &v)
Definition SbVec2i32.h:49
SbVec2i32(void)
Definition SbVec2i32.h:43
SbVec2i32(int32_t x, int32_t y)
Definition SbVec2i32.h:45
int32_t dot(const SbVec2i32 &v) const
Definition SbVec2i32.h:66
void negate(void)
Definition SbVec2i32.h:67
SbVec2i32 & setValue(const int32_t v[2])
Definition SbVec2i32.h:52
const int32_t * getValue(void) const
Definition SbVec2i32.h:60
SbVec2i32(const SbVec2d &v)
Definition SbVec2i32.h:50
SbVec2i32(const SbVec2ui32 &v)
Definition SbVec2i32.h:46
SbVec2i32 & setValue(int32_t x, int32_t y)
Definition SbVec2i32.h:53
SbVec2i32(const int32_t v[2])
Definition SbVec2i32.h:44
SbVec2i32(const SbVec2b &v)
Definition SbVec2i32.h:47
The SbVec2s class is a 2 dimensional vector with short integer coordinates.
Definition SbVec2s.h:41
Definition SbVec2ui32.h:37

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

Generated on Wed Jul 17 2024 for Coin by Doxygen 1.12.0.