5#ifndef DCPP_POINT_2D_HPP_INCLUDED 
    6#define DCPP_POINT_2D_HPP_INCLUDED 
    8#include <duckcpp/core/engine/irrMath.hpp> 
    9#include <duckcpp/core/engine/dimension2d.hpp> 
   35    vector2d<T> operator-()
 const { 
return vector2d<T>(-
X, -
Y); }
 
   37    vector2d<T>& operator=(
const dimension2d<T>& other) { 
X = other.Width; 
Y = other.Height; 
return *
this; }
 
   39    vector2d<T> operator+(
const vector2d<T>& other)
 const { 
return vector2d<T>(
X + other.X, 
Y + other.Y); }
 
   40    vector2d<T> operator+(
const dimension2d<T>& other)
 const { 
return vector2d<T>(
X + other.Width, 
Y + other.Height); }
 
   41    vector2d<T>& operator+=(
const vector2d<T>& other) { 
X+=other.X; 
Y+=other.Y; 
return *
this; }
 
   42    vector2d<T> operator+(
const T v)
 const { 
return vector2d<T>(
X + v, 
Y + v); }
 
   43    vector2d<T>& operator+=(
const T v) { 
X+=v; 
Y+=v; 
return *
this; }
 
   44    vector2d<T>& operator+=(
const dimension2d<T>& other) { 
X += other.Width; 
Y += other.Height; 
return *
this;  }
 
   46    vector2d<T> operator-(
const vector2d<T>& other)
 const { 
return vector2d<T>(
X - other.X, 
Y - other.Y); }
 
   47    vector2d<T> operator-(
const dimension2d<T>& other)
 const { 
return vector2d<T>(
X - other.Width, 
Y - other.Height); }
 
   48    vector2d<T>& operator-=(
const vector2d<T>& other) { 
X-=other.X; 
Y-=other.Y; 
return *
this; }
 
   49    vector2d<T> operator-(
const T v)
 const { 
return vector2d<T>(
X - v, 
Y - v); }
 
   50    vector2d<T>& operator-=(
const T v) { 
X-=v; 
Y-=v; 
return *
this; }
 
   51    vector2d<T>& operator-=(
const dimension2d<T>& other) { 
X -= other.Width; 
Y -= other.Height; 
return *
this;  }
 
   53    vector2d<T> operator*(
const vector2d<T>& other)
 const { 
return vector2d<T>(
X * other.X, 
Y * other.Y); }
 
   54    vector2d<T>& operator*=(
const vector2d<T>& other) { 
X*=other.X; 
Y*=other.Y; 
return *
this; }
 
   55    vector2d<T> operator*(
const T v)
 const { 
return vector2d<T>(
X * v, 
Y * v); }
 
   56    vector2d<T>& operator*=(
const T v) { 
X*=v; 
Y*=v; 
return *
this; }
 
   58    vector2d<T> operator/(
const vector2d<T>& other)
 const { 
return vector2d<T>(
X / other.X, 
Y / other.Y); }
 
   59    vector2d<T>& operator/=(
const vector2d<T>& other) { 
X/=other.X; 
Y/=other.Y; 
return *
this; }
 
   60    vector2d<T> operator/(
const T v)
 const { 
return vector2d<T>(
X / v, 
Y / v); }
 
   61    vector2d<T>& operator/=(
const T v) { 
X/=v; 
Y/=v; 
return *
this; }
 
   65        DCPP_DEBUG_BREAK_IF(index>1) 
 
   72        DCPP_DEBUG_BREAK_IF(index>1) 
 
  106    bool operator!=(
const vector2d<T>& other)
 const { 
return !
equals(other); }
 
  121    vector2d<T>& set(
const vector2d<T>& p) { 
X=p.X; 
Y=p.Y; 
return *
this; }
 
  213            return X < 0 ? 180 : 0;
 
  216            return Y < 0 ? 270 : 90;
 
 
  236            return X < 0 ? 180 : 0;
 
  238            return Y < 0 ? 90 : 270;
 
 
  295        if (begin.X != end.X)
 
  297            return ((begin.X <= 
X && 
X <= end.X) ||
 
  298                    (begin.X >= 
X && 
X >= end.X));
 
  302            return ((begin.Y <= 
Y && 
Y <= end.Y) ||
 
  303                    (begin.Y >= 
Y && 
Y >= end.Y));
 
 
  352        T val = (b.Y - 
Y) * (c.X - b.X) -
 
  353            (b.X - 
X) * (c.Y - b.Y);
 
  355        if (
val == 0) 
return 0;  
 
  357        return (
val > 0) ? 1 : 2; 
 
 
  363        T val = (b.Y - 
Y) * (c.X - b.X) -
 
  364            (b.X - 
X) * (c.Y - b.Y);
 
 
  372        T val = (b.Y - 
Y) * (c.X - b.X) -
 
  373            (b.X - 
X) * (c.Y - b.Y);
 
 
 
  404    template<
class S, 
class T>
 
  412    bool dimension2d<T>::operator==(
const vector2d<T>& other)
 const { 
return Width == other.X && Height == other.Y; }
 
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
 
dimension2d()
Default constructor for empty dimension.
Definition dimension2d.hpp:24
 
2d vector template class with lots of operators and methods.
Definition vector2d.hpp:22
 
T getDistanceFromSQ(const vector2d< T > &other) const
Returns squared distance from another point.
Definition vector2d.hpp:167
 
vector2d(T n)
Constructor with the same value for both members.
Definition vector2d.hpp:29
 
vector2d< T > getInterpolated(const vector2d< T > &other, dcpp::float64_kt d) const
Creates an interpolated vector between this vector and another vector.
Definition vector2d.hpp:312
 
T getLength() const
Gets the length of the vector.
Definition vector2d.hpp:125
 
T X
X coordinate of vector.
Definition vector2d.hpp:392
 
vector2d(T nx, T ny)
Constructor with two different values.
Definition vector2d.hpp:27
 
dcpp::float64_kt getAngleTrig() const
Calculates the angle of this vector in degrees in the trigonometric sense.
Definition vector2d.hpp:210
 
bool operator>(const vector2d< T > &other) const
sort in order X, Y. Difference must be above rounding tolerance.
Definition vector2d.hpp:99
 
bool operator>=(const vector2d< T > &other) const
sort in order X, Y. Equality with rounding tolerance.
Definition vector2d.hpp:85
 
dcpp::float64_kt getAngle() const
Calculates the angle of this vector in degrees in the counter trigonometric sense.
Definition vector2d.hpp:233
 
bool areClockwise(const vector2d< T > &b, const vector2d< T > &c) const
Definition vector2d.hpp:361
 
vector2d< T > getInterpolated_quadratic(const vector2d< T > &v2, const vector2d< T > &v3, dcpp::float64_kt d) const
Creates a quadratically interpolated vector between this and two other vectors.
Definition vector2d.hpp:324
 
dcpp::float64_kt getAngleWith(const vector2d< T > &b) const
Calculates the angle between this vector and another one in degree.
Definition vector2d.hpp:263
 
vector2d< T > & normalize()
Normalize the vector.
Definition vector2d.hpp:195
 
T getLengthSQ() const
Get the squared length of this vector.
Definition vector2d.hpp:130
 
vector2d< T > & interpolate(const vector2d< T > &a, const vector2d< T > &b, dcpp::float64_kt d)
Sets this vector to the linearly interpolated vector between a and b.
Definition vector2d.hpp:384
 
T Y
Y coordinate of vector.
Definition vector2d.hpp:395
 
bool nearlyParallel(const vector2d< T > &other, const T factor=relativeErrorFactor< T >()) const
check if this vector is parallel to another vector
Definition vector2d.hpp:141
 
dcpp::int32_kt checkOrientation(const vector2d< T > &b, const vector2d< T > &c) const
Definition vector2d.hpp:341
 
T getDistanceFrom(const vector2d< T > &other) const
Gets distance from another point.
Definition vector2d.hpp:158
 
vector2d< T > & rotateBy(dcpp::float64_kt degrees, const vector2d< T > ¢er=vector2d< T >())
rotates the point anticlockwise around a center by an amount of degrees.
Definition vector2d.hpp:176
 
T dotProduct(const vector2d< T > &other) const
Get the dot product of this vector with another.
Definition vector2d.hpp:135
 
bool areCounterClockwise(const vector2d< T > &b, const vector2d< T > &c) const
Definition vector2d.hpp:370
 
vector2d()
Default constructor (null vector)
Definition vector2d.hpp:25
 
bool equals(const vector2d< T > &other, const T tolerance=(T) ROUNDING_ERROR_Float32) const
Checks if this vector equals the other one.
Definition vector2d.hpp:115
 
bool operator<(const vector2d< T > &other) const
sort in order X, Y. Difference must be above rounding tolerance.
Definition vector2d.hpp:92
 
bool isBetweenPoints(const vector2d< T > &begin, const vector2d< T > &end) const
Returns if this vector interpreted as a point is on a line between two other points.
Definition vector2d.hpp:284
 
bool equalsRelative(const T a, const T b, const T factor=relativeErrorFactor< T >())
Definition irrMath.hpp:252
 
const dcpp::float64_kt DEGTORAD64
64bit constant for converting from degrees to radians (formally known as GRAD_PI2)
Definition irrMath.hpp:78
 
bool equals(const T a, const T b, const T tolerance=roundingError< T >())
returns if a equals b, taking possible rounding errors into account
Definition irrMath.hpp:243
 
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition irrMath.hpp:164
 
const dcpp::float64_kt RADTODEG64
64bit constant for converting from radians to degrees
Definition irrMath.hpp:81
 
As of Duckcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
 
double float64_kt
64 bit floating point variable.
Definition irrTypes.hpp:112
 
unsigned int uint32_kt
32 bit unsigned variable.
Definition irrTypes.hpp:64
 
float float32_kt
32 bit floating point variable.
Definition irrTypes.hpp:108
 
signed int int32_kt
32 bit signed variable.
Definition irrTypes.hpp:72