You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-14Lines changed: 34 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,20 +21,40 @@ Harmonic Motion in Unity.
21
21
22
22
- Open Unity Hub
23
23
- 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.
24
25
- 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.
25
27
26
28
## Documentation
27
29
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
30
32
2. Simulation Data Compiler
33
+
3. Physics Objects
31
34
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.
33
38
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.
38
58
39
59
### Simulation Data Compiler Variables
40
60
- 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
47
67
48
68
## Simulation Flow
49
69
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
0 commit comments