20#ifndef _SOURCE_TYPES_TFVECTOR2_H_
21#define _SOURCE_TYPES_TFVECTOR2_H_
25#include <Magnum/Math/Vector2.h>
26#include <Magnum/Math/Distance.h>
32 template<
class T>
using Vector2Base = Magnum::Math::Vector2<T>;
35 class TVector2 :
public Vector2Base<T> {
38 constexpr static TVector2<T>
xAxis(T
length = T(1)) {
return (TVector2<T>)Vector2Base<T>::xAxis(
length); }
41 constexpr static TVector2<T>
yAxis(T
length = T(1)) {
return (TVector2<T>)Vector2Base<T>::yAxis(
length); }
44 constexpr static TVector2<T>
xScale(T scale) {
return (TVector2<T>)Vector2Base<T>::xScale(scale); }
47 constexpr static TVector2<T>
yScale(T scale) {
return (TVector2<T>)Vector2Base<T>::yScale(scale); }
49 constexpr TVector2() noexcept: Vector2Base<T>() {}
51 constexpr explicit TVector2(T value)
noexcept: Vector2Base<T>(value) {}
53 constexpr TVector2(T
x, T
y)
noexcept: Vector2Base<T>(
x,
y) {}
55 template<
class U>
constexpr explicit TVector2(
const TVector2<U>& other)
noexcept: Vector2Base<T>(other) {}
58 T&
x() {
return Vector2Base<T>::x(); }
61 T&
y() {
return Vector2Base<T>::y(); }
64 constexpr T
x()
const {
return Vector2Base<T>::x(); }
67 constexpr T
y()
const {
return Vector2Base<T>::y(); }
70 template<class U = T, typename std::enable_if<std::is_floating_point<U>::value,
bool>::type =
true>
71 T
distance(
const TVector2<T> &lineStartPt,
const TVector2<T> &lineEndPt) {
72 return Magnum::Math::Distance::lineSegmentPoint(lineStartPt, lineEndPt, *
this);
75 template<class U = T, typename std::enable_if<std::is_floating_point<U>::value,
bool>::type =
true>
78 return lineStartPt + (*
this - lineStartPt).
dot(lineDir) * lineDir - *
this;
82 T
cross(
const TVector2<T> &other) {
83 return Magnum::Math::cross(*
this, other);
86 MAGNUM_BASE_VECTOR_CAST_METHODS(2,
TVector2, Vector2Base)
88 REVISED_MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(2, TVector2, Vector2Base)
91 SWIGPYTHON_MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(2, TVector2)
Definition tfVector2.h:35
static constexpr TVector2< T > yScale(T scale)
Definition tfVector2.h:47
constexpr T x() const
Definition tfVector2.h:64
std::enable_if< std::is_floating_point< U >::value, double >::type length() const
Definition tfVector2.h:88
T & y()
Definition tfVector2.h:61
std::enable_if< std::is_floating_point< U >::value, TVector2< T > >::type normalized() const
Definition tfVector2.h:88
static constexpr TVector2< T > xScale(T scale)
Definition tfVector2.h:44
T dot() const
Definition tfVector2.h:88
static constexpr TVector2< T > xAxis(T length=T(1))
Definition tfVector2.h:38
T cross(const TVector2< T > &other)
Definition tfVector2.h:82
constexpr T y() const
Definition tfVector2.h:67
static constexpr TVector2< T > yAxis(T length=T(1))
Definition tfVector2.h:41
T distance(const TVector2< T > &lineStartPt, const TVector2< T > &lineEndPt)
Definition tfVector2.h:71
T & x()
Definition tfVector2.h:58
Native Tissue Forge type definitions.
Definition tfMatrix.h:33