classPiiVector
#include <PiiVector.h>
A D -dimensional vector.
Inherits PiiArithmeticBase< PiiVector< T, D >, PiiVectorTraits< T, D > >
Description
PiiVector can be used to represent points and vectors in
multidimensional spaces. The size of a vector is fixed, and all of
its data is within the class itself. That is, there is no
heap-allocated data, and sizeof(PiiVector<T,D>) ==
sizeof(T) * D.
Matrices and vectors are distinct entities, but a row of a matrix can be treated as a vector:
typedef PiiVector<int,3> Vec3; PiiMatrix<int> matData(1,3, 1,2,3); Vec3& vec = *reinterpret_cast<Vec3*>(matData[0]); // Better yet: vec = *matData.rowAs<Vec3>(); QCOMPARE(vec[0], 1); QCOMPARE(vec[1], 2); QCOMPARE(vec[2], 3);
Public types
|
Shorthand for the base class type. |
|
|
typedef Pii::VaArg<
T >::Type
|
Shorthand for variable argument type. |
Constructors and destructor
|
Create a new measumerent point. |
|
|
Create a new vector by copying values from a preallocated array. |
|
|
( )
Create a new vector with all values initialized to zero. |
Public member functions
|
( )
Returns an stl-style const iterator to the beginning of data. |
|
|
( )
Returns an stl-style iterator to the beginning of data. |
|
|
( )
Returns an stl-style iterator to the end of data. |
|
|
( )
Returns an stl-style const iterator to the end of data. |
|
|
double
|
( )
|
|
void
|
( )
Change vector to a unit vector with the original orientation. |
|
( )
Get a unit vector that has the same orientation as this vector. |
|
|
(
Analogous to operator[]. |
|
|
T &
|
(
Analogous to operator[], non-const version. |
|
Copy another vector. |
|
|
(
Get the value of the vector at |
|
|
T &
|
(
Get a reference to the value of the vector at |
|
double
|
Calculate squared geometric distance to another vector. |
|
double
|
( )
Get the squared length of this vector. |
Function details
-
Create a new measumerent point.
PiiVector<int,3>* p = new PiiVector<int,3>(1, 2, 3); PiiVector<double,4>* d = new PiiVector<double,4>(1.0, 2.0, 3.0, 4.0); PiiVector<double,4> pt(1, 2, 3, 4); // WRONG! Arguments are ints
Using this constructor is dangerous. Make sure that all arguments are passed correctly.
-
Create a new vector by copying values from a preallocated array.
Parameters
- ptr
-
a pointer to the first value. This array must hold at leasts
Delements.
-
PiiVector
()[inline]Create a new vector with all values initialized to zero.
-
Returns an stl-style const iterator to the beginning of data.
-
Returns an stl-style iterator to the beginning of data.
-
Returns an stl-style iterator to the end of data.
-
Returns an stl-style const iterator to the end of data.
-
double length
()[inline] -
void normalize
()[inline]Change vector to a unit vector with the original orientation.
If the length of the vector is zero, no changes will be made.
-
Get a unit vector that has the same orientation as this vector.
If the length of the vector is zero, the result will be equal to this vector.
-
Analogous to operator[].
This operator is useful for template functions that work with both PiiMatrix and PiiVector.
-
Analogous to operator[], non-const version.
This operator is useful for template functions that work with both PiiMatrix and PiiVector.
-
Copy another vector.
-
Get the value of the vector at
indexas a copy. -
Get a reference to the value of the vector at
index. -
Calculate squared geometric distance to another vector.
-
double squaredLength
()[inline]Get the squared length of this vector.
Add a note
Not a single note added yet. Be the first, add yours.