summaryrefslogtreecommitdiff
path: root/physics
diff options
context:
space:
mode:
Diffstat (limited to 'physics')
-rw-r--r--physics/Makefile4
-rw-r--r--physics/Model.cs45
-rw-r--r--physics/Particle.cs50
3 files changed, 52 insertions, 47 deletions
diff --git a/physics/Makefile b/physics/Makefile
index a1c996a..9c70fbc 100644
--- a/physics/Makefile
+++ b/physics/Makefile
@@ -2,8 +2,8 @@ CSC=gmcs -debug
all: model.dll
-model.dll: Model.cs
- $(CSC) -out:$@ -t:library Model.cs
+model.dll: Model.cs Particle.cs
+ $(CSC) -out:$@ -t:library Model.cs Particle.cs
#note, needs Mono.Cairo 2.0, not the 1.0 in pkg-config
diff --git a/physics/Model.cs b/physics/Model.cs
index 29a656f..550e3d8 100644
--- a/physics/Model.cs
+++ b/physics/Model.cs
@@ -177,51 +177,6 @@ namespace PhysModel
}
}
- public class Particle
- {
- public Vector Force;
-
- public Point Position;
- public Point PreviousPosition;
- public Vector Velocity;
-
- public double Mass;
- public double Theta;
-
- /*
- public Particle (Point position, double mass)
- {
- this.Position = position;
- this.PreviousPosition = position;
- this.Mass = mass;
- }
- */
-
- public double GetDistance (Point p)
- {
- Vector d = Position - p;
- return Math.Sqrt (d.X*d.X + d.Y*d.Y);
- }
-
- public void AccumulateForces (Model Model)
- {
- //Gravity
- Force = Model.Gravity * Mass;
-
- //Friction
- Vector v = Position - PreviousPosition;
-
- Force -= v * Model.Friction;
- }
-
- public void Integrate (double step)
- {
- Point original_position = Position;
- Position += Position - PreviousPosition + Force * step * step;
- PreviousPosition = original_position;
- }
- }
-
public class Stick
{
public Particle A;
diff --git a/physics/Particle.cs b/physics/Particle.cs
new file mode 100644
index 0000000..177d22e
--- /dev/null
+++ b/physics/Particle.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+
+namespace PhysModel
+{
+ public class Particle
+ {
+ public Vector Force;
+
+ public Point Position;
+ public Point PreviousPosition;
+ public Vector Velocity;
+
+ public double Mass;
+ public double Theta;
+
+ /*
+ public Particle (Point position, double mass)
+ {
+ this.Position = position;
+ this.PreviousPosition = position;
+ this.Mass = mass;
+ }
+ */
+
+ public double GetDistance (Point p)
+ {
+ Vector d = Position - p;
+ return Math.Sqrt (d.X*d.X + d.Y*d.Y);
+ }
+
+ public void AccumulateForces (Model Model)
+ {
+ //Gravity
+ Force = Model.Gravity * Mass;
+
+ //Friction
+ Vector v = Position - PreviousPosition;
+
+ Force -= v * Model.Friction;
+ }
+
+ public void Integrate (double step)
+ {
+ Point original_position = Position;
+ Position += Position - PreviousPosition + Force * step * step;
+ PreviousPosition = original_position;
+ }
+ }
+}