Table of contents |
Derived from: none
Declared in: MTVector.h
Library: 3DM.so
This class represents a vector of floats. It can make operations easier to create 3d objects. You can use MTVector ton construct MTPoints objects.
|
Constructs a new vector. The first version creates an empty vector. The second one takes nValues from the array values. The third one copies the vector src.
|
Destroys the vector.
|
Returns a constant vector. It is filled with nValues floats, equal to constant.
|
Returns a vector with nValues floats, going from val1 to var2, including var2.
|
Returns a vector with nValues floats, going from val1 to var2, excluding var2.
|
Returns a vector with nValues random floats, going from val1 to var2.
|
Concatenate the current vector with val. Returns the current vector.
|
Concatenate the current vector with vect. Returns the current vector.
|
Applies a cosine function to all the values in the current vector. The values should be in radiants.
|
Returns the number of values in the vector.
|
Repeats each element of the vector each times, and the whole vector list times.
As an example, if a contains 1,2,3 and 4, in this order, it will contain these values after these operations:
a.Repeat(3,1) : 1,1,1,2,2,2,3,3,3,4,4,4
a.Repeat(1,3) : 1,2,3,4,1,2,3,4,1,2,3,4
a.Repeat(2,2) : 1,1,2,2,3,3,4,4,1,1,2,2,3,3,4,4
|
Replaces the current vector by a copy of src, or by a new vector made of the nValues floats stored in the array values.
|
Applies a sine function to all the values in the current vector. The values should be in radiants.
|
Applies a tangent function to all the values in the current vector. The values should be in radiants.
|
Returns the values stored in the vector, as an array of floats.
I've documented here all the operators, and sometimes the way I describe them isn't really easy to understand. But in fact they are very intuitive.
You can use the regular operators +,-,*,/,+=,-=,*= and /= with vectors. They work exactly as their float versions, except that they apply to each value of the vectors.
Thus [ 1 2 3 4 ] + [ 0 0 2 2 ] is [ 1 2 5 6), and [ 1 2 3 4 ] * [ 0 1 0 1 ] is [ 0 2 0 4 ]. The two vector used must have the same length
The assignation operator is here also. A = B copies B into A.
The & operator is the concatenation: [ 1 2 ] & [ 3 4 ] is [ 1 2 3 4 ].
And finally The ^ operator is an inderection operator
|
Replaces the current vector by a copy of src.
|
Concatenate the current vector with the vector src or the value val.
|
Builds and return a new vector, which is the concatenation of the current vector with the vector src or the value val. The current vector isn't modified.
|
Adds to each value of the current vector the corresponding value from src, or the value val. The current vector and src must have the same length.
|
Builds a new vector made by adding each value of the current vector to the corresponding value in src, or the value val. Both vectors must have the same length. The current vector isn't modified.
|
Substracts to each value of the current vector the corresponding value from src, or the value val. The current vector and src must have the same length.
|
Builds a new vector made by substracting to each value of the current vector the corresponding value in src, or the value val. Both vectors must have the same length. The current vector isn't modified.
|
Multiplies to each value of the current vector the corresponding value from src, or the value val. The current vector and src must have the same length.
|
Builds a new vector made by multiplying to each value of the current vector the corresponding value in src, or the value val. Both vectors must have the same length. The current vector isn't modified.
|
Divides each value of the current vector by the corresponding value from src, or the value val. The current vector and src must have the same length.
|
Builds a new vector made by dividing each value of the current vector by the corresponding value in src, or the value val. Both vectors must have the same length. The current vector isn't modified.
|
This operator lets you access to the individual values of the vector. If index is out of range, the last value is returned.
You can use this operator to read and/or to write a value: A[i] = B[j], where A and B are MTVector objects, is valid and works as expected.
|
This is the indirection operator. If you do
A = B ^ C, A will be a new
vector, with B's length, and whose values
will be as follows:
A[i] = C[B[i]]
B[i] is evaluated modulo the number of elements in C, so there is never an overflow.
|
Returns a new vector whose values are the cosines of the values in src.
|
Returns a new vector whose values are the sines of the values in src.
|
Returns a new vector whose values are the tangents of the values in src.