summaryrefslogtreecommitdiff
path: root/physics/Particle.cs
diff options
context:
space:
mode:
authorAlp Toker <alp@atoker.com>2006-07-27 10:04:20 +0100
committerAlp Toker <alp@atoker.com>2006-07-27 10:04:58 +0100
commit5c1c38f64df04fd1a4d6c5be59d3d0be7d2d9644 (patch)
tree8c33379578a76307cc545b4273cec13dbf67d248 /physics/Particle.cs
parent24963900945baf5b355fd06d9a98d5bd067b215b (diff)
downloadcompiz-cil-5c1c38f64df04fd1a4d6c5be59d3d0be7d2d9644.tar.gz
compiz-cil-5c1c38f64df04fd1a4d6c5be59d3d0be7d2d9644.tar.bz2
Split out into Particle.cs
Diffstat (limited to 'physics/Particle.cs')
-rw-r--r--physics/Particle.cs50
1 files changed, 50 insertions, 0 deletions
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;
+ }
+ }
+}