https://github.com/geometryzen/davinci-newton
Experimental Physics Engine
https://github.com/geometryzen/davinci-newton
Last synced: 11 months ago
JSON representation
Experimental Physics Engine
- Host: GitHub
- URL: https://github.com/geometryzen/davinci-newton
- Owner: geometryzen
- License: mit
- Created: 2017-01-14T22:25:50.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-04-03T11:17:40.000Z (about 2 years ago)
- Last Synced: 2025-07-23T11:56:15.144Z (11 months ago)
- Language: TypeScript
- Size: 14.2 MB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# davinci-newton
A Physics Engine for research and education using Geometric Algebra, and Units of Measure (optional).
The following metrics are supported:
DescriptionAlgebraclass
Euclidean 1DG(1,0)Engine1
Euclidean 2DG(2,0)Engine2
Euclidean 3DG(3,0)Engine3
Spacetime 1DG(1,1)EngineG11
Spacetime 2DG(2,1)EngineG21
# Getting Started
The following code illustrates the basic flow. For working examples see [STEMCstudio](https://www.stemcstudio.com/examples).
## Constructing the core simulation using the `Engine3` Euclidean 3D or G(3,0) Physics engine.
This example incorporates units of measure.
```typescript
import {
Block3,
Engine3,
Geometric3,
Spring
} from 'davinci-newton'
//
// Constants
//
const e1 = Geometric3.e1
const e2 = Geometric3.e2
const e3 = Geometric3.e3
const kg = Geometric3.kilogram
const m = Geometric3.meter
const s = Geometric3.second
//
// Initialization
//
const sim = new Engine3()
const Δt = 0.01 * s
//
// Add objects
//
const width = 0.5 * m
const height = 0.1 * m
const depth = 0.5 * m
const block1 = new Block3(width, height, depth)
const block2 = new Block3(width, height, depth)
block1.M = 1 * kg
block2.M = 1 * kg
block1.X = -1.0 * e1 * m
block2.X = +1.0 * e1 * m
sim.addBody(block1)
sim.addBody(block2)
//
// Add forces
//
const spring = new Spring(block1, block2)
spring.restLength = 1 * m
spring.stiffness = 1 * kg / (s * s)
sim.addForceLaw(spring)
spring.attach1 = (block1.width * e1 + 0 * block1.height * e2 + block1.depth * e3) / 2
// Inside animation "loop"
sim.advance(Δt.a, Δt.uom)
```