The Vish Visualization Shell 0.3
Vish
Public Member Functions | Friends | Related Symbols | List of all members
Eagle::PhysicalSpace::rotor Class Reference

A rotor is the sum of scalar with a bivector. More...

#include <elementary/eagle/rotor3.hpp>

Inheritance diagram for Eagle::PhysicalSpace::rotor:
Eagle::Vector< double, 4 > Eagle::FixedArray< value, N >

Public Member Functions

bivectorbivec ()
 Retrieve bivector component, read-only.
 
const bivectorbivec () const
 Retrieve bivector component, read-only.
 
rotor conj () const
 Compute the conjugate rotor.
 
rotor inv () const
 Compute the inverse rotor.
 
bivector operator() (const bivector &V) const
 Rotate a bivector.
 
vector operator() (const vector &v) const
 The sandwich product: Compute Rv ~R, which is the rotation of the vector v by the current rotor.
 
OddMultiVector operator* () const
 Applying the hodge star operator.
 
 rotor ()
 Default constructor.
 
 rotor (const bivector &b, double r)
 Construct rotor from bivector and scalar.
 
 rotor (const double s)
 Create rotor with just scalar component, bivector is zero.
 
 rotor (const rotor &b)
 Copy constructor.
 
 rotor (const rotor &b, const Operator<'~'> &)
 Computational constructor computing the conjugate (inverse) rotor.
 
 rotor (const Vector< double, 4 > &V)
 Explicit construction from double.
 
 rotor (double r, const bivector &b)
 Construct rotor from scalar and bivector.
 
 rotor (double r, double b1, double b2, double b3)
 Construct rotor from four doubles.
 
double & scalar ()
 Retrieve scalar component, modifyable.
 
double scalar () const
 Retrieve scalar component, read-only.
 
rotor unit () const
 Normalize to a unit rotor (added by mr).
 
- Public Member Functions inherited from Eagle::Vector< double, 4 >
Base_tfixed_array ()
 Provide access to the base class, writable.
 
const Base_tfixed_array () const
 Provide access to the base class, read-only.
 
Vectoroperator*= (const double &value)
 Self-multiplication.
 
Vectoroperator+= (const Vector &v)
 Self-addition.
 
Vector operator- () const
 Unary minus.
 
Vectoroperator-= (const Vector &v)
 Self-subtraction.
 
Vectoroperator/= (const double &value)
 Self-division.
 
Assignment< Vector, 0 > operator= (const scalar &x)
 Assign first element with scalar and use consecutive comma expressions for assignment of further elements As such a Vector may be assigned as.
 
Vectoroperator= (const Vector &src)
 Assignment operator.
 
void set (const V &value)
 Assign all values to the same scalar.
 
constexpr Vector ()
 Default constructor.
 
 Vector (const double &a)
 Convenience Constructor: initialize the first element.
 
 Vector (const double &a, const double &b)
 Convenience Constructor: initialize the first two elements.
 
 Vector (const double &a, const double &b, const double &c)
 Convenience Constructor: initialize the first three elements.
 
 Vector (const double &a, const double &b, const double &c, const double &d)
 Convenience Constructor: initialize the first four elements.
 
 Vector (const FixedArray< AType, n > &l, const FixedArray< BType, n > &r, const Operator< CompType > &Op)
 Computational constructor for binary operations on two fixed arrays, calls the Operator's ternary() member function for each element.
 
 Vector (const FixedArray< AType, n > &l, const Operator< CompType > &, const ScalarType &scalar)
 Computational constructor from vector with scalar, calls the Operator's ternary() member function for each element and the scalar as its 3rd argument.
 
 Vector (const FixedArray< InputType, SIZE > &V)
 Type conversion constructor.
 
 Vector (const Indicable &I, const AnyType &)
 Construct from indicable object, i.e.
 
 Vector (const Operator< CompType > &, const ScalarType &scalar, const FixedArray< AType, n > &v)
 Computational constructor from scalar with vector calls the Operator's ternary() member function for each element and the scalar as its 2nd argument.
 
constexpr Vector (const std::initializer_list< InputType > &Init)
 Construct from a initialization array.
 
 Vector (const Vector &l, const Vector &r, const Operator< CompType > &)
 Computational constructor for binary operations on two vectors calls the Operator's ternary() member function for each element.
 
 Vector (const Vector &NV, const Sub &, const Sub &)
 Computational constructor for unary minus.
 
constexpr Vector (const Vector &v)
 Copy constructor.
 
 Vector (const Vector &v, const Operator<'-'> &)
 Unitary minus computational constructor Applies the unitary minus to each element.
 
 Vector (const Vector< InputType, SIZE > &V)
 Type conversion constructor.
 
- Public Member Functions inherited from Eagle::FixedArray< value, N >
void expandMinMax (FixedArray &MinValues, FixedArray &MaxValues) const
 Expand a range given by MinValues,MaxValues to include the values of this array, done per component.
 
constexpr FixedArray () noexcept
 Default constructor.
 
template<class AType , class BType , OperatorID_t CompType>
constexpr FixedArray (const FixedArray< AType, N > &l, const FixedArray< BType, N > &r, const Operator< CompType > &)
 Computational constructor for binary operations on two fixed arrays, calls the Operator's ternary() member function for each element.
 
template<typename T , dimension_t M>
constexpr FixedArray (const FixedArray< T, M > &F, const T &DefaultValue)
 Construct array from another array type of variable length.
 
template<typename T >
constexpr FixedArray (const FixedArray< T, N > &F)
 Automatic type conversion function.
 
template<typename T , typename ConversionFunctor >
constexpr FixedArray (const FixedArray< T, N > &F, const ConversionFunctor &CF, const FA_CONVERT &)
 Construct array from another array type of same length.
 
template<class InitType >
constexpr FixedArray (const std::initializer_list< InitType > &Init)
 Construct from a initialization array.
 
constexpr FixedArray (const value &a)
 Convenience Constructor: initialize the first element.
 
constexpr FixedArray (const value &a, const value &b)
 Convenience Constructor: initialize the first two elements.
 
 FixedArray (const value &a, const value &b, const value &c)
 Convenience Constructor: initialize the first three elements.
 
constexpr FixedArray (const value &a, const value &b, const value &c, const value &d)
 Convenience Constructor: initialize the first four elements.
 
constexpr FixedArray (const value &a, const value &b, const value &c, const value &d, const value &e)
 Convenience Constructor: initialize the first five elements.
 
constexpr value & get (int i)
 writable element access
 
constexpr const value & get (int i) const
 read-only element access
 
template<int subsize, int offset>
constexpr const FixedArray< value, subsize > * get_subarray () const
 Helper class for retrieve a subset of the current array.
 
constexpr const FixedArray< value, SIZE-1 > & get_subdim () const
 Mainly introduced because of Interpolate::operator[].
 
const FixedArray_tgetFixedArray () const noexcept
 convenience function for base classes
 
FixedArray_tgetFixedArray () noexcept
 convenience function for base classes
 
constexpr value getMax () const
 Compute the maximum element value of this array.
 
constexpr value getMin () const
 Compute the maximum element value of this array.
 
template<typename T >
constexpr bool operator!= (const FixedArray< T, N > &F) const
 Compare two arrays.
 
template<typename T >
constexpr bool operator== (const FixedArray< T, N > &F) const
 Compare two arrays.
 
constexpr value & operator[] (int i)
 writeable element access operator
 
constexpr const value & operator[] (int i) const
 read-only element access operator
 
constexpr value * ptr (int i=0) noexcept
 Return a pointer to the ith element, no range checking.
 
template<class Value >
constexpr void set (const Value &x)
 Set all array elements to the same value.
 
void setFromArray (const value *x, int length=SIZE, int offset=0)
 Set all array elements to an array's element value.
 
void sort (FixedArray< int, N > &I) const
 Sort the elements of an array into the index array.
 

Friends

eagle_API rotor operator* (const rotor &, const rotor &)
 Multiply rotors, which is a concatenation operation of rotations.
 
OddMultiVector operator* (const rotor &, const vector &)
 Multiply rotor and vector, yielding an odd multivector, the dual of a rotor.
 
bivectoroperator*= (bivector &V, const rotor &R)
 Rotate a certain bivector by a rotor "in place".
 
vectoroperator*= (vector &v, const rotor &R)
 Rotate a certain vector by a rotor "in place".
 

Related Symbols

(Note that these are not member symbols.)

rotor exp (const bivector &i)
 Compute the exponential of a bivector, which implements a rotation as given by the norm of the bivector.
 
rotor exp (const bivector &U, double phi)
 Implement a rotation of phi degrees along the bivector U.
 
rotor exp (const rotor &s)
 Compute the exponential of a rotor (by Andrew Hamilton)
 
rotor ln (const rotor &s)
 Compute the natural logarithm of a rotor (by Andrew Hamilton)
 
vector operator% (const vector &l, const vector &r)
 Compute the three-dimensional cross product.
 
bivector operator() (const bivector &V) const
 Rotate a bivector.
 
rotor operator* (const vector &l, const vector &r)
 The multiplication operation on two vectors implements the geometric product $ lr := l.r + l^r $, thus generating a clifford algebra.
 
rotor operator+ (const bivector &U, double r)
 Create a rotor as sum of bi-vector and scalar.
 
rotor operator+ (const rotor &U, double r)
 Add a scalar value to a rotor.
 
rotor operator+ (double r, const bivector &U)
 Create a rotor as sum of scalar and bi-vector.
 
rotor operator+ (double r, const rotor &U)
 Add a scalar value to a rotor.
 
rotor operator- (const rotor &U, double r)
 Add a scalar value to a rotor.
 
rotor operator- (double r, const bivector &U)
 Create a rotor as difference of scalar and bi-vector.
 
rotor operator- (double r, const rotor &U)
 Add a scalar value to a rotor.
 
rotor operator/ (const rotor &l, const rotor &r)
 Note that $ l/r := l*r^{-1} \neq r^{-1} * l $.
 
rotor operator/ (const vector &l, const vector &r)
 Divide two vectors, yielding the rotation operation to sweep the second vector to the first one.
 
rotor operator~ (const rotor &r)
 Compute the inverse rotor.
 
rotor pow (const rotor &r, double t)
 Compute the power of a rotor.
 
Matrix< 4, 4, double > rotmatrix (const rotor &r)
 Compute the classical 4x4 rotation Matrix.
 
rotor slerp (const rotor &r1, const rotor &r2, double t)
 Interpolate between q1 (t = 0) and q2 (t = 1): q = (q2/q1)^t q1 .
 

Additional Inherited Members

- Public Types inherited from Eagle::Vector< double, 4 >
enum  
 The number of elements in this array.
 
- Public Types inherited from Eagle::FixedArray< value, N >
typedef FlattenedArray_t::value_type Element_t
 The maximally reduced type of elements stored here.
 
typedef GetFixedArrayType< value >::result_t ElementAsFixedArray_t
 Element type as fixed array, if it is convertible to a fixed array.
 
typedef FixedArray FixedArray_t
 Exporting the type definition of this array cass type.
 
typedef FixedArrayFlattener< FixedArrayOfElements_tFixedArrayFlattener_t
 Internal helper class.
 
typedef FixedArray< ElementAsFixedArray_t, N > FixedArrayOfElements_t
 If the value is derived from a fixed array type itself, then the FixedArrayOfElements_t is an FixedArray<FixedArray<>> type.
 
typedef FixedArrayFlattener_t::result_t FlattenedArray_t
 Reduction of this array type, if it is nested, to an flattened type which contains elementary types.
 
typedef value value_type
 Export the type of the respective element value type.
 
- Static Public Member Functions inherited from Eagle::FixedArray< value, N >
template<typename T , typename ConversionFunctor >
static constexpr FixedArray convert (const FixedArray< T, N > &F, const ConversionFunctor &CF)
 Perform a type conversion on a given fixed array into another basis type:
 
static constexpr dimension_t size ()
 The number of elements here.
 
- Protected Attributes inherited from Eagle::FixedArray< value, N >
value data [SIZE]
 The actual data values, intentional no-initialization for data member, which increases performance on vector creation.
 

Detailed Description

A rotor is the sum of scalar with a bivector.

It represents the even subalgebra (for instance grade 0 and 2) of the geometric algebra of euclidean 3-space and implements the same algebraic properties as a Pauli spinor. There are 3+1 components in a rotor in 3-space.

To use a rotor to rotate a vector v around a bivector u look at rotor::operator()

Todo:
Need to implement optimization for unit rotors, such that the norm2() function always returns 1.0 without computation.

Member Function Documentation

◆ operator()()

vector Eagle::PhysicalSpace::rotor::operator() ( const vector v) const
inline

The sandwich product: Compute Rv ~R, which is the rotation of the vector v by the current rotor.

R(v) = R v ~R = (s+U) v (s-U) = (s v + U v) (s-U) = s v s + U v s - s v U - U v U = s s v + Uv s - s vU - U(v) = ss v + 2 Uv s - U(v)

To rotate a vector v with angle phi around a bivector u you may use:

double phi;
rotor R = exp(u * phi); // with ||u||=1 (use unit() ) and [phi] in rad
vector rotated_v = R(v);
A three-dimensional Bi-Vector which is span by two vectors to define a plane.
Definition elementary/eagle/PhysicalSpace.hpp:556
A rotor is the sum of scalar with a bivector.
Definition rotor3.hpp:36
rotor exp(const rotor &s)
Compute the exponential of a rotor (by Andrew Hamilton)
Definition rotor3.hpp:351
3-dimensional vector.
Definition elementary/eagle/PhysicalSpace.hpp:170
Todo:
Hmm, isn't there a sign error in the 2 s vU part? Plz verify!!

References bivec(), Eagle::PhysicalSpace::dot(), and scalar().

Friends And Related Symbol Documentation

◆ exp()

rotor exp ( const bivector U,
double  phi 
)
related

Implement a rotation of phi degrees along the bivector U.

If U is not unit, then the resulting rotor will also scale a given vector.

Parameters
phiRotation in radians.

◆ ln()

rotor ln ( const rotor s)
related

Compute the natural logarithm of a rotor (by Andrew Hamilton)

important: maybe error of ln with rotor r = (1,0,0,0); must be tested
rotor ln(const rotor &s)
Compute the natural logarithm of a rotor (by Andrew Hamilton)
Definition rotor3.hpp:378

References bivec(), Eagle::norm2(), and unit().

◆ operator()()

bivector operator() ( const bivector V) const
related

Rotate a bivector.

This operator is equivalent to $ *R(*V) $.

Note
Let's hope the compiler optimizes this function sufficiently.

◆ operator* [1/2]

OddMultiVector operator* ( const rotor R,
const vector v 
)
friend

Multiply rotor and vector, yielding an odd multivector, the dual of a rotor.

Use its vec() member function to retrieve the vectorial part.

◆ operator*() [2/2]

rotor operator* ( const vector l,
const vector r 
)
related

The multiplication operation on two vectors implements the geometric product $ lr := l.r + l^r $, thus generating a clifford algebra.

Geometrically it means the operation to sweep one vector r to a vector l, which results in a rotor.

References Eagle::PhysicalSpace::dot().

◆ operator*=

bivector & operator*= ( bivector V,
const rotor R 
)
friend

Rotate a certain bivector by a rotor "in place".

Note
This is numerically not more efficient than assignment.

◆ operator/()

rotor operator/ ( const vector l,
const vector r 
)
related

Divide two vectors, yielding the rotation operation to sweep the second vector to the first one.

This operation is identical to (l r^-1).

References Eagle::PhysicalSpace::vector::inv().

◆ operator~()

rotor operator~ ( const rotor r)
related

Compute the inverse rotor.

Note
This is probably only correct for unit rotors...

References bivec(), and scalar().

◆ rotmatrix()

Matrix< 4, 4, double > rotmatrix ( const rotor r)
related

Compute the classical 4x4 rotation Matrix.

E.g. for use with openGls: glMultMatrixd like: glMultMatrixd( RotMat.ptr() );

References Eagle::Matrix< R, C, Value >::column().