55 inline double x()
const {
60 inline double y()
const {
65 inline double z()
const {
91 void set(
double x,
double y,
double z) {
112 void mul(
double mx,
double my) {
118 void mul(
double mx,
double my,
double mz) {
132 void add(
double dx,
double dy) {
138 void add(
double dx,
double dy,
double dz) {
145 void sub(
double dx,
double dy) {
151 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;
213 const double scalar = (length - offset) / length;
231 }
else if (
myY < p2.
myY) {
296 return (std::isnan(
myX) || std::isnan(
myY) || std::isnan(
myZ));
A point in 2D or 3D with translation and scaling methods.
Position(double x, double y)
Parametrised constructor (only for x-y)
Position(double x, double y, double z)
Parametrised constructor.
void sub(const Position &pos)
Subtracts the given position from this one.
bool isNAN() const
check if position is NAN
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
void add(double dx, double dy)
Adds the given position to this one.
void add(double dx, double dy, double dz)
Adds the given position to this one.
Position()
default constructor
double slopeTo2D(const Position &other) const
returns the slope of the vector pointing from here to the other position
void setx(double x)
set position x
bool operator!=(const Position &p2) const
difference operator
void norm2d()
Normalises the given 2d position.
Position operator-(const Position &p2) const
sub operator
void set(const Position &pos)
set position with another position
void set(double x, double y)
set positions x and y
double dotProduct(const Position &pos)
returns the dot product (scalar product) between this point and the second one
static const Position INVALID
used to indicate that a position is valid
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
void sub(double dx, double dy)
Subtracts the given position from this one.
double distanceSquaredTo(const Position &p2) const
returns the square of the distance to another position
void sub(double dx, double dy, double dz)
Subtracts the given position from this one.
Position operator+(double offset) const
keep the direction but modify the length of the (location) vector to length + scalar
void mul(double mx, double my)
Multiplies position with the given values.
friend std::ostream & operator<<(std::ostream &os, const Position &p)
output operator
double x() const
Returns the x-position.
double myZ
The z-position.
Position operator*(double scalar) const
keep the direction but modify the length of the (location) vector to length * scalar
Position crossProduct(const Position &pos)
returns the cross product between this point and the second one
void swapXY()
swap position X and Y
Position operator-(double offset) const
keep the direction but modify the length of the (location) vector to length - scalar
void add(const Position &pos)
Adds the given position to this one.
bool operator==(const Position &p2) const
comparation operator
void set(double x, double y, double z)
set positions x, y and z
Position operator+(const Position &p2) const
add operator
void setz(double z)
set position z
double myY
The y-position.
bool operator<(const Position &p2) const
lexicographical sorting for use in maps and sets
void mul(double val)
Multiplies both positions with the given value.
Position rotateAround2D(double rad, const Position &origin)
rotate this position by rad around origin and return the result
double z() const
Returns the z-position.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
void sety(double y)
set position y
double myX
The x-position.
bool almostSame(const Position &p2, double maxDiv=POSITION_EPS) const
check if two position is almost the sme as other
void mul(double mx, double my, double mz)
Multiplies position with the given values.
double y() const
Returns the y-position.
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects