Skip to content

Commit

Permalink
loose initial curation pass, organizing the top-level docs and main s…
Browse files Browse the repository at this point in the history
…imulation types
  • Loading branch information
heckj committed Oct 31, 2023
1 parent 5e9fddb commit 54bee9b
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

## Overview

You can simply create 2D or 3D simulations by using Simulation2D or Simulation3D:
Create 2D or 3D simulations by using Simulation2D or Simulation3D.
For example, the following code creates a 2D force simulation.

```swift

Expand All @@ -30,4 +31,4 @@ for i in 0..<120 {

```

See [Example](https://github.com/li3zhen1/Grape/tree/main/Examples/ForceDirectedGraphExample) for more details.
See [Examples](https://github.com/li3zhen1/Grape/tree/main/Examples) for example Xcode projects.
56 changes: 32 additions & 24 deletions Sources/ForceSimulation/ForceSimulation.docc/Documentation.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# ``ForceSimulation``

Run force simulation on any dimensions.
Run force simulation within any number of dimensions.

## Overview

`ForceSimulation` is a force simulation library that enables you to create any dimensional simulation with velocity Verlet integration. The basic concepts of simulations and forces can be found here: [Force simulations - D3](https://d3js.org/d3-force/simulation).
The `ForceSimulation` library enables you to create any dimensional simulation that uses velocity Verlet integration.

For more information on force simulations, read: [Force simulations - D3](https://d3js.org/d3-force/simulation).


@Image(source: "ForceDirectedGraph.png", alt: "An example of 2D force directied graph.")
Expand All @@ -20,25 +22,31 @@ Run force simulation on any dimensions.
* ``Simulation3D``
* ``SimulationKD``

### Creating forces in a simulation

* ``Simulation2D/CenterForce``
* ``Simulation2D/CollideForce``
* ``Simulation2D/LinkForce``
* ``Simulation2D/ManyBodyForce``
* ``Simulation2D/DirectionForce2D``
* ``Simulation2D/RadialForce``

* ``Simulation3D/CenterForce``
* ``Simulation3D/CollideForce``
* ``Simulation3D/LinkForce``
* ``Simulation3D/ManyBodyForce``
* ``Simulation3D/DirectionForce3D``
* ``Simulation3D/RadialForce``

* ``SimulationKD/CenterForce``
* ``SimulationKD/CollideForce``
* ``SimulationKD/LinkForce``
* ``SimulationKD/ManyBodyForce``
* ``SimulationKD/DirectionForce``
* ``SimulationKD/RadialForce``
### Spatial data structures

- ``Quadtree``
- ``QuadtreeDelegate``
- ``QuadBox``
- ``Octree``
- ``OctreeDelegate``
- ``OctBox``
- ``NDTree``
- ``NDTreeDelegate``
- ``NDBox``
- ``EdgeID``

### Deterministic Randomness

- ``FloatLinearCongruentialGenerator``
- ``LinearCongruentialGenerator``

### Supporting Protocols

- ``ForceLike``
- ``NDTreeBasedForceLike``
- ``VectorLike``
- ``SimulatableFloatingPoint``

### Error Types

- ``ManyBodyForce2DError``
48 changes: 48 additions & 0 deletions Sources/ForceSimulation/ForceSimulation.docc/Simulation2D.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ``ForceSimulation/Simulation2D``

A force-simulation for distributed layout within a two-dimensional space.

## Topics

### Creating a 2D force simulation

- ``init(nodeIds:alpha:alphaMin:alphaDecay:alphaTarget:velocityDecay:setInitialStatus:)``

### Creating forces for the simulation

- ``createCenterForce(center:strength:)``
- ``CenterForce``
- ``createCollideForce(radius:strength:iterationsPerTick:)``
- ``CollideForce``
- ``createLinkForce(_:stiffness:originalLength:iterationsPerTick:)-652gu``
- ``createLinkForce(_:stiffness:originalLength:iterationsPerTick:)-9iwy5``
- ``LinkForce``
- ``createManyBodyForce(strength:nodeMass:)``
- ``ManyBodyForce``
- ``createPositionForce(direction:targetOnDirection:strength:)``
- ``DirectionForce2D``
- ``createRadialForce(center:radius:strength:)``
- ``RadialForce``

### Running the simulation

- ``tick(iterationCount:)``
- ``resetAlpha(_:)``

### Inspecting the simulation

- ``alpha``
- ``alphaMin``
- ``alphaDecay``
- ``alphaTarget``
- ``initializedAlpha``
- ``velocityDecay``
- ``forces``

### Inspecting nodes within the simulation

- ``nodeIds``
- ``nodeFixations``
- ``nodePositions``
- ``nodeVelocities``
- ``getIndex(of:)``
48 changes: 48 additions & 0 deletions Sources/ForceSimulation/ForceSimulation.docc/Simulation3D.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ``ForceSimulation/Simulation3D``

A force-simulation for distributed layout within a three-dimensional space.

## Topics

### Creating a 3D force simulation

- ``init(nodeIds:alpha:alphaMin:alphaDecay:alphaTarget:velocityDecay:setInitialStatus:)``

### Creating forces for the simulation

- ``createCenterForce(center:strength:)``
- ``CenterForce``
- ``createCollideForce(radius:strength:iterationsPerTick:)``
- ``CollideForce``
- ``createLinkForce(_:stiffness:originalLength:iterationsPerTick:)-2bixz``
- ``createLinkForce(_:stiffness:originalLength:iterationsPerTick:)-3sa2n``
- ``LinkForce``
- ``createManyBodyForce(strength:nodeMass:)``
- ``ManyBodyForce``
- ``createPositionForce(direction:targetOnDirection:strength:)``
- ``DirectionForce3D``
- ``createRadialForce(center:radius:strength:)``
- ``RadialForce``

### Running the simulation

- ``tick(iterationCount:)``
- ``resetAlpha(_:)``

### Inspecting the simulation

- ``alpha``
- ``alphaMin``
- ``alphaDecay``
- ``alphaTarget``
- ``initializedAlpha``
- ``velocityDecay``
- ``forces``

### Inspecting nodes within the simulation

- ``nodeIds``
- ``nodeFixations``
- ``nodePositions``
- ``nodeVelocities``
- ``getIndex(of:)``
48 changes: 48 additions & 0 deletions Sources/ForceSimulation/ForceSimulation.docc/SimulationKD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ``ForceSimulation/SimulationKD``

A force-simulation for distributed layout within a multi-dimensional space.

## Topics

### Creating a multi-dimensional force simulation

- ``init(nodeIds:alpha:alphaMin:alphaDecay:alphaTarget:velocityDecay:setInitialStatus:)``

### Creating forces for the simulation

- ``createCenterForce(center:strength:)``
- ``CenterForce``
- ``createCollideForce(radius:strength:iterationsPerTick:)``
- ``CollideForce``
- ``createLinkForce(_:stiffness:originalLength:iterationsPerTick:)-46ea4``
- ``createLinkForce(_:stiffness:originalLength:iterationsPerTick:)-9opzo``
- ``LinkForce``
- ``createManyBodyForce(strength:nodeMass:)``
- ``ManyBodyForce``
- ``createPositionForce(direction:targetOnDirection:strength:)``
- ``DirectionForce``
- ``createRadialForce(center:radius:strength:)``
- ``RadialForce``

### Running the simulation

- ``tick(iterationCount:)``
- ``resetAlpha(_:)``

### Inspecting the simulation

- ``alpha``
- ``alphaMin``
- ``alphaDecay``
- ``alphaTarget``
- ``initializedAlpha``
- ``velocityDecay``
- ``forces``

### Inspecting nodes within the simulation

- ``nodeIds``
- ``nodeFixations``
- ``nodePositions``
- ``nodeVelocities``
- ``getIndex(of:)``
5 changes: 3 additions & 2 deletions Sources/ForceSimulation/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ extension VectorLike where Scalar: SimulatableFloatingPoint {
}


/// A Hashable identifier for an edge. It’s a utility type for preserving the
/// `Hashable` conformance.
/// A Hashable identifier for an edge.
///
/// It’s a utility type for preserving `Hashable` conformance.
public struct EdgeID<NodeID>: Hashable where NodeID: Hashable {
public let source: NodeID
public let target: NodeID
Expand Down

0 comments on commit 54bee9b

Please sign in to comment.