コード例 #1
0
ファイル: PhysicsTests.cs プロジェクト: skeryl/OpenScience
 public void TestElectromagnetism()
 {
     var particleOne = new Sphere().SetCharge(new Coulomb(1));
     var particleTwo = new Sphere().SetCharge(new Coulomb(1)).SetCoordinates(PhysicalCoordinate<Meter>.Create(0,0,1));
     Newton forceBetween = Electromagnetism.ForceBetween(particleOne, particleTwo);
     Assert.AreEqual(8987551787.3681755, forceBetween.Value);
 }
コード例 #2
0
ファイル: PhysicsTests.cs プロジェクト: skeryl/OpenScience
        public void TestGravitation()
        {
            var earth = new Sphere(new Meter(6378100), new Kilogram(5.98 * (Math.Pow(10, 24))));
            earth.SetCoordinates(PhysicalCoordinate<Meter>.Create(0, 0, 6378100));

            var shaneOnGround = new Sphere(new Centimeter(85), new Kilogram(79.37));

            var shaneAtWork = new Sphere(new Centimeter(85), new Kilogram(79.37));
            shaneAtWork.SetCoordinates(PhysicalCoordinate<Meter>.Create(0, 0, -20));

            var shaneOnPlane = new Sphere(new Centimeter(85), new Kilogram(79.37));
            shaneOnPlane.SetCoordinates(PhysicalCoordinate<Meter>.Create(0, 0, -11277.6));

            var halfwayToMoon = new Sphere(new Centimeter(85), new Kilogram(79.37));
            halfwayToMoon.SetCoordinates(PhysicalCoordinate<Meter>.Create(0, 0, -192201500));

            var forceOnGround = Gravitation.GravityBetween(shaneOnGround, earth);
            var forceAtWork = Gravitation.GravityBetween(shaneAtWork, earth);
            Assert.Less(forceAtWork.Value, forceOnGround.Value);

            var forceOnPlane = Gravitation.GravityBetween(shaneOnPlane, earth);
            Assert.Less(forceOnPlane.Value, forceAtWork.Value);

            var forceHalfwayToMoon = Gravitation.GravityBetween(halfwayToMoon, earth);
            Assert.Less(forceHalfwayToMoon.Value, forceOnPlane.Value);
        }
コード例 #3
0
        public void SphereTests()
        {
            var sphere = new Sphere(new Meter(1));
            var volume = sphere.GetVolume<Meter>();
            Assert.AreEqual(4/3*Math.PI, volume.Value); // 4/3 * pi * r^2

            sphere.SetRadius(new Meter(5));
            Assert.AreEqual(4/3*Math.PI*Math.Pow(sphere.GetRadius<Meter>().Value,3), sphere.GetVolume<Meter>().Value);

            sphere.SetMass(new Kilogram(50));
            Assert.AreEqual(50000, sphere.GetMass<Gram>().Value);
        }