~ubuntu-branches/debian/sid/coin2/sid

« back to all changes in this revision

Viewing changes to src/base/SbVec2ui32.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-06-28 02:38:17 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080628023817-lgrh0u677j1gcqgf
Tags: 2.5.0-2
* debian/control: Change suggests from libopenal0 to libopenal0a.
  Closes: #488001.  Change ${Source-Version} to ${binary:Version}.
  Update to standards version 3.8.0.

* debian/rules: Do not ignore errors in clean rule.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************\
 
2
 *
 
3
 *  This file is part of the Coin 3D visualization library.
 
4
 *  Copyright (C) 1998-2007 by Systems in Motion.  All rights reserved.
 
5
 *
 
6
 *  This library is free software; you can redistribute it and/or
 
7
 *  modify it under the terms of the GNU General Public License
 
8
 *  ("GPL") version 2 as published by the Free Software Foundation.
 
9
 *  See the file LICENSE.GPL at the root directory of this source
 
10
 *  distribution for additional information about the GNU GPL.
 
11
 *
 
12
 *  For using Coin with software that can not be combined with the GNU
 
13
 *  GPL, and for taking advantage of the additional benefits of our
 
14
 *  support services, please contact Systems in Motion about acquiring
 
15
 *  a Coin Professional Edition License.
 
16
 *
 
17
 *  See http://www.coin3d.org/ for more information.
 
18
 *
 
19
 *  Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
 
20
 *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
 
21
 *
 
22
\**************************************************************************/
 
23
 
 
24
#include <Inventor/SbVec2ui32.h>
 
25
 
 
26
#include <Inventor/SbVec2i32.h>
 
27
#include <Inventor/SbVec2ub.h>
 
28
#include <Inventor/SbVec2us.h>
 
29
 
 
30
/*!
 
31
  \class SbVec2ui32 SbVec2ui32.h Inventor/SbVec2ui32.h
 
32
 
 
33
  \brief The SbVec2ub class is a 2 dimensional vector with unsigned
 
34
  32-bit integer coordinates.
 
35
  
 
36
  \ingroup base
 
37
  
 
38
  This vector provides storage for a vector in 2 dimensions as well as
 
39
  simple integer arithmetic operations.
 
40
 
 
41
  \sa SbVec3ui32, SbVec4ui32, SbVec2b, SbVec2ub, SbVec2s, SbVec2us, SbVec2i32
 
42
 
 
43
  \since Coin-2.5
 
44
*/
 
45
 
 
46
/*!
 
47
  Sets this vector to the 32-bit integer precision vector \a v
 
48
  converting the vector to an unsigned 32-bit integer precision vector.
 
49
*/
 
50
SbVec2ui32 &
 
51
SbVec2ui32::setValue(const SbVec2i32 & v)
 
52
{
 
53
  vec[0] = static_cast<uint32_t>(v[0]);
 
54
  vec[1] = static_cast<uint32_t>(v[1]);
 
55
  return *this;
 
56
}
 
57
 
 
58
/*!
 
59
  Sets this vector to the unsigned 8-bit integer precision vector \a v
 
60
  converting the vector to an unsigned 32-bit integer precision vector.
 
61
*/
 
62
SbVec2ui32 &
 
63
SbVec2ui32::setValue(const SbVec2ub & v)
 
64
{
 
65
  vec[0] = static_cast<uint32_t>(v[0]);
 
66
  vec[1] = static_cast<uint32_t>(v[1]);
 
67
  return *this;
 
68
}
 
69
 
 
70
/*!
 
71
  Sets this vector to the unsigned short integer precision vector \a v
 
72
  converting the vector to an unsigned 32-bit integer precision vector.
 
73
*/
 
74
SbVec2ui32 &
 
75
SbVec2ui32::setValue(const SbVec2us & v)
 
76
{
 
77
  vec[0] = static_cast<uint32_t>(v[0]);
 
78
  vec[1] = static_cast<uint32_t>(v[1]);
 
79
  return *this;
 
80
}
 
81
 
 
82
/*! 
 
83
  Negate the vector (i.e. point it in the opposite direction)
 
84
*/
 
85
void
 
86
SbVec2ui32::negate(void)
 
87
{
 
88
  vec[0] = static_cast<uint32_t>(0-vec[0]);
 
89
  vec[1] = static_cast<uint32_t>(0-vec[1]);
 
90
}
 
91
 
 
92
/*!
 
93
  Multiply components of vector with scalar value \a d. Returns
 
94
  reference to self.
 
95
*/
 
96
SbVec2ui32 &
 
97
SbVec2ui32::operator *= (double d)
 
98
{
 
99
  vec[0] = static_cast<uint32_t>(vec[0] * d);
 
100
  vec[1] = static_cast<uint32_t>(vec[1] * d);
 
101
  return *this;
 
102
}
 
103
 
 
104
/*!  
 
105
  \fn SbVec2ui32::SbVec2ui32(void)
 
106
 
 
107
  The default constructor does nothing. The vector coordinates will be
 
108
  uninitialized until you do a setValue().
 
109
*/
 
110
 
 
111
/*!  
 
112
  \fn SbVec2ui32::SbVec2ui32(const uint32_t v[2])
 
113
  
 
114
  Constructs an SbVec2ui32 instance with initial values from \a v.
 
115
*/
 
116
 
 
117
/*!  
 
118
  \fn SbVec2ui32::SbVec2ui32(uint32_t x, uint32_t y)
 
119
 
 
120
  Constructs an SbVec2ui32 instance with the initial vector endpoint set
 
121
  to \a <x,y>.
 
122
*/
 
123
 
 
124
/*!  
 
125
  \fn explicit SbVec2ui32::SbVec2ui32(const SbVec2i32 & v)
 
126
 
 
127
  Constructs an SbVec2ui32 instance with initial values from the
 
128
  32-bit integer precision vector \a v.
 
129
*/
 
130
 
 
131
/*!  
 
132
  \fn explicit SbVec2ui32::SbVec2ui32(const SbVec2ub & v)
 
133
 
 
134
  Constructs an SbVec2ui32 instance with initial values from the
 
135
  unsigned 8-bit vector \a v.
 
136
*/
 
137
 
 
138
/*!  
 
139
  \fn explicit SbVec2ui32::SbVec2ui32(const SbVec2us & v)
 
140
  
 
141
  Constructs an SbVec2ui32 instance with initial values from the
 
142
  unsigned short integer precision vector \a v.
 
143
*/
 
144
 
 
145
/*!  
 
146
  \fn SbVec2ui32 & SbVec2ui32::setValue(const uint32_t v[2])
 
147
 
 
148
  Set new coordinates for the vector from \a v. Returns reference to
 
149
  self.
 
150
 
 
151
  \sa getValue()
 
152
*/
 
153
 
 
154
/*!  
 
155
  \fn SbVec2ui32 & SbVec2ui32::setValue(uint32_t x, uint32_t y)
 
156
 
 
157
  Set new coordinates for the vector. Returns reference to self.
 
158
 
 
159
  \sa getValue()
 
160
*/
 
161
 
 
162
/*!  
 
163
  \fn const uint32_t * SbVec2ui32::getValue(void) const
 
164
 
 
165
  Returns a pointer to an array of two unsigned 32-bit integers
 
166
  containing the x and y coordinates of the vector.
 
167
 
 
168
  \sa setValue()
 
169
*/
 
170
 
 
171
/*!  
 
172
  \fn void SbVec2ui32::getValue(uint32_t & x, uint32_t & y) const 
 
173
  
 
174
  Returns the x and y coordinates of the vector.
 
175
 
 
176
  \sa setValue()
 
177
*/
 
178
 
 
179
/*!  
 
180
  \fn uint32_t & SbVec2ui32::operator [] (int i) 
 
181
 
 
182
  Index operator. Returns modifiable x or y coordinate of the vector.
 
183
 
 
184
  \sa getValue() and setValue()
 
185
*/
 
186
 
 
187
/*!  
 
188
  \fn const uint32_t & SbVec2ui32::operator [] (int i) const
 
189
 
 
190
  Index operator. Returns non-modifiable x or y coordinate of the
 
191
  vector.
 
192
 
 
193
  \sa getValue() and setValue()
 
194
*/
 
195
 
 
196
/*!  
 
197
  \fn int32_t SbVec2ui32::dot(const SbVec2ui32 & v) const 
 
198
 
 
199
  Calculates and returns the result of taking the dot product of this
 
200
  vector and \a v.
 
201
*/
 
202
 
 
203
/*!  
 
204
  \fn SbVec2ui32 & SbVec2ui32::operator *= (int d)
 
205
 
 
206
  Multiply components of vector with scalar value \a d. Returns
 
207
  reference to self.
 
208
*/
 
209
 
 
210
/*!  
 
211
  \fn SbVec2ui32 & SbVec2ui32::operator /= (int d) 
 
212
 
 
213
  Divides components of vector with scalar value \a d. Returns
 
214
  reference to self.
 
215
*/
 
216
 
 
217
/*!  
 
218
  \fn SbVec2ui32 & SbVec2ui32::operator /= (double d) 
 
219
 
 
220
  Divides components of vector with double precision floating point
 
221
  value \a d. Returns reference to self.
 
222
*/
 
223
 
 
224
/*!  
 
225
  \fn SbVec2ui32 & SbVec2ui32::operator += (const SbVec2ui32 & v)
 
226
 
 
227
  Adds this vector and vector \a u. Returns reference to self.
 
228
*/
 
229
 
 
230
/*!  
 
231
  \fn SbVec2ui32 & SbVec2ui32::operator -= (const SbVec2ui32 & v)
 
232
 
 
233
  Subtracts vector \a u from this vector. Returns reference to self.
 
234
*/
 
235
 
 
236
/*!  
 
237
  \fn SbVec2ui32 SbVec2ui32::operator - (void) const 
 
238
 
 
239
  Non-destructive negation operator. Returns a new SbVec3f instance
 
240
  which points in the opposite direction of this vector.
 
241
 
 
242
  \sa negate()
 
243
*/