1 #ifndef QNANO_NEW_CLASS_VEC3D_ 2 #define QNANO_NEW_CLASS_VEC3D_ 18 inline void set(
double x,
double y,
double z){v[0]=x;v[1]=y;v[2]=z;}
19 inline void set(
const Vec3d &other){v[0]=other.v[0];v[1]=other.v[1];v[2]=other.v[2];}
21 inline double norm2()
const{
return (v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);}
22 inline double norm()
const{
return sqrt(norm2());}
23 inline void normalize(){
double n=norm(); v[0]/=n; v[1]/=n; v[2]/=n;}
26 double & operator[](
const size_t i){
return v[i];}
27 double operator[](
const size_t i)
const{
return v[i];}
31 Vec3d & operator*=(
double d);
32 Vec3d & operator/=(
double d);
33 friend std::ostream& operator<<(std::ostream& os,
const Vec3d& v);
37 Vec3d(
double x,
double y,
double z);
41 std::ostream& operator<<(std::ostream& os,
const Vec3d&
v);
45 Vec3d operator*(
double left,
const Vec3d right);
46 Vec3d operator*(
const Vec3d left,
double right);
49 Vec3d operator/(
const Vec3d left,
double right);
51 double operator*(
const Vec3d & v1,
const Vec3d & v2);
53 double norm(
const Vec3d &v);
56 std::istream& operator>>(std::istream& is,
Vec3d &v);
Class to store positions and to handle operations on 3d vectors.
Definition: Vec3d.h:9
double v[3]
Actual vector elements:
Definition: Vec3d.h:13
Vec3d()
Class to store positions and to handle operations on 3d vectors.
Definition: Vec3d.cc:8