// ************************** // // Project 1: Curling Collision // This program computes the effects when a half-size // curling stone collides with a full-size one. The effects // include the momentum shift to the large stone (its angle // and velocity) and the change in speed of the small stone // (its new velocity). // All velocities are in meters/second. // // Written by Jim Wolfe // Due on 17 January 2007 // Input: None - initial velocity of small stone and the // deflection angle are set as constants // Output: Velocity and angle of the large stone and // the remaining velocity of the small stone // ************************** #include #include #include using namespace std; const double ONE_EIGHTY = 180.0; // Degrees in a radian const double PI = 3.14159265359; // Accurate version of Pi const double INITIAL_VELOCITY = 8.0; // Starting speed of small const double SMALL_ANGLE = 40.0; // Deflection angle of small double Square (double); // Function to square a value int main () { double newVelocity; // Changed velocity of small double bigRockVelocity; // Velocity of large stone double bigRockAngle; // Angle of large stone (radians) double bigRockDegrees; // Angle of large stone (degrees) double cosSmallAngle; // Cosine of deflection double sinSmallAngle; // Sine of deflection double sinSquared; // Sine of deflection squared double cosSquared; // Cosine of deflection squared double part1; // Part 1 of formula for angle // large stone takes double part2; // Part 2 of formula cout << fixed << showpoint << setprecision(3); // Display initial conditions cout << "Initial velocity of " << INITIAL_VELOCITY << " m/s and deflection of " << SMALL_ANGLE << " degrees" << endl; // Convert to radians and get trig function values & squares cosSmallAngle = cos (SMALL_ANGLE / ONE_EIGHTY * PI); sinSmallAngle = sin (SMALL_ANGLE / ONE_EIGHTY * PI); sinSquared = Square(sinSmallAngle); cosSquared = Square(cosSmallAngle); // Calculate angle large stone takes to small stone path part1 = cosSmallAngle * sqrt(3.0 + cosSquared); part2 = sqrt((1.0 + cosSquared - part1)/4.0); bigRockAngle = asin(part2); // Convert to degrees for display bigRockDegrees = bigRockAngle * ONE_EIGHTY / PI; // Calculate large stone's velocity bigRockVelocity = (INITIAL_VELOCITY * part2) / (2.0 * (cosSmallAngle * part2 + sinSmallAngle * cos (bigRockAngle))); // Calculate small stone's remaining velocity newVelocity = 2.0 * bigRockVelocity * part2 / sinSmallAngle; // Display results cout << endl; cout << "New velocity for small rock: " << newVelocity << " m/s" << endl; cout << "Big rock velocity: " << bigRockVelocity << " m/s" << endl; cout << "Big rock angle: " << bigRockDegrees << " degrees" << endl << endl;; return 0; } // Square a floating point value double Square (double arg) // Value to take square of { return arg * arg; // Calculate and return result }