Skip to content

Commit 3805361

Browse files
Update README.md
1 parent da41a84 commit 3805361

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

README.md

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,40 @@ Harmonic Motion in Unity.
2121

2222
- Open Unity Hub
2323
- Click on the **Add Project** button in the top right next to **New Project**.
24+
- Navigate to the cloned folder and click **Open** in the bottom right corner.
2425
- This project was made with Unity 6000.1.1f1 so that is where the code is guaranteed to work, but most Unity 6 versions will (most likely) work well.
26+
- once you have opened Unity, Navigate to the scenes folder and open the **SampleScene** scene.
2527

2628
## Documentation
2729

28-
There are 2 main scripts you need to know to understand this repo. And they are:
29-
1. Body
30+
There are 3 main classes you need to know to understand this repo. And they are:
31+
1. Physics Controller
3032
2. Simulation Data Compiler
33+
3. Physics Objects
3134

32-
The **Body** script is added to the gameObject you want to simulate a spring system with, and the **Simulation Data Compiler** visualizes the data from the bodies.
35+
The **Physics Objects** script contains 2 classes: Spring and Pointmass.
36+
Physics Controller makes a list of Springs and Pointmasses which are then linked by the user (similar to vertices and edges).
37+
Simulation Data Compiler takes data from the **Physics Controller** and visualizes it. I am planning to make an option to export this data.
3338

34-
### Body Variables
35-
- Data Compiler is the **Simulation Data Compiler** script that will read the data from the current Body.
36-
- Mass is the mass of the point (the GameObject's transform's position) in kilograms.
37-
- Connected Springs is a list of all the springs that will Influence the current Body. Currently, the only way to make new springs that the body will recognize is to access this, but I am planning to make a dedicated GameObject for springs in the near future.
39+
### Physics Controller
40+
- Visualize Springs toggles the visualization of springs in the unity scene view.
41+
- Record Data toggles the sending of data from Physics Controller to Simulation Data Compiler.
42+
43+
#### Masses
44+
45+
Every element in masses is an individual instance of class **Pointmass**:
46+
- Position is the starting position of the Pointmass. note that this is also used as the current position of the pointmass on runtime.
47+
- Mass is the mass of the pointmass in kilograms.
48+
49+
#### Springs
50+
51+
Every element in springs is an individual instance of class **Spring**:
52+
- Spring Constant is the variable `k` in Hooke's law `Fs = -kx` and it controls the "strength" of the spring
53+
- Rest Length is the length of the spring `x` in Hooke's law `Fs = -kx` where if x = 0 there is no restorative force `Fs = 0`.
54+
- Root linked index is the pointmass that is linked to the spring from its root.
55+
- End linked index is the pointmass that is linked to the spring from its end.
56+
57+
Note: If either of the "linked indices" do not exist, the spring is considered to come from the origin.
3858

3959
### Simulation Data Compiler Variables
4060
- Plot Scale is a scalar that controls the size of the graph in the unity scene.
@@ -47,15 +67,15 @@ The **Body** script is added to the gameObject you want to simulate a spring sys
4767

4868
## Simulation Flow
4969
On Simulation Start:
50-
1. Initialize all positions for point-masses from preset transform
51-
2. Calculate initial stretch of all springs
70+
1. Find the simulation end data instance in the scene
71+
2. Find springs' pointmass indices
5272

5373
Every Timestep:
54-
1. Represent Springs in Unity Scene using Debug
55-
2. Velocity Verlet's Half-step (for Second-Order Accuracy)
56-
3. Recalculation of spring forces and stretching based on new positions from Velocity Verlet's intermediate step
57-
4. Final Step of Velocity Verlet
58-
5. Sending Data to Simulation Data Compiler
74+
1. Velocity Verlet's Half-step (for Second-Order Accuracy)
75+
2. Recalculation of spring forces and stretching based on new positions from Velocity Verlet's intermediate step
76+
3. Final Step of Velocity Verlet
77+
78+
Note that the sending of simulation data to the instance of simulation end data is accumulated across all steps.
5979

6080
## Credits
6181

0 commit comments

Comments
 (0)