30#ifndef ROBODK_VECTOR3_H
31#define ROBODK_VECTOR3_H
59 Vector3(
double x,
double y,
double z);
80 inline double X()
const {
return _v[0]; }
85 inline double Y()
const {
return _v[1]; }
90 inline double Z()
const {
return _v[2]; }
95 inline void SetX(
double x) { _v[0] = x; }
100 inline void SetY(
double y) { _v[0] = y; }
105 inline void SetZ(
double z) { _v[0] = z; }
110 inline const double&
operator[](
size_t i)
const {
return _v[i]; }
137 double _v[3] = {0.0, 0.0, 0.0};
The Vector3 class represents a vector or vertex in 3D space.
static double DotProduct(const Vector3 &v1, const Vector3 &v2)
Returns the dot product of v1 and v2.
void SetZ(double z)
Sets the z coordinate of this vector to the given z coordinate.
double & operator[](size_t i)
Returns the component of the vector at index position i as a modifiable reference.
Vector3(const Vector3 &v)=default
Constructs a vector object as a copy of v.
Vector3()=default
Constructs a null vector, i.e.
const double & operator[](size_t i) const
Returns the component of the vector at index position i.
double Length() const
Returns the length of the vector from the origin.
static Vector3 CrossProduct(const Vector3 &v1, const Vector3 &v2)
Returns the cross-product of vectors v1 and v2, which corresponds to the normal vector of a plane def...
void SetX(double x)
Sets the x coordinate of this vector to the given x coordinate.
double Z() const
Returns the z coordinate of this vector.
Vector3 & operator=(const Vector3 &v)=default
Sets this Vector3 object as a copy of v.
double X() const
Returns the x coordinate of this vector.
void Normalize()
Normalizes the currect vector in place.
double Y() const
Returns the y coordinate of this vector.
void SetY(double y)
Sets the y coordinate of this vector to the given y coordinate.