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

« back to all changes in this revision

Viewing changes to src/base/SbVec4ub.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/SbVec4ub.h>
 
25
 
 
26
#include <Inventor/SbVec4b.h>
 
27
#include <Inventor/SbVec4us.h>
 
28
#include <Inventor/SbVec4ui32.h>
 
29
 
 
30
/*!
 
31
  \class SbVec4ub SbVec4ub.h Inventor/SbVec4ub.h
 
32
 
 
33
  \brief The SbVec4ub class is a 4 dimensional vector with unsigned
 
34
  8-bit integer coordinates.
 
35
 
 
36
  \ingroup base
 
37
 
 
38
  This vector class provides storage for a 3 dimensional homogeneoues
 
39
  vector (with the 4 components usually referred to as <x, y, z, w>)
 
40
  aswell as simple integer precision arithmetic operations.
 
41
 
 
42
  \sa SbVec2ub, SbVec3ub, SbVec4b, SbVec4s, SbVec4us, SbVec4i32, SbVec4ui32
 
43
 
 
44
  \since Coin-2.5
 
45
*/
 
46
 
 
47
/*!  
 
48
  Sets this vector to the 8-bit integer precision vector \a v,
 
49
  converting the vector to a unsigned 8-bit integer precision vector.
 
50
*/
 
51
SbVec4ub &
 
52
SbVec4ub::setValue(const SbVec4b & v)
 
53
{
 
54
  vec[0] = static_cast<uint8_t>(v[0]);
 
55
  vec[1] = static_cast<uint8_t>(v[1]);
 
56
  vec[2] = static_cast<uint8_t>(v[2]);
 
57
  vec[3] = static_cast<uint8_t>(v[3]);
 
58
  return *this;
 
59
}
 
60
 
 
61
/*!
 
62
  Sets this vector to the unsigned short integer precision vector \a
 
63
  v, converting the vector to a unsigned 8-bit integer precision vector.
 
64
*/
 
65
SbVec4ub &
 
66
SbVec4ub::setValue(const SbVec4us & v)
 
67
{
 
68
  vec[0] = static_cast<uint8_t>(v[0]);
 
69
  vec[1] = static_cast<uint8_t>(v[1]);
 
70
  vec[2] = static_cast<uint8_t>(v[2]);
 
71
  vec[3] = static_cast<uint8_t>(v[3]);
 
72
  return *this;
 
73
}
 
74
 
 
75
/*!
 
76
  Sets this vector to the unsigned 32-bit integer precision vector \a
 
77
  v, converting the vector to a unsigned 8-bit integer precision vector.
 
78
*/
 
79
SbVec4ub &
 
80
SbVec4ub::setValue(const SbVec4ui32 & v)
 
81
{
 
82
  vec[0] = static_cast<uint8_t>(v[0]);
 
83
  vec[1] = static_cast<uint8_t>(v[1]);
 
84
  vec[2] = static_cast<uint8_t>(v[2]);
 
85
  vec[3] = static_cast<uint8_t>(v[3]);
 
86
  return *this;
 
87
}
 
88
 
 
89
/*!
 
90
  Negate the vector (i.e. point it in the opposite direction)
 
91
*/
 
92
void
 
93
SbVec4ub::negate(void)
 
94
{
 
95
  vec[0] = static_cast<uint8_t>(-vec[0]);
 
96
  vec[1] = static_cast<uint8_t>(-vec[1]);
 
97
  vec[2] = static_cast<uint8_t>(-vec[2]);
 
98
  vec[3] = static_cast<uint8_t>(-vec[3]);
 
99
}
 
100
 
 
101
 
 
102
/*!  
 
103
  Multiply components of vector with value \a d. Returns reference
 
104
  to self.
 
105
 */
 
106
SbVec4ub &
 
107
SbVec4ub::operator *= (double d)
 
108
{
 
109
  vec[0] = static_cast<uint8_t>(vec[0] * d);
 
110
  vec[1] = static_cast<uint8_t>(vec[1] * d);
 
111
  vec[2] = static_cast<uint8_t>(vec[2] * d);
 
112
  vec[3] = static_cast<uint8_t>(vec[3] * d);
 
113
  return *this;
 
114
}
 
115
 
 
116
/*!
 
117
  \fn SbVec4ub::SbVec4ub(void)
 
118
  
 
119
  The default constructor does nothing. The vector coordinates will be
 
120
  uninitialized until a call the setValue().
 
121
*/
 
122
 
 
123
/*!
 
124
  \fn SbVec4ub::SbVec4ub(const uint8_t v[4])
 
125
 
 
126
  Constructs an SbVec4ub instance with initial values from \a v.
 
127
*/
 
128
 
 
129
/*!
 
130
  \fn SbVec4ub::SbVec4ub(uint8_t x, uint8_t y, uint8_t z, uint8_t w)
 
131
 
 
132
  Constructs an SbVec4ub instance with the initial homogeneous vector
 
133
  set to \a <x,y,z,w>.
 
134
*/
 
135
 
 
136
/*!
 
137
  \fn explicit SbVec4ub::SbVec4ub(const SbVec4b & v)
 
138
 
 
139
  Constructs an SbVec4ub instance with initial values from the 8-bit
 
140
  integer precision vector \a v.
 
141
*/
 
142
 
 
143
/*!
 
144
  \fn explicit SbVec4ub::SbVec4ub(const SbVec4us & v)
 
145
 
 
146
  Constructs an SbVec4ub instance with initial values from the
 
147
  unsigned short integer precision vector \a v.
 
148
*/
 
149
 
 
150
/*!
 
151
  \fn explicit SbVec4ub::SbVec4ub(const SbVec4ui32 & v)
 
152
 
 
153
  Constructs an SbVec4ub instance with initial values from the
 
154
  unsigned 32-bit integer precision vector \a v.
 
155
*/
 
156
 
 
157
/*!
 
158
  \fn SbVec4ub & SbVec4ub::setValue(const uint8_t v[4]) 
 
159
  
 
160
  Set new coordinates for the vector from \a v. Returns reference to
 
161
  self.
 
162
  
 
163
  \sa getValue()
 
164
*/
 
165
 
 
166
/*!
 
167
  \fn SbVec4ub & SbVec4ub::setValue(uint8_t x, uint8_t y, uint8_t z, uint8_t w)
 
168
 
 
169
  Set new coordinates for the vector. Returns reference to self.
 
170
 
 
171
  \sa getValue()
 
172
*/
 
173
 
 
174
/*!
 
175
  \fn const uint8_t * SbVec4ub::getValue(void) const
 
176
 
 
177
  Returns a pointer to an array of four uint8_t integers
 
178
  containing the x, y, z and w coordinates of the vector.
 
179
 
 
180
  \sa setValue()
 
181
*/
 
182
 
 
183
/*!
 
184
  \fn void SbVec4ub::getValue(uint8_t & x, uint8_t & y, uint8_t & z, uint8_t & w) const 
 
185
 
 
186
  Returns the x, y, z and w coordinates of the vector.
 
187
*/
 
188
 
 
189
/*!
 
190
  \fn uint8_t & SbVec4ub::operator [] (int i)
 
191
 
 
192
  Index operator. Returns modifiable x, y, z or w coordinate of the
 
193
  vector.
 
194
*/
 
195
/*!
 
196
  \fn const uint8_t & SbVec4ub::operator [] (int i) const
 
197
 
 
198
  Index operator. Returns non-modifiable x, y, z or w coordinate of
 
199
  the vector.
 
200
*/
 
201
 
 
202
/*!
 
203
  \fn int32_t SbVec4ub::dot(SbVec4ub v) const 
 
204
 
 
205
  Calculates and returns the result of taking the dot product of this
 
206
  vector and \a v.
 
207
*/
 
208
 
 
209
/*!
 
210
  \fn void SbVec4ub::negate(void) 
 
211
 
 
212
  Negate the vector (i.e. point it in the opposite direction)
 
213
*/
 
214
 
 
215
/*!
 
216
  \fn SbVec4ub & SbVec4ub::operator *= (int d) 
 
217
 
 
218
  Multiply components of vector with scalar value \a d. Returns
 
219
  reference to self.
 
220
*/
 
221
 
 
222
/*!
 
223
  \fn SbVec4ub & SbVec4ub::operator /= (int d) 
 
224
 
 
225
  Divides components of vector with scalar value \a d. Returns
 
226
  reference to self.
 
227
*/
 
228
 
 
229
/*!
 
230
  \fn SbVec4ub & SbVec4ub::operator /= (double d) 
 
231
 
 
232
  Divides components of vector with scalar value \a d. Returns
 
233
  reference to self.
 
234
*/
 
235
 
 
236
/*!
 
237
  \fn SbVec4ub & SbVec4ub::operator += (SbVec4ub v) 
 
238
 
 
239
  Adds this vector and vector \a u. Returns reference to self.
 
240
*/
 
241
 
 
242
/*!
 
243
  \fn SbVec4ub & SbVec4ub::operator -= (SbVec4ub v) 
 
244
  
 
245
  Subtracts \a v from this vector. Returns reference to self.
 
246
*/
 
247
/*!
 
248
  \fn SbVec4ub SbVec4ub::operator - (void) const 
 
249
 
 
250
  Non-destructive negation operator. Returns a new SbVec4ub instance
 
251
  which points in the opposite direction of this vector.
 
252
  
 
253
  \sa negate()
 
254
*/