24 QPVector(
double x,
double y,
double z);
40 void Get(
double& x,
double& y,
double& z);
192 std::string
Print(
bool quite=
false);
196 double fX=0., fY=0., fZ=0;
229 fX = fY*other.fZ-fY*other.fZ;
230 fY = fZ*other.fX-fX*other.fZ;
231 fZ = fX*other.fY-fY*other.fX;
236 if(i>2) std::cout<<
"QPVector::operator() - Index is over 3\t:\t" << i <<std::endl;
237 double * val[3] = {&fX, &fY, &fZ};
242 if(i>2) std::cout<<
"QPVector::operator[] - Index is over 3\t:\t" << i <<std::endl;
243 double * val[3] = {&fX, &fY, &fZ};
249 return fX*other.fX + fY*other.fY + fZ*other.fZ;
253 return QPVector(fY*other.fZ-other.fY*fZ, fZ*other.fX-other.fZ*fX, fX*other.fY-other.fX*fY);
3-component double vector with hand-rolled operations.
void AddThis(const QPVector &other)
In-place add; delegates to operator+= and inherits its z-component defect (see operator+=).
void CrossThis(const QPVector &other)
In-place cross product; delegates to operator^= and inherits its overwrite defect (see operator^=).
void ScaleThis(const double &number)
Multiply all components in place.
QPVector Cross(QPVector other) const
Cross product (correct, unlike operator^=).
QPVector & operator^=(const QPVector &other)
In-place cross product.
double & operator()(const int &i)
Reference to component i (0 = x, 1 = y, 2 = z).
double Dot(QPVector other) const
Dot product .
QPVector Scale(double &number)
Scaled copy .
QPVector Unit()
Unit vector .
friend QPVector operator^(QPVector a, QPVector b)
Cross product .
friend QPVector operator*(QPVector vec, double other)
Scaled copy.
QPVector & operator=(const QPVector &other)
Component-wise copy assignment.
QPVector & operator-=(const QPVector &other)
In-place subtract.
QPVector & operator+=(const QPVector &other)
In-place add.
double GetAngle(QPVector other)
Angle between this vector and other, .
friend QPVector operator+(QPVector &a, QPVector &b)
Component-wise sum (lvalue overload).
std::string Print(bool quite=false)
Formats the vector as "[x,y,z]".
double & operator[](const int &i)
Reference to component i (0 = x, 1 = y, 2 = z); same behavior and warning as operator().
void SubstractThis(const QPVector &other)
In-place subtract; delegates to operator-= and inherits its z-component defect (see operator-=).
QPVector & operator*=(const double &other)
Multiply all components in place.
friend QPVector operator-(QPVector a, QPVector b)
Component-wise difference.
double GetAngleDegree(QPVector other)
GetAngle converted to degrees.
void Get(double &x, double &y, double &z)
Writes the components into the given references.