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

« back to all changes in this revision

Viewing changes to src/base/SbVec2f.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
1
/**************************************************************************\
2
2
 *
3
3
 *  This file is part of the Coin 3D visualization library.
4
 
 *  Copyright (C) 1998-2006 by Systems in Motion.  All rights reserved.
 
4
 *  Copyright (C) 1998-2007 by Systems in Motion.  All rights reserved.
5
5
 *
6
6
 *  This library is free software; you can redistribute it and/or
7
7
 *  modify it under the terms of the GNU General Public License
23
23
 
24
24
/*!
25
25
  \class SbVec2f SbLinear.h Inventor/SbLinear.h
26
 
  \brief The SbVec2f class is a 2 dimensional vector with floating point coordinates.
 
26
 
 
27
  \brief The SbVec2f class is a 2 dimensional vector with floating
 
28
  point coordinates.
 
29
 
27
30
  \ingroup base
28
31
 
29
 
  This vector class is used by many other classes in
30
 
  Coin. It provides storage for a vector in 2 dimensions aswell
31
 
  as simple floating point arithmetic operations on this vector.
 
32
  This vector class is used by many other classes in Coin. It provides
 
33
  storage for a vector in 2 dimensions aswell as simple floating point
 
34
  arithmetic operations on this vector.
32
35
 
33
 
  \sa SbVec2s, SbVec3s, SbVec3f, SbVec4f
 
36
  \sa SbVec2d, SbVec3f, SbVec3d, SbVec4f, SbVec4d
34
37
*/
35
38
 
 
39
#include <Inventor/SbVec2f.h>
 
40
 
36
41
#include <assert.h>
37
 
#include <Inventor/SbVec2f.h>
 
42
 
 
43
#include <Inventor/SbVec2d.h>
 
44
#include <Inventor/SbVec2b.h>
 
45
#include <Inventor/SbVec2s.h>
 
46
#include <Inventor/SbVec2i32.h>
 
47
 
38
48
#include <Inventor/C/tidbitsp.h> // coin_debug_normalize()
39
49
#if COIN_DEBUG
40
50
#include <Inventor/errors/SoDebugError.h>
41
51
#endif // COIN_DEBUG
42
52
 
 
53
 
43
54
// *************************************************************************
44
55
 
45
56
/*!
73
84
}
74
85
 
75
86
/*!
 
87
  \fn SbVec2f::SbVec2f(const SbVec2d & v)
 
88
 
 
89
  Constructs an SbVec2f instance with initial values from the vector
 
90
  \a v.
 
91
 
 
92
  \since Coin-2.5
 
93
*/
 
94
 
 
95
/*!
 
96
  \fn SbVec2f::SbVec2f(const SbVec2b & v)
 
97
 
 
98
  Constructs an SbVec3f instance with initial values from the vector
 
99
  \a v.
 
100
 
 
101
  \since Coin-2.5
 
102
*/
 
103
 
 
104
/*!
 
105
  \fn SbVec2f::SbVec2f(const SbVec2s & v)
 
106
 
 
107
  Constructs an SbVec3f instance with initial values from the vector
 
108
  \a v.
 
109
 
 
110
  \since Coin-2.5
 
111
*/
 
112
 
 
113
/*!
 
114
  \fn SbVec2f::SbVec2f(const SbVec2i32 & v)
 
115
 
 
116
  Constructs an SbVec3f instance with initial values from the vector
 
117
  \a v.
 
118
 
 
119
  \since Coin-2.5
 
120
*/
 
121
 
 
122
/*!
76
123
  Calculates and returns the result of taking the dot product of this
77
124
  vector and \a v.
78
125
 */
141
188
}
142
189
 
143
190
/*!
 
191
  Returns the square of the length of the vector.
 
192
 
 
193
  \since Coin-2.5
 
194
*/
 
195
 
 
196
float
 
197
SbVec2f::sqrLength(void) const
 
198
{
 
199
  return vec[0] * vec[0] + vec[1] * vec[1];
 
200
}
 
201
 
 
202
/*!
144
203
  Negate the vector (i.e. point it in the opposite direction).
145
204
 */
146
205
 
204
263
}
205
264
 
206
265
/*!
 
266
  Set new value from an SbVec2d instance.
 
267
 
 
268
  \since Coin-2.5
 
269
*/
 
270
 
 
271
SbVec2f &
 
272
SbVec2f::setValue(const SbVec2d & v)
 
273
{
 
274
  vec[0] = static_cast<float>(v[0]);
 
275
  vec[1] = static_cast<float>(v[1]);
 
276
  return *this;
 
277
}
 
278
 
 
279
/*!
 
280
  Sets the value from an SbVec2b instance.
 
281
 
 
282
  \since Coin-2.5
 
283
*/
 
284
 
 
285
SbVec2f &
 
286
SbVec2f::setValue(const SbVec2b & v)
 
287
{
 
288
  vec[0] = static_cast<float>(v[0]);
 
289
  vec[1] = static_cast<float>(v[1]);
 
290
  return *this;
 
291
}
 
292
 
 
293
/*!
 
294
  Sets the value from an SbVec2s instance.
 
295
 
 
296
  \since Coin-2.5
 
297
*/
 
298
 
 
299
SbVec2f &
 
300
SbVec2f::setValue(const SbVec2s & v)
 
301
{
 
302
  vec[0] = static_cast<float>(v[0]);
 
303
  vec[1] = static_cast<float>(v[1]);
 
304
  return *this;
 
305
}
 
306
 
 
307
/*!
 
308
  Sets the value from an SbVec2i32 instance.
 
309
 
 
310
  \since Coin-2.5
 
311
*/
 
312
 
 
313
SbVec2f &
 
314
SbVec2f::setValue(const SbVec2i32 & v)
 
315
{
 
316
  vec[0] = static_cast<float>(v[0]);
 
317
  vec[1] = static_cast<float>(v[1]);
 
318
  return *this;
 
319
}
 
320
 
 
321
 
 
322
/*!
207
323
  Index operator. Returns modifiable x or y coordinate.
208
324
 
209
325
  \sa getValue() and setValue().