예제 #1
0
        public void TestObject3D_AddRotationalForce()
        {
            List <PointMass> massPoints = new List <PointMass>()
            {
                //
                //  two masses about Z axis
                //
                //   5kg -------- | -------- 5kg

                new PointMass(new Vector(-5, 0, 0), 5),
                new PointMass(new Vector(5, 0, 0), 5),
            };

            Object3D obj = new Object3D(massPoints, new Vector(1, 1, 0));

            //moment of intertia = (0, 250, 250)

            //add rotational 2N force 5m from centre of mass
            //force in Z-direction, causing rotation anticlockwise about y (negative rotational direction)
            //Torque = f*d, so this is equivalent to 10Nm ===> obj.AddTorque(new Vector(5,0,0))
            obj.AddForce_OffCentre(new Vector(0, 0, 2), new Vector(5, 0, 0));

            Vector result = obj.RotationalAcceleration;

            Vector expected = new Vector(0, 10d / 250d, 0);

            Assert.AreEqual(expected, result);
        }