19void QPVector::Get(
double& x,
double& y,
double& z){x = fX; y = fY; z=fZ;}
23 return QPVector(fX/norm, fY/norm, fZ/norm);
30 return QPVector(number*fX, number*fY, number*fZ);
34 return sqrt(fX*fX + fY*fY + fZ*fZ);
38 return fX*fX + fY*fY + fZ*fZ;
59 (*this).operator*=(number);
88 std::ostringstream anss;
90 anss <<
"[" << fX <<
"," << fY <<
"," << fZ <<
"]";
92 std::string ans = anss.str();
95 std::cout<<
"[x,y,z] = " << ans << std::endl;
106 return QPVector(a.fX+b.fX, a.fY+b.fY, a.fZ+b.fZ);
114 return QPVector(a.fX-b.fX, a.fY-b.fY, a.fZ-b.fZ);
125 double x = a.fY*b.fZ-a.fZ*b.fY;
126 double y = a.fZ*b.fX-a.fX*b.fZ;
127 double z = a.fX*b.fY-a.fY*b.fX;
136 return QPVector(other*vec.fX, other*vec.fY, other*vec.fZ);
148 return QPVector(other*vec.fX, other*vec.fY, other*vec.fZ);
152 return vec.
Dot(other);
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.
double Dot(QPVector other) const
Dot product .
QPVector Scale(double &number)
Scaled copy .
QPVector Unit()
Unit vector .
double GetAngle(QPVector other)
Angle between this vector and other, .
std::string Print(bool quite=false)
Formats the vector as "[x,y,z]".
void SubstractThis(const QPVector &other)
In-place subtract; delegates to operator-= and inherits its z-component defect (see operator-=).
double GetAngleDegree(QPVector other)
GetAngle converted to degrees.
void Get(double &x, double &y, double &z)
Writes the components into the given references.