34 #ifndef OCTOMATH_VECTOR3_H 35 #define OCTOMATH_VECTOR3_H 112 z()*other.
x() -
x()*other.
z(),
113 x()*other.
y() -
y()*other.
x());
119 return x()*other.
x() +
y()*other.
y() +
z()*other.
z();
146 inline const float&
x()
const 151 inline const float&
y()
const 156 inline const float&
z()
const 176 inline const float&
roll()
const 186 inline const float&
yaw()
const 194 result(0) = -
data[0];
195 result(1) = -
data[1];
196 result(2) = -
data[2];
203 result(0) += other(0);
204 result(1) += other(1);
205 result(2) += other(2);
220 result(0) -= other(0);
221 result(1) -= other(1);
222 result(2) -= other(2);
252 for (
unsigned int i=0; i<3; i++) {
253 if (
operator()(i) != other(i))
266 return (
x()*
x() +
y()*
y() +
z()*
z());
273 *
this /= (float) len;
285 double dot_prod = this->
dot(other);
286 double len1 = this->
norm();
287 double len2 = other.
norm();
288 return acos(dot_prod / (len1*len2));
293 double dist_x =
x() - other.
x();
294 double dist_y =
y() - other.
y();
295 double dist_z =
z() - other.
z();
296 return sqrt(dist_x*dist_x + dist_y*dist_y + dist_z*dist_z);
300 double dist_x =
x() - other.
x();
301 double dist_y =
y() - other.
y();
302 return sqrt(dist_x*dist_x + dist_y*dist_y);
308 std::istream&
read(std::istream &s);
309 std::ostream&
write(std::ostream &s)
const;
Vector3 operator*(float x) const
Vector3()
Default constructor.
std::ostream & write(std::ostream &s) const
const float & roll() const
std::ostream & operator<<(std::ostream &s, const Pose6D &p)
user friendly output in format (x y z, u x y z) which is (translation, rotation)
double dot(const Vector3 &other) const
dot product
Vector3 & normalize()
normalizes this vector, so that it has norm=1.0
Vector3(const Vector3 &other)
Copy constructor.
std::istream & read(std::istream &s)
double distance(const Vector3 &other) const
const float & pitch() const
Vector3 cross(const Vector3 &other) const
Three-dimensional vector (cross) product.
double distanceXY(const Vector3 &other) const
Vector3 operator+(const Vector3 &other) const
double angleTo(const Vector3 &other) const
Vector3 & rotate_IP(double roll, double pitch, double yaw)
Vector3(float x, float y, float z)
Constructor.
std::ostream & writeBinary(std::ostream &s) const
std::istream & readBinary(std::istream &s)
void operator+=(const Vector3 &other)
const float & operator()(unsigned int i) const
This class represents a three-dimensional vector.
Vector3 operator-() const
const float & yaw() const
Vector3 normalized() const
void operator-=(const Vector3 &other)
Vector3 & operator=(const Vector3 &other)
Assignment operator.
bool operator==(const Vector3 &other) const