6#include <Common/assertion.h>
27 const TVector2<T> diagonallyMirroredPoint(point.
y(), point.
x());
37 return diagonallyMirroredPoint.
abs().complement() *
38 TVector2<T>(point.
x() >= 0.0f ? 1.0f : -1.0f, point.
y() >= 0.0f ? 1.0f : -1.0f);
62 if(octahedronProj.
z() < 0)
65 octahedronProj.
x() = mirroredXYProj.
x();
66 octahedronProj.
y() = mirroredXYProj.
y();
69 return TVector2<T>(octahedronProj.
x(), octahedronProj.
y()) *
static_cast<T
>(0.5) +
static_cast<T
>(0.5);
79 PH_ASSERT_IN_RANGE_INCLUSIVE(encodedVal.
x(), 0, 1);
80 PH_ASSERT_IN_RANGE_INCLUSIVE(encodedVal.
y(), 0, 1);
85 const TVector2<T> expandedEncodedVal = encodedVal *
static_cast<T
>(2) -
static_cast<T
>(1);
88 expandedEncodedVal.
x(),
89 expandedEncodedVal.
y(),
90 static_cast<T
>(1) - expandedEncodedVal.
abs().sum());
91 if(octahedronProj.
z() < 0)
94 octahedronProj.
x() = mirroredXYProj.
x();
95 octahedronProj.
y() = mirroredXYProj.
y();
Represents a 2-D vector.
Definition TVector2.h:19
T & x()
Definition TVector2.ipp:38
T & y()
Definition TVector2.ipp:44
Represents a 3-D vector.
Definition TVector3.h:17
T & y()
Definition TVector3.ipp:189
T & z()
Definition TVector3.ipp:195
T & x()
Definition TVector3.ipp:183
Derived normalize() const
Normalize the vector. Notice that normalizing a integer typed vector will result in 0-vector most of ...
Definition TVectorNBase.ipp:50
Derived abs() const
Definition TArithmeticArrayBase.ipp:466
TVector2< T > octahedron_diamond_mirror(const TVector2< T > &point)
Definition geometry.h:25
Math functions and utilities.
Definition TransformInfo.h:10
TVector2< T > octahedron_unit_vector_encode(const TVector3< T > &unitVec)
Encode a unit vector using octahedron projection.
Definition geometry.h:59
TVector3< T > octahedron_unit_vector_decode(const TVector2< T > &encodedVal)
Decode and get a unit vector using octahedron projection.
Definition geometry.h:77