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]; }
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());
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();
354 operator<<(std::ostream &, const BasicVector3D<float> &);
361 operator>>(std::istream &, BasicVector3D<float> &);
367 inline BasicVector3D<float>
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());
462 operator<<(std::ostream &, const BasicVector3D<double> &);
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());
bool operator!=(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< double > operator*(const BasicVector3D< double > &v, double a)
BasicVector3D< T > & rotate(T a, const BasicVector3D< T > &v)
BasicVector3D< float > operator*(double a, const BasicVector3D< float > &v)
BasicVector3D< double > operator/(const BasicVector3D< double > &v, double a)
void set(T x1, T y1, T z1)
BasicVector3D< double > operator+(const BasicVector3D< double > &v)
bool operator==(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
BasicVector3D(const BasicVector3D< float > &v)
T operator()(int i) const
BasicVector3D< double > operator*(double a, const BasicVector3D< double > &v)
BasicVector3D< T > unit() const
BasicVector3D< T > & operator=(const BasicVector3D< T > &v)
BasicVector3D< double > operator-(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
BasicVector3D< float > operator-(const BasicVector3D< float > &v)
BasicVector3D< float > operator+(const BasicVector3D< float > &v)
BasicVector3D< double > operator-(const BasicVector3D< double > &v)
BasicVector3D< T > & operator+=(const BasicVector3D< T > &v)
double operator*(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
T operator[](int i) const
BasicVector3D< double > operator+(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
bool operator!=(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
T perp(const BasicVector3D< T > &v) const
float operator*(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< T > & operator-=(const BasicVector3D< T > &v)
bool operator==(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< float > operator-(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
T angle(const BasicVector3D< T > &v) const
BasicVector3D< T > & rotateX(T a)
BasicVector3D< T > orthogonal() const
BasicVector3D< float > operator*(const BasicVector3D< float > &v, double a)
BasicVector3D< T > & operator*=(double a)
std::istream & operator>>(std::istream &is, BasicVector3D< float > &a)
BasicVector3D< float > operator/(const BasicVector3D< float > &v, double a)
BasicVector3D(T x1, T y1, T z1)
BasicVector3D< float > operator+(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
T perp2(const BasicVector3D< T > &v) const
T dot(const BasicVector3D< T > &v) const
BasicVector3D< T > & rotateY(T a)
BasicVector3D< T > cross(const BasicVector3D< T > &v) const
BasicVector3D< T > & operator/=(double a)
BasicVector3D< T > & rotateZ(T a)