Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Consider an ellipse in the x, y-plane. Let a be the semi-majoraxis and b be s

ID: 3609073 • Letter: 1

Question

1. Consider an ellipse in the x, y-plane. Let a be the semi-majoraxis
and b be semi-minor axis of the ellipse. The center of theellipse
is located at (x0, y0). If the major axis coincides with thex-axis,
the polar representation of the ellipse is
        x - x0=a cos(theta) andy-y0=b sin(theta)       (1)
   However, if the major axis of the ellipse is rotatedby theta0 from
   the x- axis in the counterclockwise direction, the x,y-coordinates
   become
    x = x0 + a cos(theta)cos(theta0)-bsin(theta)sin(theta0) (2)
    y = y0 + a cos(theta)sin(theta0)+bsin(theta)cos(theta0) (3)

   Create the void function:

   void ellipse(double a, double b, double x0, doubley0,
               double theta0);

   The input arguments are the semi-major axis a, theminor axis b,
   the origin of the ellipse (x0, y0), and the tilt angletheta0
   (in degrees) of the major axis from the x-axis.
   In ellipse() compute and print (x, y) from theta=0 to360 degrees
   with the increment of 10 degrees. To print use %4d,%12.3e, and
   %12.3e for theta, x, and y, respectively. Your outputin 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

2. In prob1(), call ellipse() for a=2.0, b=1.0, x0=2.0, y0=1.0,
   theta0=30.0.

3. Copy "in_ellipse.dat" from the public directory to yourdirectory
4. In prob2() define the file stream *infile to read"in_ellipse.dat"
5. In prob2() read "in_ellipse.dat" using fgets(). Print each lineas
   it is read.
6. Finally, print the total number of lines in the file.



#include <stdio.h>
#include <math.h>
#define PI 3.14159265

//Function prototypes
void prob1(void);
void prob2(void);
void ellipse(double a, double b, double x0, double y0, doubletheta0);
int main(void)
{
        int menu;
        printf(" There are twoparts. ");
        printf("Enter the partnumber to execute (1, or 2): ");
        scanf("%d",&menu);
        // form a switch toexecute one part
        switch(menu){
           case 1:
               prob1();
               break;
           case 2:
               prob2();
               break;
           default:
               printf("part %d does not exist. ", menu);
        }
        exit(0);
}
void prob1(void)
{
//Declare a, b, x0, y0, and theta0 here

//Call ellipse here

        return;
}
void ellipse(double a, double b, double x0, double y0, doubletheta0)
{
//Add your statements

        return;
}
void prob2(void)
{
//Add your statements

        return;
}


in_ellipse.dat:
#Ellipse
#-------------------------------
#theta   x-coord      y-coord
#-------------------------------
   0    3.732e+00   2.000e+00
10    3.619e+00   2.135e+00
20    3.457e+00   2.236e+00
30    3.250e+00   2.299e+00
40    3.005e+00   2.323e+00
50    2.730e+00   2.306e+00
60    2.433e+00   2.250e+00
70    2.123e+00   2.156e+00
80    1.808e+00   2.027e+00
90    1.500e+00   1.866e+00
100    1.207e+00   1.679e+00
110    9.378e-01   1.472e+00
120    7.010e-01   1.250e+00
130    5.036e-01   1.021e+00
140    3.518e-01   7.906e-01
150    2.500e-01   5.670e-01
160    2.014e-01   3.565e-01
170    2.074e-01   1.656e-01
180    2.679e-01   -1.179e-11
190    3.811e-01   -1.352e-01
200    5.434e-01   -2.359e-01
210    7.500e-01   -2.990e-01
220    9.946e-01   -3.227e-01
230    1.270e+00   -3.062e-01
240    1.567e+00   -2.500e-01
250    1.877e+00   -1.558e-01
260    2.192e+00   -2.652e-02
270    2.500e+00   1.340e-01
280    2.793e+00   3.208e-01
290    3.062e+00   5.282e-01
300    3.299e+00   7.500e-01
310    3.496e+00   9.794e-01
320    3.648e+00   1.209e+00
330    3.750e+00   1.433e+00
340    3.799e+00   1.643e+00
350    3.793e+00   1.834e+00
360    3.732e+00   2.000e+00

Explanation / Answer

can anyone help me out.?