Some of the Cargo tests on the main branch are designed to print output for human inspection, not to verify computations automatically. The incoming branch turns these tests into Cargo examples. It also makes two organizational changes in pursuit of this goal: - It introduces a dyna3 library target, which the examples use as a dependency. In the future, this target could grow into an officially maintained dyna3 library. - It puts the code for realizing the Irisawa hexlet into a new conditionally compiled `engine::irisawa` module. This code is shared by a test and an example. Compilation is controlled by the `dev` feature, which is turned on by default in development mode. I've verified that printed output of the examples hasn't changed between the head (848f7d6
) and base (e917272
) of the incoming branch. Co-authored-by: Aaron Fenyes <aaron.fenyes@fareycircles.ooo> Co-authored-by: Glen Whitney <glen@studioinfinity.org> Reviewed-on: #24 Co-authored-by: Vectornaut <vectornaut@nobody@nowhere.net> Co-committed-by: Vectornaut <vectornaut@nobody@nowhere.net>
3.6 KiB
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
- Install
rustup
: the officially recommended Rust toolchain manager- It's available on Ubuntu as a Snap
- 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
- If you forget, the
- Call
rustup target add wasm32-unknown-unknown
to add the most generic 32-bit WebAssembly target - Call
cargo install wasm-pack
to install the WebAssembly toolchain - Call
cargo install trunk
to install the Trunk web-build tool - 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
- Go into the
app-proto
folder - 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
- 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
- Touching any file in the
- Press ctrl+C in the shell where Trunk is running to stop serving the prototype
Run the engine on some example problems
- Go into the
app-proto
folder - 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 theninclude("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
- Go into the
app-proto
folder - Call
cargo test