12#ifndef BASIC_VECTOR3D_H
13#define BASIC_VECTOR3D_H
61 v_[0] = v.
x();
v_[1] = v.
y();
v_[2] = v.
z();
74 operator T * () {
return v_; }
78 operator const T * ()
const {
return v_; }
94 v_[0] = v.
v_[0];
v_[1] = v.
v_[1];
v_[2] = v.
v_[2];
return *
this;
99 v_[0] += v.
v_[0];
v_[1] += v.
v_[1];
v_[2] += v.
v_[2];
return *
this;
104 v_[0] -= v.
v_[0];
v_[1] -= v.
v_[1];
v_[2] -= v.
v_[2];
return *
this;
109 v_[0] *= a;
v_[1] *= a;
v_[2] *= a;
return *
this;
114 v_[0] /= a;
v_[1] /= a;
v_[2] /= a;
return *
this;
141 T
x()
const {
return v_[0]; }
144 T
y()
const {
return v_[1]; }
147 T
z()
const {
return v_[2]; }
161 void set(T x1, T y1, T z1) {
v_[0] = x1;
v_[1] = y1;
v_[2] = z1; }
182 factor = rh/factor;
v_[0] *= factor;
v_[1] *= factor;
202 return x() == 0 &&
y() == 0 ? 0 : std::atan2(
y(),
x());
207 return x() == 0 &&
y() == 0 &&
z() == 0 ? 0 : std::atan2(
perp(),
z());
228 factor = ma/factor;
v_[0] *= factor;
v_[1] *= factor;
v_[2] *= factor;
242 set(ma*std::sin(th)*std::cos(ph), ma*std::sin(th)*std::sin(ph), ma*std::cos(th));
270 return x()*v.
x()+
y()*v.
y()+
z()*v.
z();
278 x()*v.
y()-v.
x()*
y());
285 return tot > 0 ?
mag2()-s*s/tot :
mag2();
291 return std::sqrt(
perp2(v));
313 T dx =
x() < 0 ? -
x() :
x();
314 T dy =
y() < 0 ? -
y() :
y();
315 T dz =
z() < 0 ? -
z() :
z();
403 return BasicVector3D<float>(v.
x()*
static_cast<float>(a), v.
y()*
static_cast<float>(a), v.
z()*
static_cast<float>(a));
421 return BasicVector3D<float>(
static_cast<float>(a)*v.
x(),
static_cast<float>(a)*v.
y(),
static_cast<float>(a)*v.
z());
430 return BasicVector3D<float>(v.
x()/
static_cast<float>(a), v.
y()/
static_cast<float>(a), v.
z()/
static_cast<float>(a));
439 return (a.
x()==b.
x() && a.
y()==b.
y() && a.
z()==b.
z());
448 return (a.
x()!=b.
x() || a.
y()!=b.
y() || a.
z()!=b.
z());
548 return (a.
x()==b.
x() && a.
y()==b.
y() && a.
z()==b.
z());
558 return (a.
x()!=b.
x() || a.
y()!=b.
y() || a.
z()!=b.
z());
BasicVector3D< float > operator-(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< T > cross(const BasicVector3D< T > &v) const
BasicVector3D< float > operator*(const BasicVector3D< float > &v, double a)
float operator*(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< T > & rotateZ(T a)
BasicVector3D(const BasicVector3D< float > &v)
BasicVector3D< double > operator*(const BasicVector3D< double > &v, double a)
bool operator!=(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< T > & operator/=(double a)
BasicVector3D< T > & rotateX(T a)
BasicVector3D< T > & rotate(T a, const BasicVector3D< T > &v)
BasicVector3D< T > & operator=(const BasicVector3D< T > &v)
BasicVector3D< float > operator+(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< float > operator/(const BasicVector3D< float > &v, double a)
T operator[](int i) const
T angle(const BasicVector3D< T > &v) const
BasicVector3D< T > & operator*=(double a)
BasicVector3D< double > operator+(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
bool operator==(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< float > operator-(const BasicVector3D< float > &v)
bool operator==(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
BasicVector3D< double > operator+(const BasicVector3D< double > &v)
BasicVector3D(T x1, T y1, T z1)
BasicVector3D< double > operator-(const BasicVector3D< double > &v)
BasicVector3D< T > & rotateY(T a)
BasicVector3D< double > operator/(const BasicVector3D< double > &v, double a)
BasicVector3D< double > operator-(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
bool operator!=(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
BasicVector3D< T > unit() const
BasicVector3D< float > operator*(double a, const BasicVector3D< float > &v)
BasicVector3D< double > operator*(double a, const BasicVector3D< double > &v)
BasicVector3D< T > & operator+=(const BasicVector3D< T > &v)
BasicVector3D< T > & operator-=(const BasicVector3D< T > &v)
double operator*(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
T perp2(const BasicVector3D< T > &v) const
void set(T x1, T y1, T z1)
BasicVector3D< T > orthogonal() const
T perp(const BasicVector3D< T > &v) const
BasicVector3D< float > operator+(const BasicVector3D< float > &v)
T dot(const BasicVector3D< T > &v) const
T operator()(int i) const
std::istream & operator>>(std::istream &is, BasicVector3D< float > &a)
std::ostream & operator<<(std::ostream &os, const BasicVector3D< float > &a)