57 inline double x()
const {
62 inline double y()
const {
67 inline double z()
const {
87 void set(
double x,
double y) {
93 void set(
double x,
double y,
double z) {
114 void mul(
double mx,
double my) {
120 void mul(
double mx,
double my,
double mz) {
134 void add(
double dx,
double dy) {
140 void add(
double dx,
double dy,
double dz) {
147 void sub(
double dx,
double dy) {
153 void sub(
double dx,
double dy,
double dz) {
175 os << p.
x() <<
"," << p.
y();
176 if (p.
z() != double(0.0)) {
203 const double scalar = (length + offset) / length;
221 }
else if (
myY < p2.
myY) {
281 return (std::isnan(
myX) || std::isnan(
myY) || std::isnan(
myZ));
Position operator+(const Position &p2) const
add operator
bool almostSame(const Position &p2, double maxDiv=POSITION_EPS) const
check if two position is almost the sme as other
Position operator+(double offset) const
keep the direction but modify the length of the (location) vector to length + scalar ...
double z() const
Returns the z-position.
void add(const Position &pos)
Adds the given position to this one.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double y() const
Returns the y-position.
double x() const
Returns the x-position.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position ...
double myZ
The z-position.
void mul(double mx, double my, double mz)
Multiplies position with the given values.
static const Position & invalidPosition()
reference to invalid position (needed if INVALID is taken by macro-definition)
Position crossProduct(const Position &pos)
returns the cross product between this point and the second one
void sub(const Position &pos)
Substracts the given position from this one.
Position(double x, double y, double z)
Parametrised constructor.
A point in 2D or 3D with translation and scaling methods.
void setx(double x)
set position x
bool operator==(const Position &p2) const
comparation operator
void sub(double dx, double dy, double dz)
Substracts the given position from this one.
double myX
The x-position.
double distanceSquaredTo(const Position &p2) const
returns the square of the distance to another position
bool operator!=(const Position &p2) const
difference operator
void swapXY()
swap position X and Y
void mul(double mx, double my)
Multiplies position with the given values.
Position(double x, double y)
Parametrised constructor (only for x-y)
Position rotateAround2D(double rad, const Position &origin)
rotate this position by rad around origin and return the result
void add(double dx, double dy, double dz)
Adds the given position to this one.
friend std::ostream & operator<<(std::ostream &os, const Position &p)
output operator
double dotProduct(const Position &pos)
returns the dot product (scalar product) between this point and the second one
void sety(double y)
set position y
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions) ...
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
void mul(double val)
Multiplies both positions with the given value.
void add(double dx, double dy)
Adds the given position to this one.
double myY
The y-position.
Position()
default constructor
Position operator*(double scalar) const
keep the direction but modify the length of the (location) vector to length * scalar ...
Position operator-(const Position &p2) const
sub operator
bool isNAN() const
check if position is NAN
static const Position INVALID
used to indicate that a position is valid
bool operator<(const Position &p2) const
lexicographical sorting for use in maps and sets
void setz(double z)
set position z
void sub(double dx, double dy)
Substracts the given position from this one.