Beispiel #1
0
void SolveAccelerationProblems2()
{
  //1. In 0.5 seconds, a projectile goes from 0 to 300 m/s. What is the acceleration of the 
  //   projectile? 
  Acceleration const rep1 = Velocity( 300. ) / Second( .5 );
  Scalar const _rep1 = rep1.GetValue();
  Assert( fequal( _rep1, 600. ) );

  //2. A meteoroid changed velocity from 1.0 km/s to 1.8 km/s in 0.03 seconds. What is
  //   the acceleration of the meteoroid? 
  Acceleration const rep2 = (Kilovelocity( 1.8 ) - Kilovelocity( 1. )) / Second( .03 );
  Scalar const _rep2 = rep2.GetValue();
  Assert( fequal( _rep2, 26666.6666666666667 ) );

  //3. The space shuttle releases a space telescope into orbit around the earth. The 
  //   telescope goes from being stationary to traveling at a speed of 1700 m/s in 25 
  //   seconds. What is the acceleration of the satellite? 
  Acceleration const rep3 = Velocity( 1700. ) / Second( 25. );
  Scalar const _rep3 = rep3.GetValue();
  Assert( fequal( _rep3, 68. ) );


  //4. A dragster in a race accelerated from stop to 60 m/s by the time it reached the 
  //   finish line. The  dragster moved in a straight line and traveled from the starting line to
  //   the finish line in 8.0 sec.   What was the acceleration of the dragster? 
  Acceleration const rep4 = Velocity( 60. ) / Second( 8. );
  Scalar const _rep4 = rep4.GetValue();
  Assert( fequal( _rep4, 7.5 ) );

}
Beispiel #2
0
void TestClassDefinition()
{
  Femtoacceleration const femtoacceleration( 1. );
  Assert( fequal( femtoacceleration.GetValue(), 1. ) );
  Assert( fequal( femtoacceleration.GetFactor(), 1.e-15 ) );

  Picoacceleration const picoacceleration( 1. );
  Assert( fequal( picoacceleration.GetValue(), 1. ) );
  Assert( fequal( picoacceleration.GetFactor(), 1.e-12 ) );

  Nanoacceleration const nanoacceleration( 1. );
  Assert( fequal( nanoacceleration.GetValue(), 1. ) );
  Assert( fequal( nanoacceleration.GetFactor(), 1.e-9 ) );

  Microacceleration const microacceleration( 1. );
  Assert( fequal( microacceleration.GetValue(), 1. ) );
  Assert( fequal( microacceleration.GetFactor(), 1.e-6 ) );

  Milliacceleration const milliacceleration( 1. );
  Assert( fequal( milliacceleration.GetValue(), 1. ) );
  Assert( fequal( milliacceleration.GetFactor(), 1.e-3 ) );

  Centiacceleration const centiacceleration( 1. );
  Assert( fequal( centiacceleration.GetValue(), 1. ) );
  Assert( fequal( centiacceleration.GetFactor(), 1.e-2 ) );

  Deciacceleration const deciacceleration( 1. );
  Assert( fequal( deciacceleration.GetValue(), 1. ) );
  Assert( fequal( deciacceleration.GetFactor(), 1.e-1 ) );

  Acceleration const acceleration( 1. );
  Assert( fequal( acceleration.GetValue(), 1. ) );
  Assert( fequal( acceleration.GetFactor(), 1. ) );

  Dekaacceleration const dekaacceleration( 1. );
  Assert( fequal( dekaacceleration.GetValue(), 1. ) );
  Assert( fequal( dekaacceleration.GetFactor(), 1.e1 ) );

  Hectoacceleration const hectoacceleration( 1. );
  Assert( fequal( hectoacceleration.GetValue(), 1. ) );
  Assert( fequal( hectoacceleration.GetFactor(), 1.e2 ) );

  Kiloacceleration const kiloacceleration( 1. );
  Assert( fequal( kiloacceleration.GetValue(), 1. ) );
  Assert( fequal( kiloacceleration.GetFactor(), 1.e3 ) );

  Megaacceleration const megaacceleration( 1. );
  Assert( fequal( megaacceleration.GetValue(), 1. ) );
  Assert( fequal( megaacceleration.GetFactor(), 1.e6 ) );

  Gigaacceleration const gigaacceleration( 1. );
  Assert( fequal( gigaacceleration.GetValue(), 1. ) );
  Assert( fequal( gigaacceleration.GetFactor(), 1.e9 ) );

  Teraacceleration const teraacceleration( 1. );
  Assert( fequal( teraacceleration.GetValue(), 1. ) );
  Assert( fequal( teraacceleration.GetFactor(), 1.e12 ) );

  Petaacceleration const petaacceleration( 1. );
  Assert( fequal( petaacceleration.GetValue(), 1. ) );
  Assert( fequal( petaacceleration.GetFactor(), 1.e15 ) );

  CarAccel const caracceleration( 1. );
  Assert( fequal( caracceleration.GetValue(), 1. ) );
  //Assert( fequal( caracceleration.GetFactor(), .27777777777777777777777777777778 ) );
}