34 Vector3(
const double x_,
const double y_,
const double z_):valX(x_),valY(y_),valZ(z_)
57 return (valX==0 && valY==0 && valZ==0);
63 double sq(valX*valX+valY*valY+valZ*valZ);
65 return (err>-.03 && err<.03);
73 void xyz(
double& x_,
double& y_,
double& z_)
const
93 inline double x()
const
102 inline double y()
const
112 inline double z()
const
123 void set(
const double x_,
const double y_,
const double z_);
175 if(valX>=valY && valX>=valZ)
return valX;
176 if(valY>=valZ)
return valY;
232 void addOwnCoords(
double& x,
double& y,
double& z)
const
239 Vector3& operator+=(
const Vector3& other);
240 Vector3& operator-=(
const Vector3& other);
241 Vector3& operator/=(
double div);
242 Vector3& operator*=(
double mul);
257 inline std::ostream &operator<<(std::ostream &stream,
const Vector3& vec)
259 stream <<
"Vector3: "<<vec.x()<<
", "<<vec.y()<<
", "<<vec.z();
269 double x=vec0.
y() * vec1.
z() - vec0.
z() * vec1.
y();
270 double y=vec0.
z() * vec1.
x() - vec0.
x() * vec1.
z();
271 double z=vec0.
x() * vec1.
y() - vec0.
y() * vec1.
x();
283 double len(other.
length());
286 return Vector3(other.
x()/len,other.
y()/len,other.
z()/len);
291 std::cerr<<
"\n\n** warning: normalize(const Vector3& other), Null length vector! Will segfault now"<<std::endl;
292 std::cerr<<
"other.x()="<<other.
x()<<std::endl;
293 std::cerr<<
"other.y()="<<other.
y()<<std::endl;
294 std::cerr<<
"other.z()="<<other.
z()<<std::endl;
295 if(other.
x()==0.0) std::cerr<<
"other.x()==0.0"<<std::endl;
296 if(other.
y()==0.0) std::cerr<<
"other.y()==0.0"<<std::endl;
297 if(other.
z()==0.0) std::cerr<<
"other.z()==0.0"<<std::endl;
307 inline Vector3 operator-(
const Vector3& in)
309 return Vector3(-in.x(),-in.y(),-in.z());
312 inline Vector3 operator*(
double d,
const Vector3& vec)
314 return Vector3(d*vec.x(),d*vec.y(),d*vec.z());
318 inline Vector3 operator+(
const Vector3& vec0,
const Vector3& vec1)
320 return Vector3(vec0.x()+vec1.x(), vec0.y()+vec1.y() , vec0.z()+vec1.z());
323 inline Vector3 operator-(
const Vector3& vec0,
const Vector3& vec1)
325 return Vector3(vec0.x()-vec1.x(), vec0.y()-vec1.y() , vec0.z()-vec1.z());
3D Vector
Definition: Vector3.h:27
double z() const
Get the z-value.
Definition: Vector3.h:112
void set(const double x_, const double y_, const double z_)
Set x,y,z.
double sqLength() const
Get the squared length of the vector.
double operator*(const Vector3 &other) const
Scalar product.
double getCartesian(int i) const
Get component i.
Vector3 & operator=(const Vector3 &other)
Assignment operator.
Definition: Vector3.h:223
Vector3(const Vector3 &v_)
Copy constructor.
Definition: Vector3.h:48
double x() const
Get the x-value.
Definition: Vector3.h:93
void add(const Vector3 &other)
Add a Vector3 to the present one.
Definition: Vector3.h:129
Vector3(const double x_, const double y_, const double z_)
Constructor.
Definition: Vector3.h:34
double getMaxComponent() const
Get max component.
Definition: Vector3.h:173
void reset()
reset
Definition: Vector3.h:83
Vector3()
Default constructor.
Definition: Vector3.h:41
double getMaxAbsComponent() const
Get max absolute component.
int getMaxAbsIndex() const
Get max index.
Vector3 operator*(double val) const
Multiply by a scalar value.
Vector3 operator/(double val) const
Divide by a scalar value.
bool isDegenerate() const
isDegenerate
Definition: Vector3.h:55
void xyz(double &x_, double &y_, double &z_) const
Get x,y,z.
Definition: Vector3.h:73
double length() const
Get the length of the vector.
double y() const
Get the y-value.
Definition: Vector3.h:102
Vector3 normalize(const Vector3 &other)
Normalize.
Definition: Vector3.h:281
Vector3 crossProduct(const Vector3 &vec0, const Vector3 &vec1)
Cross product.
Definition: Vector3.h:266