Constraint-based three-dimensional dynamic geometry
Go to file
Vectornaut 817a446fad Switch to Euclidean-invariant projection onto tangent space of solution variety (#34)
This pull request addresses issues #32 and #33 by projecting nudges onto the tangent space of the solution variety using a Euclidean-invariant inner product, which I'm calling the *uniform* inner product.

### Definition of the uniform inner product

For spheres and planes, the uniform inner product is defined on the tangent space of the hyperboloid $\langle v, v \rangle = 1$. For points, it's defined on the tangent space of the paraboloid $\langle v, v \rangle = 0,\; \langle v, I_\infty \rangle = 1$.

The tangent space of an assembly can be expressed as the direct sum of the tangent spaces of the elements. We extend the uniform inner product to assemblies by declaring the tangent spaces of different elements to be orthogonal.

#### For spheres and planes

If $v = [x, y, z, b, c]^\top$ is on the hyperboloid $\langle v, v \rangle = 1$, the vectors
$$\left[ \begin{array}{c} 2b \\ \cdot \\ \cdot \\ \cdot \\ x \end{array} \right],\;\left[ \begin{array}{c} \cdot \\ 2b \\ \cdot \\ \cdot \\ y \end{array} \right],\;\left[ \begin{array}{c} \cdot \\ \cdot \\ 2b \\ \cdot \\ z \end{array} \right],\;\left[ \begin{array}{l} 2bx \\ 2by \\ 2bz \\ 2b^2 \\ 2bc + 1 \end{array} \right]$$
form a basis for the tangent space of hyperboloid at $v$. We declare this basis to be orthonormal with respect to the uniform inner product.

The first three vectors in the basis are unit-speed translations along the coordinate axes. The last vector moves the surface at unit speed along its normal field. For spheres, this increases the radius at unit rate. For planes, this translates the plane parallel to itself at unit speed. This description makes it clear that the uniform inner product is invariant under Euclidean motions.

#### For points

If $v = [x, y, z, b, c]^\top$ is on the paraboloid $\langle v, v \rangle = 0,\; \langle v, I_\infty \rangle = 1$, the vectors
$$\left[ \begin{array}{c} 2b \\ \cdot \\ \cdot \\ \cdot \\ x \end{array} \right],\;\left[ \begin{array}{c} \cdot \\ 2b \\ \cdot \\ \cdot \\ y \end{array} \right],\;\left[ \begin{array}{c} \cdot \\ \cdot \\ 2b \\ \cdot \\ z \end{array} \right]$$
form a basis for the tangent space of paraboloid at $v$. We declare this basis to be orthonormal with respect to the uniform inner product.

The meanings of the basis vectors, and the argument that the uniform inner product is Euclidean-invariant, are the same as for spheres and planes. In the engine, we pad the basis with $[0, 0, 0, 0, 1]^\top$ to keep the number of uniform coordinates consistent across element types.

### Confirmation of intended behavior

Two new tests confirm that we've corrected the misbehaviors described in issues #32 and #33.

Issue | Test
---|---
#32 | `proj_equivar_test`
#33 | `tangent_test_kaleidocycle`

Co-authored-by: Aaron Fenyes <aaron.fenyes@fareycircles.ooo>
Reviewed-on: #34
Co-authored-by: Vectornaut <vectornaut@nobody@nowhere.net>
Co-committed-by: Vectornaut <vectornaut@nobody@nowhere.net>
2025-01-31 19:34:33 +00:00
app-proto Switch to Euclidean-invariant projection onto tangent space of solution variety (#34) 2025-01-31 19:34:33 +00:00
coffeetest Set up testing with Ava 2019-12-11 12:07:43 -05:00
doc Switch to good old make to reduce redundancies in build 2019-12-12 00:33:59 -05:00
engine-proto Integrate engine into application prototype (#15) 2024-11-12 00:46:16 +00:00
notes Integrate engine into application prototype (#15) 2024-11-12 00:46:16 +00:00
src Adjust lighting and camera for decent initial rendering of polyhedra 2019-12-31 07:20:33 -08:00
.gitignore Copy only the production dependencies to the site directory 2019-12-11 13:20:31 -05:00
LICENSE Initial commit 2019-09-14 19:00:59 +00:00
Makefile First pass at coordinate axes 2019-12-12 02:44:33 -05:00
package-lock.json Adjust lighting and camera for decent initial rendering of polyhedra 2019-12-31 07:20:33 -08:00
package.json Switch to good old make to reduce redundancies in build 2019-12-12 00:33:59 -05:00
README.md Turn non-automated tests into Cargo examples (#24) 2024-11-26 00:32:50 +00:00

dyna3

Abstract

Constraint-based three-dimensional dynamic geometry

Description

From a thorough web search, there does not seem to be a dynamic geometry software package which (a) began its life handling three dimensions, rather than just two, and (b) allows you to express the desired geometric configuration in terms of constraints on the entities (e.g. l and k are parallel, a, b, and c a collinear, etc.) rather than as a construction (e.g. l is the perpendicular bisector of a and b). The goal of the dyna3 project is to close this gap.

Note that currently this is just the barest beginnings of the project, more of a framework for developing dyna3 rather than anything useful.

Implementation goals

  • Comfortable, intuitive UI

  • Able to run in browser (so implemented in WASM-compatible language)

  • Produce scalable graphics of 3D diagrams, and maybe STL files (or other fabricatable file format) as well.

Prototype

The latest prototype is in the folder app-proto. It includes both a user interface and a numerical constraint-solving engine.

Install the prerequisites

  1. Install rustup: the officially recommended Rust toolchain manager
    • It's available on Ubuntu as a Snap
  2. Call rustup default stable to "download the latest stable release of Rust and set it as your default toolchain"
    • If you forget, the rustup help system will remind you
  3. Call rustup target add wasm32-unknown-unknown to add the most generic 32-bit WebAssembly target
  4. Call cargo install wasm-pack to install the WebAssembly toolchain
  5. Call cargo install trunk to install the Trunk web-build tool
  6. Add the .cargo/bin folder in your home directory to your executable search path
    • This lets you call Trunk, and other tools installed by Cargo, without specifying their paths
    • On POSIX systems, the search path is stored in the PATH environment variable

Play with the prototype

  1. Go into the app-proto folder
  2. Call trunk serve --release to build and serve the prototype
    • The crates the prototype depends on will be downloaded and served automatically
    • For a faster build, at the expense of a much slower prototype, you can call trunk serve without the --release flag
  3. In a web browser, visit one of the URLs listed under the message INFO 📡 server listening at:
    • Touching any file in the app-proto folder will make Trunk rebuild and live-reload the prototype
  4. Press ctrl+C in the shell where Trunk is running to stop serving the prototype

Run the engine on some example problems

  1. Go into the app-proto folder
  2. Call ./run-examples
    • For each example problem, the engine will print the value of the loss function at each optimization step

    • The first example that prints is the same as the Irisawa hexlet example from the Julia version of the engine prototype. If you go into engine-proto/gram-test, launch Julia, and then

      include("irisawa-hexlet.jl")
      for (step, scaled_loss) in enumerate(history_alt.scaled_loss)
        println(rpad(step-1, 4), " | ", scaled_loss)
      end
      

      you should see that it prints basically the same loss history until the last few steps, when the lower default precision of the Rust engine really starts to show

Run the automated tests

  1. Go into the app-proto folder
  2. Call cargo test