20#ifndef _SOURCE_TYPES_TFVECTOR3_H_
21#define _SOURCE_TYPES_TFVECTOR3_H_
25#include <Magnum/Math/Vector3.h>
26#include <Magnum/Math/Distance.h>
32 template<
class T>
using Vector3Base = Magnum::Math::Vector3<T>;
35 class TVector3 :
public Vector3Base<T> {
37 constexpr static TVector3<T> xAxis(T
length = T(1)) {
return (TVector3<T>)Vector3Base<T>::xAxis(
length); }
39 constexpr static TVector3<T> yAxis(T
length = T(1)) {
return (TVector3<T>)Vector3Base<T>::yAxis(
length); }
41 constexpr static TVector3<T> zAxis(T
length = T(1)) {
return (TVector3<T>)Vector3Base<T>::zAxis(
length); }
43 constexpr static TVector3<T> xScale(T scale) {
return (TVector3<T>)Vector3Base<T>::xScale(scale); }
45 constexpr static TVector3<T> yScale(T scale) {
return (TVector3<T>)Vector3Base<T>::yScale(scale); }
47 constexpr static TVector3<T> zScale(T scale) {
return (TVector3<T>)Vector3Base<T>::zScale(scale); }
49 constexpr TVector3()
noexcept: Vector3Base<T>() {}
51 constexpr explicit TVector3(T value)
noexcept: Vector3Base<T>(value) {}
53 constexpr TVector3(T
x, T
y, T
z)
noexcept: Vector3Base<T>(
x,
y,
z) {}
57 template<
class U>
constexpr explicit TVector3(
const TVector3<U>& other)
noexcept: Vector3Base<T>(other) {}
60 T&
x() {
return Vector3Base<T>::x(); }
63 T&
y() {
return Vector3Base<T>::y(); }
66 T&
z() {
return Vector3Base<T>::z(); }
69 constexpr T
x()
const {
return Vector3Base<T>::x(); }
72 constexpr T
y()
const {
return Vector3Base<T>::y(); }
75 constexpr T
z()
const {
return Vector3Base<T>::z(); }
78 T&
r() {
return Vector3Base<T>::r(); }
81 T&
g() {
return Vector3Base<T>::g(); }
84 T&
b() {
return Vector3Base<T>::b(); }
87 constexpr T
r()
const {
return Vector3Base<T>::r(); }
90 constexpr T
g()
const {
return Vector3Base<T>::g(); }
93 constexpr T
b()
const {
return Vector3Base<T>::b(); }
100 return {Vector3Base<T>::_data[0], Vector3Base<T>::_data[1]};
104 template<class U = T, typename std::enable_if<std::is_floating_point<U>::value,
bool>::type =
true>
105 T
distance(
const TVector3<T> &lineStartPt,
const TVector3<T> &lineEndPt) {
106 return Magnum::Math::Distance::lineSegmentPoint(lineStartPt, lineEndPt, *
this);
118 template<class U = T, typename std::enable_if<std::is_floating_point<U>::value,
bool>::type =
true>
120 const TVector3<T> lineDir = (lineEndPt - lineStartPt).
normalized();
121 return lineStartPt + (*
this - lineStartPt).
dot(lineDir) * lineDir - *
this;
124 template<class U = T, typename std::enable_if<std::is_floating_point<U>::value,
bool>::type =
true>
129 if(result[0] < -crit[0]) result[0] += dim[0];
130 else if(result[0] > crit[0]) result[0] -= dim[0];
133 if(result[1] < -crit[1]) result[1] += dim[1];
134 else if(result[1] > crit[1]) result[1] -= dim[1];
137 if(result[2] < -crit[2]) result[2] += dim[2];
138 else if(result[2] > crit[2]) result[2] -= dim[2];
144 TVector3<T>
cross(
const TVector3<T> &other) {
145 return Magnum::Math::cross(*
this, other);
148 MAGNUM_BASE_VECTOR_CAST_METHODS(3,
TVector3, Vector3Base)
150 REVISED_MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(3, TVector3, Vector3Base)
153 SWIGPYTHON_MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(3, TVector3)
Definition tfVector2.h:35
static TVector2< T > & from(T *data)
Definition tfVector2.h:88
Definition tfVector3.h:35
constexpr T g() const
Definition tfVector3.h:90
std::enable_if< std::is_floating_point< U >::value, T >::type length() const
Definition tfVector3.h:150
TVector3< T > lineShortestDisplacementTo(const TVector3< T > &lineStartPt, const TVector3< T > &lineEndPt) const
Get the position relative to a point.
Definition tfVector3.h:119
T & r()
Definition tfVector3.h:78
TVector3< T > cross(const TVector3< T > &other)
Definition tfVector3.h:144
constexpr T b() const
Definition tfVector3.h:93
T & g()
Definition tfVector3.h:81
TVector2< T > & xy()
Definition tfVector3.h:96
T & x()
Definition tfVector3.h:60
T & z()
Definition tfVector3.h:66
constexpr T x() const
Definition tfVector3.h:69
T & y()
Definition tfVector3.h:63
constexpr T y() const
Definition tfVector3.h:72
constexpr const TVector2< T > xy() const
Definition tfVector3.h:99
T dot() const
Definition tfVector3.h:150
constexpr T z() const
Definition tfVector3.h:75
std::enable_if< std::is_floating_point< U >::value, TVector3< T > >::type normalized() const
Definition tfVector3.h:150
T distance(const TVector3< T > &lineStartPt, const TVector3< T > &lineEndPt)
Definition tfVector3.h:105
T & b()
Definition tfVector3.h:84
constexpr T r() const
Definition tfVector3.h:87
Native Tissue Forge type definitions.
Definition tfMatrix.h:33