本文整理汇总了C#中State.ForwardStep方法的典型用法代码示例。如果您正苦于以下问题:C# State.ForwardStep方法的具体用法?C# State.ForwardStep怎么用?C# State.ForwardStep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类State
的用法示例。
在下文中一共展示了State.ForwardStep方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LinearBasicStepTest
public void LinearBasicStepTest()
{
World w = new World ();
Rigid r = new Rigid (10, new Matrix (1, 1, 1));
w.AddRigid (r);
w.AddEffect (new Force (new Vector (1, 0, 0), r));
State s = new State (w, 0.001);
s.InitState ();
s.ForwardStep ();
Assert.AreEqual (10, s.RigidStates [r].Mass, 0.0001);
Assert.AreEqual (1, s.RigidStates [r].StateForceList.Force.X, 0.001);
Assert.AreEqual (0.1, s.RigidStates [r].LinearAcceleration.X, 0.001);
}
示例2: OneWorldTwoStatesTest
public void OneWorldTwoStatesTest()
{
World w = new World ();
Rigid r1 = new Rigid (30, new Matrix (70, 70, 70));
w.AddRigid (r1);
w.AddEffect (new Force (new Vector (30, 0, 0), r1, new Vector (5, 0, 0)));
w.AddEffect (new Moment (new Vector (0, 0, 50), r1));
Rigid r2 = new Rigid (5, new Matrix (200, 200, 200));
r2.StartCenterOfMass = new Vector (10, 10, 10);
w.AddRigid (r2);
w.AddEffect (new Force (new Vector (10, 0, 0), r2, new Vector (0, -100, 0)));
State s1 = new State (w, 0.0001);
State s2 = new State (w, 0.001);
s1.Simulate (1);
s2.Simulate (2);
s1.ForwardStep ();
Assert.AreEqual (0, s1.RigidStates [r1].LinearAcceleration.Y, 0.1);
Assert.AreEqual (0, s1.RigidStates [r1].LinearVelocity.Y, 0.1);
Assert.AreEqual (0, s1.RigidStates [r1].CenterOfMass.Y, 0.1);
Assert.AreEqual (1, s1.RigidStates [r1].LinearAcceleration.X, 0.1);
Assert.AreEqual (1, s1.RigidStates [r1].LinearVelocity.X, 0.1);
Assert.AreEqual (0.5, s1.RigidStates [r1].CenterOfMass.X, 0.1);
Assert.AreEqual (0.71, s1.RigidStates [r1].AngularAcceleration.Z, 0.1);
Assert.AreEqual (0.71, s1.RigidStates [r1].AngularVelocity.Z, 0.1);
Assert.AreEqual (0.36, s1.RigidStates [r1].AnglesOfRotation.Z, 0.1);
Assert.AreEqual (0, s1.RigidStates [r2].LinearAcceleration.Y, 0.1);
Assert.AreEqual (0, s1.RigidStates [r2].LinearVelocity.Y, 0.1);
Assert.AreEqual (10, s1.RigidStates [r2].CenterOfMass.Y, 0.1);
Assert.AreEqual (2, s1.RigidStates [r2].LinearAcceleration.X, 0.1);
Assert.AreEqual (2, s1.RigidStates [r2].LinearVelocity.X, 0.1);
Assert.AreEqual (11, s1.RigidStates [r2].CenterOfMass.X, 0.1);
Assert.AreEqual (10, s1.RigidStates [r2].CenterOfMass.Z, 0.1);
Assert.AreEqual (5, s1.RigidStates [r2].AngularAcceleration.Z, 0.1);
Assert.AreEqual (5, s1.RigidStates [r2].AngularVelocity.Z, 0.1);
Assert.AreEqual (2.5, s1.RigidStates [r2].AnglesOfRotation.Z, 0.1);
Assert.AreEqual (0, s2.RigidStates [r1].LinearAcceleration.Y, 0.1);
Assert.AreEqual (0, s2.RigidStates [r1].LinearVelocity.Y, 0.1);
Assert.AreEqual (0, s2.RigidStates [r1].CenterOfMass.Y, 0.1);
Assert.AreEqual (1, s2.RigidStates [r1].LinearAcceleration.X, 0.1);
Assert.AreEqual (2, s2.RigidStates [r1].LinearVelocity.X, 0.1);
Assert.AreEqual (2, s2.RigidStates [r1].CenterOfMass.X, 0.1);
Assert.AreEqual (0.71, s2.RigidStates [r1].AngularAcceleration.Z, 0.1);
Assert.AreEqual (1.43, s2.RigidStates [r1].AngularVelocity.Z, 0.1);
Assert.AreEqual (1.43, s2.RigidStates [r1].AnglesOfRotation.Z, 0.1);
Assert.AreEqual (0, s2.RigidStates [r2].LinearAcceleration.Y, 0.1);
Assert.AreEqual (0, s2.RigidStates [r2].LinearVelocity.Y, 0.1);
Assert.AreEqual (10, s2.RigidStates [r2].CenterOfMass.Y, 0.1);
Assert.AreEqual (2, s2.RigidStates [r2].LinearAcceleration.X, 0.1);
Assert.AreEqual (4, s2.RigidStates [r2].LinearVelocity.X, 0.1);
Assert.AreEqual (14, s2.RigidStates [r2].CenterOfMass.X, 0.1);
Assert.AreEqual (10, s2.RigidStates [r2].CenterOfMass.Z, 0.1);
Assert.AreEqual (5, s2.RigidStates [r2].AngularAcceleration.Z, 0.1);
Assert.AreEqual (10, s2.RigidStates [r2].AngularVelocity.Z, 0.1);
Assert.AreEqual (10, s2.RigidStates [r2].AnglesOfRotation.Z, 0.1);
}