42 Point( std::pair<T, T> point )
43 :
x(point.first),
y(point.second) {}
52 return static_cast<T
>(atan2(
y,
x));
68 template<
typename U,
typename T>
77 IndexedPair() =
default;
87 IndexedPair<U, T> subtract(
const IndexedPair<U, T>& other )
const
92 bool operator==(
const IndexedPair<U, T>& other )
const
94 return index == other.index;
109 PointAngle(
const int& index, T angle )
110 : index(index), angle(angle) {}
118 PointAngle(
const int& ind,
const T& x,
const T& y )
124 bool operator<(
const PointAngle<T>& other )
const
126 return angle < other.angle;
129 bool operator>(
const PointAngle<T>& other )
const
131 return angle > other.angle;
153 :
X(in),
Y(in),
Z(in) {};
155 Vec3( T xin, T yin, T zin )
156 :
X(xin),
Y(yin),
Z(zin) {};
159 constexpr Vec3(
const Vec3<U>& other )
160 :
X(static_cast<T>(other.
X)),
Y(static_cast<T>(other.
Y)),
Z(static_cast<T>(other.
Z)) {}
164 Vec3 operator+(
const Vec3& other )
const
166 return Vec3(
X + other.X,
Y + other.Y,
Z + other.Z);
169 Vec3& operator+=(
const Vec3& other )
178 Vec3 operator-(
const Vec3& other )
const
180 return Vec3(
X - other.X,
Y - other.Y,
Z - other.Z);
183 Vec3& operator-=(
const Vec3& other )
192 Vec3 operator*( T scalar )
const
194 return Vec3(
X * scalar,
Y * scalar,
Z * scalar);
197 Vec3 operator*( Vec3 other )
const
199 return Vec3(
X * other.X,
Y * other.Y,
Z * other.Z);
202 Vec3& operator*=( T scalar )
211 Vec3 operator/( T scalar )
const
213 return Vec3(
X / scalar,
Y / scalar,
Z / scalar);
216 Vec3& operator/=( T scalar )
224 Vec3 operator/(
const Vec3& other )
const
226 return Vec3(
X / other.X,
Y / other.Y,
Z / other.Z);
229 Vec3& operator/=(
const Vec3& other )
240 return X == other.
X &&
Y == other.
Y &&
Z == other.
Z;
246 return X != other.
X ||
Y != other.
Y ||
Z != other.
Z;
274 T
Dot(
const Vec3& other )
const
276 return X * other.
X +
Y * other.
Y +
Z * other.
Z;
280 Vec3
Cross(
const Vec3& other )
const
282 return Vec3(
Y * other.
Z -
Z * other.
Y,
Z * other.
X -
X * other.
Z,
X * other.
Y -
Y * other.
X);
288 return X *
X +
Y *
Y +
Z *
Z;
300 return Vec3{fabs(
X), fabs(
Y), fabs(
Z)};
312 return fabs(
X) + fabs(
Y) + fabs(
Z);
constexpr double Y_PI
Famous PI value.
Definition Constants.h:14
constexpr double EPSILON
Value used for number stability check.
Definition Constants.h:17
Generic Types used in library.
Definition YasiuMathDataTypes.h:24
Categorized name spaces.
Definition Constants.h:10
Helper object, for point description in algorithm. Index and 2 values.
Definition YasiuMathDataTypes.h:69
T second
Definition YasiuMathDataTypes.h:75
U index
Definition YasiuMathDataTypes.h:71
T first
Definition YasiuMathDataTypes.h:73
Pair-like type, Helper for point description in ConvexHull algorithm.
Definition YasiuMathDataTypes.h:33
T x
Definition YasiuMathDataTypes.h:35
T fastAngle()
Get Angle from X/Y.
Definition YasiuMathDataTypes.h:46
T y
Definition YasiuMathDataTypes.h:37
Structure reflecting vector of size 3, Templated Type.
Definition YasiuMathDataTypes.h:142
bool operator==(const Vec3 &other) const
All elements must match.
Definition YasiuMathDataTypes.h:238
bool operator<(const Vec3 &other) const
Compare magnitudes.
Definition YasiuMathDataTypes.h:268
Vec3 Cross(const Vec3 &other) const
Cross product of 2 vectors.
Definition YasiuMathDataTypes.h:280
float Z
Definition YasiuMathDataTypes.h:148
Vec3 Normalize() const
Return copy of normalized vector.
Definition YasiuMathDataTypes.h:316
bool operator>(const T value) const
Compare magnitudes.
Definition YasiuMathDataTypes.h:250
T Sum() const
Sum inner elements.
Definition YasiuMathDataTypes.h:304
T LengthSquared() const
Length^2.
Definition YasiuMathDataTypes.h:286
float X
Definition YasiuMathDataTypes.h:144
Vec3 & NormalizeInPlace()
Normalize this vector.
Definition YasiuMathDataTypes.h:324
bool operator!=(const Vec3 &other) const
OnlY 1 can be different.
Definition YasiuMathDataTypes.h:244
bool IsNearly0(const T EPS=YasiuMath::Constants::EPSILON) const
Check if vector has any element other than 0, uses YasiuMath::Constants::EPSILON.
Definition YasiuMathDataTypes.h:336
T Dot(const Vec3 &other) const
Dot product of 2 vectors.
Definition YasiuMathDataTypes.h:274
bool operator>(const Vec3 &other) const
Compare magnitudes.
Definition YasiuMathDataTypes.h:262
float Y
Definition YasiuMathDataTypes.h:146
Vec3 Abs() const
Vector with absolute values.
Definition YasiuMathDataTypes.h:298
bool operator<(const T value) const
Compare magnitudes.
Definition YasiuMathDataTypes.h:256
T Length() const
Default Pythagoras Length.
Definition YasiuMathDataTypes.h:292
T AbsSum() const
Sum of absolute values of components.
Definition YasiuMathDataTypes.h:310