2024-12-17

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 inner product

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

inner_product = (a, b) ->
  return scale(b, a) if is_scalar a
  return scale(a, b) if is_scalar b
  result_components = {}
  for_each_component a, (coeff_a, bases_a, grade_a) ->
    non_null_a = remove_null_bases bases_a
    null_a = extract_null_bases bases_a
    for_each_component b, (coeff_b, bases_b, grade_b) ->
      non_null_b = remove_null_bases bases_b
      null_b = extract_null_bases bases_b
      if bases_a == bases_b
        add_to_result result_components, null_base(), coeff_a * coeff_b * compute_metric(bases_a), 0
      else if has_null_bases(null_a, null_b)
        sign = compute_sign bases_a, bases_b
        for_each_combination bases_b, grade_a, (subset) ->
          metric_product = compute_metric_product bases_a, subset
          continue unless metric_product
          coeff = coeff_a * coeff_b * sign * metric_product
          add_to_result result_components, subtract_bases(bases_b, subset), coeff, grade_b - grade_a
      else if grade_a <= grade_b and is_subset(non_null_a, non_null_b)
        combined_bases = exclusive_xor non_null_a, non_null_b
        metric_product = compute_metric combined_bases
        continue unless metric_product
        coeff = coeff_a * coeff_b * compute_sign(bases_a, combined_bases) * metric_product
        add_to_result result_components, combined_bases, coeff, grade_b - grade_a
  assemble_multivector result_components

compute_metric calculates the diagonal product for diagonal metrics and the submatrix determinant for non-diagonal metrics. compute_sign works the same way as it does for the exterior product.

special cases

  • in a purely euclidean metric, metric(i,j) = 0 unless i = j. thus, all terms with distinct i, j vanish, and the outline simplifies to only considering identical indices appearing on both sides.
  • in cga (with null vectors), metric(i,j) may be non-zero even when i != j. this outline allows for such cases naturally. it does not rely on the vectors being identical to produce a non-zero result; the metric handles that.

calculation of the geometric product

the geometric product is sometimes defined as a combination of the inner and exterior products; naively translating this into code would require a complicated combination of the results.

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

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)