EGA implementation¶
In this section, we describe a simple implementation of the \(G_{3,0,0}\) algebra. As stated before, this implementation is quite simple and is not really meant for high-performance contexts nor low-memory efficiency.
We refer the reader to other geometric algebra libraries/generators/implementations such as :
This module lives inside the hk::maths::vga
namespace and provide a unique data structure mvec3f
representing a multivector in this algebraic structure.
struct mvec3f
{
union
{
float at[8];
struct {float s, x,y,z, xy, yz, zx, xyz;};
};
// [...]
};
Here is an example of creating a vector using algebra:
vga::mvec3f x = vga::mvec3f::basis_x();
vga::mvec3f y = vga::mvec3f::basis_y();
vga::mvec3f z = vga::mvec3f::basis_z();
vga::mvec3f v = 2.f * x + 0.5f * y + 1.5f * z;
This data structure comes with some operators:
*
orproduct
function: performing the geometric product between multivectors^
orwedge
orouter
: performing the outer/wedge product between multivectorsdot
orinner
: performing the inner/dot product between multivectors
This implementation also provides
v.grade_0
: \( \langle A \rangle_0 \) the scalar part of the multivector \(A\)v.grade_1
: \( \langle A \rangle_1 \) the vector part of the multivector \(A\)v.grade_2
: \( \langle A \rangle_2 \) the bivector/pseudovector part of the multivector \(A\)v.grade_3
: \( \langle A \rangle_3 \) the trivector/pseudoscalar part of the multivector \(A\)reverse
: denoted \(A^\dagger\) reversing blades from the multivectornorm_sqr
: denoted \( |A|^2 = \langle A^\dagger A \rangle_0 \)norm
: denoted \( |A| = \sqrt{ \langle A^\dagger A \rangle_0 } \)inverse
: denoted \(A^\star = A^\dagger / |A|^2 \) the inverse of \(A\), meaning \(AA^\star = 1\)
duality is achieved using the pseudoscalar \(A I^{-1}\) with \(I^{-1} = (e_{123})^{-1}\)
vga::mvec3f I_inv = inverse(vga::mvec3f::basis_xyz());
vga::mvec3f A = ...
vga::mvec3f A_dual = A * I_inv;