144 T& operator[](
size_t);
150 const T& operator[](
size_t) const;
160 constexpr const T*
data() const;
165 constexpr operator T*();
170 constexpr operator const T*() const;
175 constexpr T
x() const;
185 constexpr T
y() const;
317 static constexpr auto
tolerance = std::numeric_limits<T>::epsilon() * 10.0;
343 friend class TRectangle2D<T>;
349 return {v.
x() * c, v.
y() * c};
355 return {v.
x() * c, v.
y() * c};
365 constexpr auto delimiter =
')';
366 std::getline(is, s, delimiter);
367 v.fromString(s.append(1, delimiter));
383#include <math/TVector2D.hpp>
Generic 2 x 2 matrix template.
Definition TMatrix22.h:16
2-dimensional vector for math operations.
Definition TVector2D.h:23
T lengthSqr() const
Gets the squared length or magnitude of the vector.
TVector2D(const TVector2D &v)
Copy constructor.
T distanceSqr(const TVector2D &) const
Gets the squared distance between 2 given points. Avoids taking an expensive sqrt call....
static constexpr auto tolerance
Tolerance for when comparing in the equal operator. Empirical chosen epsilon multiplier to make it wo...
Definition TVector2D.h:317
TVector2D & fromString(const std::string &s) noexcept(false)
Gets the vector value from the string representation formed like '(1.23,4.56)'. Throws an exception w...
T dotProduct(const TVector2D &) const
Gets the dot (in) product of 2 vectors.
TVector2D(TVector2D &&) noexcept
Move constructor.
TVector2D scaled(T factor) const
Scales the vector by multiplying all axis with the passed factor.
static int areOnSameSide(const TVector2D &lp1, const TVector2D &lp2, const TVector2D &p1, const TVector2D &p2)
Checks where 2 points lie in relation to a given line given by 2 points.
std::string toString() const
Gets the string representation of the 2D vector formed like '(1.23,4.56)'.
TVector2D & scale(T factor)
Scales the vector by multiplying all axis with the passed factor.
constexpr T * data()
Gets a const pointer to the data.
TVector2D normalized() const
Gets a normalized vector also called a unit-vector, made of length 1.
T angleNormalized() const
Returns a normalized positive angle of function angle().
TVector2D & assign(T xp, T yp)
Assignment of new coordinate values.
T angle(const TVector2D &) const
Gets the angle between the two vectors.
union sf::TVector2D::data_type _data
TVector2D()=default
Default constructor.
T slope() const
Gets the slope (coefficient) of the line formed with the origin (0, 0). When it is an infinite value ...
T crossProduct(const TVector2D &) const
Gets the cross (out) product of 2 vectors.
void updateMax(const TVector2D &vertex)
Copy only those values of x or y which are larger.
T length() const
Gets the length or magnitude of the vector.
TVector2D & normalize()
Normalizes the vector also called a unit-vector, set to length 1.
constexpr T x() const
Gets the x-coordinate value.
constexpr T y() const
Gets the y-coordinate value.
T distance(const TVector2D &) const
Gets the distance between this and the passed vector. Note that this has to return a double because i...
T value_type
Type declaration of the coordinate storage values.
Definition TVector2D.h:28
bool isEqual(const TVector2D &v, T tol=tolerance) const
Compares the passed vector within the set tolerance.
void updateMin(const TVector2D &vertex)
Copy only those values of x or y which are smaller.
Definition Application.h:10
_GII_FUNC std::istream & operator>>(std::istream &is, ResultData &)
Stream operator for setting up this instance with a setup std::string.
TMatrix44< T > operator*(const TMatrix44< T > &lm, const TMatrix44< T > &rm)
Multiplies to matrices into a single one.
_GII_FUNC std::ostream & operator<<(std::ostream &os, const ResultData &)
Stream operator for the setup std::string.
Definition TVector2D.h:337
T y
Definition TVector2D.h:339
T x
Definition TVector2D.h:338
Storage union of the 2D coordinate making the x,y accessible as an array.
Definition TVector2D.h:334