2024-12-30

geometric algebra

a collection of links and notes of varying quality.

see also the relatively straightforward software implementation sph-ga.

links

additional links

calculation of the exterior product

among the inner, geometric, and exterior products, the exterior product is the simplest to calculate.

exterior_product = (a, b) ->  # multivector multivector -> mulivector
  result_components = {}
  for_each_component a, (coeff_a, blade_a) ->
    for_each_component b, (coeff_b, blade_b) ->
      continue if has_overlap blade_a.bases, blade_b.bases
      combined_bases = logical_or blade_a.bases, blade_b.bases
      continue unless combined_bases
      sign = if is_scalar(blade_b) then 1 else compute_sign(blade_a.bases, blade_b.bases)
      combined_coeff = sign * coeff_a * coeff_b
      combined_grade = blade_a.grade + blade_b.grade
      add_to_result result_components, combined_bases, combined_coeff, combined_grade
  assemble_multivector result_components

calculation of the geometric product

the geometric product is sometimes defined as a combination of the inner and exterior products. however, the fact that this is only valid under certain conditions can be misleading. there are cases where both the inner and extrerior product create results. while scalar multiplication rules can be adapted to be non-overlapping, merging more complex results is a challenge.

the geometric product is actually easier to calculate than the inner product.

it merges indices with the correct sign and metric factor. it yields the final basis monomial(s) with associated coefficients.

outdated

geometric_product = (a, b) ->
  result_components = {}
  for blade_a, coeff_a of a
    for blade_b, coeff_b of b
      combined = blade_a.bases.concat(blade_b.bases)
      combined, sign = canonical_sort_and_sign(combined)
      coeff = coeff_a * coeff_b * sign
      factor = 1
      changed = true
      while changed
        changed = false
        i = 0
        while i < combined.length
          j = i + 1
          while j < combined.length
            v1 = combined[i]
            v2 = combined[j]
            metric_component = metric[v1][v2]
            if metric_component != 0
              factor *= metric_component
              combined = remove_pair_from_list(combined, i, j)
              changed = true
              break
            j++
          if changed then break
          i++
      coeff *= factor
      continue if coeff == 0
      add_to_result result_components, combined, coeff, grade(combined)
  assemble_multivector result_components

one obtains:

  • the inner product by extracting the components of the geometric product at grade |p - q|
  • the exterior product by extracting the components at grade p + q
  • the left contraction, right contraction, etc, likewise by focusing on specific grades of the geometric product

calculation of the inner product

the easiest way to implement the inner product is to use the geometric product and extract only the b_grade minus a_grade blades from the result. its complexity arises mostly with cga; the purely euclidean, orthogonal, case is trivially solved in comparison.

here is a general outline for computing the left contraction clifford (geometric) inner product that explicitly depends on the metric and also handles null vectors like for the conformal model.

geometric_product = (a, b) ->  # multivector multivector -> multivector
  result_terms = {}
  for_each_component a, (coeff_a, term_a) ->
    for_each_component b, (coeff_b, term_b) ->
      continue if term_b.grade < term_a.grade
      factor = metric_combination(term_a.id, term_b.id)
      combined_indices = sort concatenate(bit_indices(term_a.id), bit_indices(term_b.id))
      grade_final = combined_indices.length
      coeff_final = coeff_a * coeff_b * factor
      continue if coeff_final == 0
      add_to_result result_terms, combined_indices, coeff_final, grade_final
  assemble_multivector result_terms

grade_reduction = (product_terms, desired_grade) ->  # multivector int -> multivector
  result_terms = {}
  for_each_component product_terms, (coeff, term) ->
    continue unless term.grade == desired_grade
    add_to_result result_terms, term.id, coeff, term.grade
  assemble_multivector result_terms

notes

tests

then geometric and inner product of the pseudoscalar with itself can uncover flaws in null vector handling

e1_2_3_4_5 * e1_2_3_4_5
  • the sign can vary depending on the specific metric one uses. other libraries or references may use different conventions which flips all signs compared to your implementation
  • in cga references, one can often see a scaling factor applied to the pseudoscalar "pseudoscalar = scaling_factor * (e1_2_3_0_∞)". sometimes this scaling factor is chosen to be "-1/2". the geometric product of the pseudoscalar with itself, mechanically calculated, is 1 using the conformal metric. only with the scaling factor is it sometimes modified

conformal metric

the conformal metric is a split-signature metric with two off-diagonal negative terms.

[1, 1, 1, 0, 0]

it aligns with the use of the no and ni null vector bases.

no * no = 0
ni * ni = 0
no * ni = -1
e_i * e_i = 1
e_i * e_j (where i != j) = 0

terminology

  • scalars: real-number elements of the algebra
  • vectors: elements of a vector space, forming the grade-1 components
  • basis vectors: linearly independent vectors spanning the space
  • null vectors: special basis vectors whose self-inner product vanishes, adding conformal or additional structure
  • blades: simple multivectors obtained as the exterior product of linearly independent vectors
  • bivectors: grade-2 elements representing oriented plane segments
  • trivectors: grade-3 elements representing oriented volume segments
  • multivectors: general elements of the algebra, linear combinations of scalars, vectors, bivectors, trivectors, and higher-grade elements
  • pseudoscalar: the highest-grade element in the algebra, encoding oriented n-volumes (where n is the space dimension)
  • spinors: multivectors representing transformations, such as rotations, reflections, and dilations
  • null space: subspace spanned by null vectors
  • dual: a multivector's complement with respect to the pseudoscalar
  • grades: homogeneous components of a multivector corresponding to its dimensionality (e.g., scalars are grade-0, vectors grade-1)
  • conformal points: vectors representing positions in conformal space via null vector embedding
  • directions: null vectors that represent points at infinity
  • rounds: elements describing spheres or circles in conformal geometric algebra
  • flats: elements representing hyperplanes or lines in the conformal framework
  • tangent vectors: null vectors encoding directions tangent to a conformal round

main operations

  • exterior product (wedge product, outer product): an associative, antisymmetric product producing higher-grade blades
  • inner product (dot product): reduces the grade of multivectors, encoding projections and magnitudes
  • geometric product: the associative fundamental product combining the inner and exterior products, unifying algebraic operations
  • reversion: reversing the order of vectors in a product, generalizing conjugation
  • grade involution: negates all odd-grade components of a multivector
  • dualization: mapping a multivector to its dual via multiplication with the pseudoscalar
  • grade projection: extracting components of a multivector corresponding to specific grades
  • norm: measuring the magnitude of a multivector using its geometric product
  • sandwich product: encoding transformations (e.g., rotations) via spinor conjugation: A -> R A R⁻¹
  • meet: the intersection of two geometric objects, derived via dualization
  • join: the union of two geometric objects, derived via the exterior product
  • reflection: mapping a vector across a hyperplane using a spinor: v -> -RvR⁻¹
  • rotation: generalizing reflections using spinors to perform rotations
  • inversion: mapping points or vectors relative to spheres in conformal space
  • translation: embedding translations as specific spinor operations in conformal space
  • dilation: scaling transformations represented by spinors
  • exponential map: constructing rotations and dilations via exponentiation of bivectors
  • logarithm map: extracting bivectors from spinors encoding rotations or dilations
  • commutator product: measuring the "twist" between two elements, defined as [A, B] = AB - BA
  • anticommutator product: symmetric product measuring alignment, defined as {A, B} = AB + BA
  • orthogonal complement: constructing orthogonal spaces or duals relative to a flat or round
  • null decomposition: separating null components of a vector or multivector for conformal analysis

conformal geometric algebra

in conformal geometric algebra (cga), a point in euclidean space is represented as a null vector in a higher-dimensional space. specifically, for an n-dimensional euclidean space, cga embeds this space into an (n + 2)-dimensional space with a signature (n + 1, 1). the point p with coordinates (x1, x2, ..., xn) is represented as:

p = x1 * e1 + x2 * e2 + ... + xn * en + e0 + 0.5 * (x1 ** 2 + x2 ** 2 + ... + xn ** 2) * e∞

where 'e1, e2, ..., en' are the basis vectors corresponding to the original euclidean space. e0 and e∞ are additional basis vectors with specific properties to facilitate the embedding, introduced to handle infinity and origin, and operations like translation, rotation, dilation, and reflection. e0 is often associated with the origin in the extended space. e∞ represents the "point at infinity," enabling the conformal model to handle infinite points, essential for representing directions and ideal points.

the null vector condition is given by:

dot_product(p, p) = 0

this condition ensures that the representation is a null vector in the conformal space, preserving the geometric properties of the original euclidean point.

rotation

rotor = e ** (-axis_orthogonal_plane * angle / 2)

where axis_orthogonal_plane is a unit bivector.

without exponentiation, the rotor can be constructed using the trigonometric functions that define the exponential form.

rotor = cos(angle / 2) + bivector * sin(angle / 2)

translation

rotor = 1 + 1 / 2 * translation_vector * e∞

rotation followed by translation

rotor = e ** (-axis * angle / 2) * (1 + 1 / 2 * translation_vector * e∞)

perspective projection

described in computing perspective projections in 3-dimensions using rotors in the homogeneous and conformal models of clifford algebra.

step 1: reflection

e ** ((angle / 2) * n * e4) = cos(angle / 2) + sin(angle / 2) * n * e4

step 2: inversion

e ** ((1 / (2 * d)) * n * e0) = exterior_product(1 + (1 / (2 * d) * n, e0))

rotor application

result = rotor * point * reverse(rotor)