Hey,
I need help with my program. I'm really lost and don't know where to start.
Hopefully someone can help me.
1. Use #define to set the value for PI=3.14159265359
2. Consider an ellipse in the x, y-plane. Let a be the semi-major axis
and b be semi-minor axis of the ellipse. The center of the ellipse
is located at (x0, y0). If the major axis coincides with the x-axis,
the polar representation of the ellipse is
x - x0=a cos(theta) and y-y0=b sin(theta) (1)
However, if the major axis of the ellipse is rotated by theta0 from
the x- axis in the counterclockwise direction, the x, y-coordinates
become
x = x0 + a cos(theta)cos(theta0)-b sin(theta)sin(theta0) (2)
y = y0 + a cos(theta)sin(theta0)+b sin(theta)cos(theta0) (3)
Create the void function:
void ellipse(double a, double b, double x0, double y0,
double theta0);
The input arguments are the semi-major axis a, the minor axis b,
the origin of the ellipse (x0, y0), and the tilt angle theta0
(in degrees) of the major axis from the x-axis.
In ellipse() compute and print (x, y) from theta=0 to 360 degrees
with the increment of 10 degrees. To print use %4d, %12.3e, and
%12.3e for theta, x, and y, respectively. Your output in ellipse()
should look like as follows:
-------------------------------
theta x-coord y-coord
-------------------------------
0 3.732e+00 2.000e+00
10 3.619e+00 2.135e+00
... ......... .........
360 3.732e+00 2.000e+00
3. In prob1(), call ellipse() for a=2.0, b=1.0, x0=2.0, y0=1.0,
theta0=30.0.
4. Copy "in_ellipse.dat" from the public directory to your directory
5. In prob2() define the file stream *infile to read "in_ellipse.dat"
6. In prob2() read "in_ellipse.dat" using fgets(). Print each line as
it is read.
7. Finally, print the total number of lines in the file.



LinkBack URL
About LinkBacks


