|
Class CXMMVector is a base class to represent a three-dimensional
vector with the following features :
it contains the three X,Y,Z values plus one homogeneous coordinate W
(used in coordinate transformations, you can think of this
class as of a simple 3-D vector). They are four 4-byte floats
it is based on parallel XMM instructions. They are available on all
Intel CPUs starting from Pentium III. These instructions enable to
perform simultaneous (parallel) operations on all four floats
at once. This is called SIMD (Single Instruction, Multiple Data)
CPU operation
a number of popular vector operations, like addition, vector and
dot products etc. are formed as operators of the class, e.g. addition
of two vectors can be written
in source code in a way similar to normal ariphmetic like
a = b + c;
where a,b,c are instances of CXMMVector class
Operations defined (with sample code snippets) :
addition
CXMMVector V1 = CXMMVector(0.5,-0.7,88.0); // just for sample
CXMMVector V2 = CXMMVector(3.5,0.7,3.3);
CXMMVector V3;
V3 = V1 + V2;
V1 += V2;
subtraction
V3 = V1 - V2;
V1 -= V2;
multiply of all components by a scalar coefficient
V3 = V1 * float;
V1 *= float;
for example,
V3 = V1 * 0.1;
division of all components by a scalar coefficient
V3 = V1 / float;
V1 /= float;
dot product
float = V1 * V2;
get vector coordinate
float = V[AxisX];
get vector length
float = !V;
vector product
V3 = V1^V2;
normalisation
V2 = +V1;
get distance between two vectors
float = V1%V2;
vectors equal?
bool = (V1==V2);
get angle between vectors in radians
float = V1"<"V2;
change sign of components
V2 = -V1;
get mean vector
V3 = V1|V2;
vectors co-directed?
bool = (V1>V2);
|