Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
TQuat2< T > Class Template Reference

#include <TransformCalculus2D.h>

Public Types

using FReal = T
 
using Vector2Type = UE::Math::TVector2<T>
 

Public Member Functions

 TQuat2 ()
 
 TQuat2 (T RotRadians)
 
template<typename VType >
 TQuat2 (const UE::Math::TVector2< VType > &InRot)
 
template<typename ArgType >
UE::Math::TVector2< ArgType > TransformPoint (const UE::Math::TVector2< ArgType > &Point) const
 
template<typename ArgType >
UE::Math::TVector2< ArgType > TransformVector (const UE::Math::TVector2< ArgType > &Vector) const
 
TQuat2 Concatenate (const TQuat2 &RHS) const
 
TQuat2 Inverse () const
 
bool operator== (const TQuat2 &Other) const
 
bool operator!= (const TQuat2 &Other) const
 
const Vector2TypeGetVector () const
 

Private Attributes

Vector2Type Rot
 

Detailed Description

template<typename T>
class TQuat2< T >

Represents a 2D rotation as a complex number (analagous to quaternions). Rot(theta) == cos(theta) + i * sin(theta) General transformation follows complex number algebra from there. Does not use "spinor" notation using theta/2 as we don't need that decomposition for our purposes. This makes the implementation for straightforward and efficient for 2D.

Definition at line 294 of file TransformCalculus2D.h.

Member Typedef Documentation

◆ FReal

template<typename T >
using TQuat2< T >::FReal = T

Definition at line 299 of file TransformCalculus2D.h.

◆ Vector2Type

template<typename T >
using TQuat2< T >::Vector2Type = UE::Math::TVector2<T>

Definition at line 300 of file TransformCalculus2D.h.

Constructor & Destructor Documentation

◆ TQuat2() [1/3]

template<typename T >
TQuat2< T >::TQuat2 ( )
inline

Ctor. initialize to an identity rotation.

Definition at line 303 of file TransformCalculus2D.h.

◆ TQuat2() [2/3]

template<typename T >
TQuat2< T >::TQuat2 ( T RotRadians)
inlineexplicit

Ctor. initialize from a rotation in radians.

Definition at line 305 of file TransformCalculus2D.h.

◆ TQuat2() [3/3]

template<typename T >
template<typename VType >
TQuat2< T >::TQuat2 ( const UE::Math::TVector2< VType > & InRot)
inlineexplicit

Ctor. initialize from an FVector2D, representing a complex number.

Definition at line 308 of file TransformCalculus2D.h.

Member Function Documentation

◆ Concatenate()

template<typename T >
TQuat2 TQuat2< T >::Concatenate ( const TQuat2< T > & RHS) const
inline

Transform 2 rotations defined by complex numbers: In imaginary land: (A + Bi) * (C + Di) == (AC - BD) + (AD + BC)i

Looking at this as a matrix, A == cos(theta), B == sin(theta), C == cos(sigma), D == sin(sigma):

[ A B] * [ C D] == [ AC-BD AD+BC] [-B A] [-D C] [-(AD+BC) AC-BD]

If you look at how the vector multiply works out: [X(AC-BD)+Y(-BC-AD) X(AD+BC)+Y(-BD+AC)] you can see it follows the same form of the imaginary form. Indeed, check out how the matrix nicely works out to [ A B] for a visual proof of the results. [-B A]

Definition at line 350 of file TransformCalculus2D.h.

◆ GetVector()

template<typename T >
const Vector2Type & TQuat2< T >::GetVector ( ) const
inline

Access to the underlying FVector2D that stores the complex number.

Definition at line 377 of file TransformCalculus2D.h.

◆ Inverse()

template<typename T >
TQuat2 TQuat2< T >::Inverse ( ) const
inline

Invert the rotation defined by complex numbers: In imaginary land, an inverse is a complex conjugate, which is equivalent to reflecting about the X axis: Conj(A + Bi) == A - Bi

Definition at line 359 of file TransformCalculus2D.h.

◆ operator!=()

template<typename T >
bool TQuat2< T >::operator!= ( const TQuat2< T > & Other) const
inline

Inequality.

Definition at line 371 of file TransformCalculus2D.h.

◆ operator==()

template<typename T >
bool TQuat2< T >::operator== ( const TQuat2< T > & Other) const
inline

Equality.

Definition at line 365 of file TransformCalculus2D.h.

◆ TransformPoint()

template<typename T >
template<typename ArgType >
UE::Math::TVector2< ArgType > TQuat2< T >::TransformPoint ( const UE::Math::TVector2< ArgType > & Point) const
inline

Transform a 2D point by the 2D complex number representing the rotation: In imaginary land: (x + yi) * (u + vi) == (xu - yv) + (xv + yu)i

Looking at this as a matrix, x == cos(A), y == sin(A)

[x y] * [ cosA sinA] == [x y] * [ u v] == [xu-yv xv+yu] [-sinA cosA] [-v u]

Looking at the above results, we see the equivalence with matrix multiplication.

Definition at line 322 of file TransformCalculus2D.h.

◆ TransformVector()

template<typename T >
template<typename ArgType >
UE::Math::TVector2< ArgType > TQuat2< T >::TransformVector ( const UE::Math::TVector2< ArgType > & Vector) const
inline

Vector rotation is equivalent to rotating a point.

Definition at line 332 of file TransformCalculus2D.h.

Member Data Documentation

◆ Rot

template<typename T >
Vector2Type TQuat2< T >::Rot
private

Underlying storage of the rotation (X = cos(theta), Y = sin(theta).

Definition at line 381 of file TransformCalculus2D.h.


The documentation for this class was generated from the following file: