Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
/ three Public archive

Roblox Lua library for 3D multivectors, the geometric product and associated operations

License

Notifications You must be signed in to change notification settings

polychromatist/three

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 

Repository files navigation

archived in favor of three/four bundle "thor" to be published on a later date!

three

Roblox Lua library for 3D multivectors, the geometric product and associated operations

what/why

The space of 3D multivectors is a space of regular 3D vectors and an assortment of objects, all of which become transformations under the geometric product, a useful way to multiply vectors. Projections, rotations, reflections are defined with this product in a way that is practical, but also illuminating, suggestive, and privy to tinkering.

The language of geometric algebra is quickly taking the stage as a universal representation of transformations in space.

Please take some time to understand these captivating objects: https://www.youtube.com/watch?v=60z_hpEAtD8

usage

Place contents of three.lua into ReplicatedStorage
local three = require(game:GetService("ReplicatedStorage").three)
To specify a multivector directly: local m1 = three(a, x, y, z, xy, xz, yz, im)

  • a describes the scalar component m1.scalar (returns a number)
  • x, y, z describes the vector component m1.vector (returns a Vector3)
  • xy, xz, yz describes the pseudovector component m1.pseudovector (returns a pure bivector Three object)
  • im describes the pseudoscalar component m1.pseudoscalar (returns a pure pseudoscalar Three object)

If you have two multivectors m1, m2, you can...

  • Add / subtract them
  • Take their geometric product: m1 * m2 (m2 can also be a scalar, Vector3, or Vector2)
  • Take their inner product: m1 .. m2 OR m1:inner(m2) (wrapper for 0.5 * (m1 * m2 + m2 * m1))
  • Take their outer product: m1:outer(m2) (wrapper for 0.5 * (m1 * m2 - m2 * m1))
  • Take a quotient (if m2 is invertible): m1 / m2 (wrapper for m1 * m2.inverse)
  • Take the scalar product m1:scalarprod(m2), fat dot product m1:fatdot(m2), m1:left(m2) and m1:right(m2) contractions
  • Take their exterior (wedge) product: m1 ^ m2 or m1:exterior(m2)
  • Take a regressive product: m1:regressive(m2) / m1:meet(m2) / m1:join(m2)
  • Take a generalized reflection: m1:reflect(m2)

If you have one multivector m1, you can...

  • Take its reverse conjugate m1.reversion, which is the multivector such that, if m1 = v1 * v2 * ... * v_n for vectors v_i, then m1.reversion = v_n * v_(n-1) * ... * v_1
  • Take its Clifford conjugate m1.bar, which is useful to provide a value analogous to magnitude (by m1 * m1.bar)
  • Take its Hodge dual: m1.dual
  • Take its "magnitude" m1.magnitude, which is vector magnitude if the multivector is a vector, but is defined by sqrt(sqrt(b.scalar ^ 2 + b.pseudoscalar ^ 2)), where b = m1 * m1.bar
  • Take its "unit" multivector m1.unit, simply m1 / m1.magnitude
  • Take its inverse m1.inverse, defined by m1 * m1.inverse = id = unit scalar = three(1)
    See an interesting paper on generalized multivector inverse: https://arxiv.org/abs/1712.05204v2 "INVERSE OF MULTIVECTOR: BEYOND P+Q=5 THRESHOLD" (A. ACUS AND A. DARGYS)

not yet implemented

  • rotations, multivector SQRT
    Motivating paper on generalized multivector SQRT: https://arxiv.org/abs/2003.06873v1 "Square root of a multivector of Clifford algebras in 3D: A game with signs" (A. Acus, A. Dargys)

Warning: May Not Be Suitable for Production

  • This code is superbly undertested: I have only verified it with bouts of trial-and-error. Use at your own risk.
  • There is a concern with floating-point error here in that some operations that should yield a zero value in a component of a multivector, such as inverse, yields an epsilon value. This is resolvable by, for example, implementing a symbolic equation solver that would destroy cancelling terms before they are evaluated. (toeventuallydo)

About

Roblox Lua library for 3D multivectors, the geometric product and associated operations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages