Example #1
0
        public override Collision checkCollisionWith(SphereBody body)
        {
            double dist = distanceToPoint(body.Position);

            if (dist < body.Radius)
            {
                Vector normal     = Normal;
                Vector startPoint = (Vector)(body.Position - Normal);
                Vector endPoint   = (Vector)(body.Position - Normal * dist);

                return(new Collision(startPoint, endPoint, normal, this, body));
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        static void practice1()
        {
            World world = new World();

//            PlaneBody ground = new PlaneBody(
//                double.PositiveInfinity,
//                0, 0, 0,
//                0, 0, 1);
//            world.addBody(ground);
            SphereBody body = new SphereBody(
                1,
                0, 0, 100,
                0, 0, 0);

            world.addBody(body);

            world.addGlobalForce(new SimpleGravity());

            //double[] v = { 0, 0, 10 };
            //body.applyForce(new TemporalForce((Vector)Vector.Build.DenseOfArray(v), 1.0));

            Console.Write("Tell me the magnitude of the initial velocity:  ");
            double vel_scalar;

            while (!double.TryParse(Console.ReadLine(), out vel_scalar))
            {
                Console.Write("I need a floating point number:  ");
            }

            Console.Write("Tell me its angle to the X axis:  ");
            double angle;

            while (!double.TryParse(Console.ReadLine(), out angle))
            {
                Console.Write("I need a floating point number:  ");
            }

            double tan = Math.Tan(angle * Math.PI / 180);

            double[] vel      = { 1, tan, 0 };
            Vector   velocity = (Vector)(Vector.Build.DenseOfArray(vel).Normalize(2) * vel_scalar);

            body.Velocity = velocity;

            StreamWriter outputStream = new StreamWriter("./output.txt");

            outputBodyData(outputStream, 0.0, body, true);

            double iterationStep  = 0.1;
            double iterationFrame = 10;

            for (double t = 0; t < iterationFrame; t += iterationStep)
            {
                world.update(iterationStep);
                outputBodyData(outputStream, t, body);
            }

            outputStream.Close();

            return;
        }
 public Collision checkCollisiion(SphereBody body1, SphereBody body2)
 {
     throw new NotImplementedException();
 }
Example #4
0
 public Collision checkCollisionWith(SphereBody body)
 {
 }