Beispiel #1
0
        private void testCoordinateMapping()
        {
            TranslateTransform t = new TranslateTransform();

            Flatbody a = new Flatbody(new Point(0, 0));

            t = sim.renderer.CircleTransform(a);
            Flatbody b = new Flatbody(new Point(-500, 0));

            t = sim.renderer.CircleTransform(b);
            Flatbody c = new Flatbody(new Point(500, 0));

            t = sim.renderer.CircleTransform(c);
            Flatbody d = new Flatbody(new Point(0, 500));

            t = sim.renderer.CircleTransform(d);
            Flatbody e = new Flatbody(new Point(0, -500));

            t = sim.renderer.CircleTransform(e);
        }
Beispiel #2
0
        public Point BodyToBodyAccelerate(Flatbody otherBody)
        {
            // was 10.0
            const double rMinimum = 0.1;    // we are not simulating collisions so don't let accelerations run away as bodies
                                            //  approach 0.0 separation
            const double rMinSquared = rMinimum * rMinimum;

            double dX = otherBody.position.X - this.position.X;
            double dY = otherBody.position.Y - this.position.Y;

            double rSquared = (dX * dX) + (dY * dY);

            rSquared = Math.Max(rSquared, rMinSquared); // enforce minimum value of r
            double a = otherBody.mass / rSquared;       //F = ma, g = m * m2 / rSquared, m's cancel out so a = m2 / rSquared

            double r = Math.Sqrt(rSquared);

            // return aX, aY
            return(new Point(a * dX / r, a * dY / r));
        }
Beispiel #3
0
 // Needs to be marshalled onto the UI thread
 public void UpdateMonitoredValues(Flatbody body, double simElapsedTime)
 {
     positionTextBlock.Text = "position = " + FormatPointToString(body.Position);
     velocityTextBlock.Text = "velocity = " + FormatPointToString(body.Velocity);
     timeTextBlock.Text     = String.Format("time = {0:F3}", simElapsedTime);
 }