コード例 #1
0
ファイル: PlaneBody.cs プロジェクト: dkarpushkin/TeorMech
        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);
            }
        }
コード例 #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;
        }
コード例 #3
0
 public Collision checkCollisiion(SphereBody body1, SphereBody body2)
 {
     throw new NotImplementedException();
 }
コード例 #4
0
ファイル: SphereBody.cs プロジェクト: dkarpushkin/TeorMech
 public Collision checkCollisionWith(SphereBody body)
 {
 }