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

Looking for working .CPP source code of the elliptical orbits. Using Visual C++

ID: 3684939 • Letter: L

Question

Looking for working .CPP source code of the elliptical orbits.

Using Visual C++ and your OpenGL configured environment, write an application that displays a graphical scene that displays a top-down, 2-D (non-animated) view of the Sun and at least 4 planets of our solar system. You can assume elliptical orbits for all of the planets in your scene. Sizes of the ellipses should be scaled to the actual distances from the Sun. You should include circles representing each of the planets and the Sun in your scene. Sizes of the objects should be scaled proportional to their actual size (with the exception of the Sun as it will be most likely too large to have other planet be visible). Be sure to label each of your planets and the Sun. In the word document you submit, describe exactly how you scaled your planets and elliptical orbits.

Be sure to reference your source for planet size, and distance from the Sun. (e.g.

http://www.solarviews.com/eng/solarsys.htm)

A “rough” graphics scene might look like this:

My Solar System Sun Mercury Venus Mars Reference: http://www.solarviews.com/eng/solarsys.htm)

Explanation / Answer

#define R 5
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>
#include<stdlib.h>
void main()

{
void orbit(void);
int d=DETECT,m;
initgraph(&d,&m,"e: ccgi");
float xx,yy,aa=15,bb=50,x,y,X,Y,a=34,b=0,A=100,B=60,ex,sq;
setcolor(14);
for(float i=0;i<=720;i+=.1)

{

x=a*cos(i+10)-a*sin(i+10);
y=b*sin(i+10)+a*cos(i+10);

X=A*cos(i+20)-B*sin(i+20+90);
Y=B*sin(i+20)+B*cos(i+20+90);

xx=aa*cos(i);
yy=bb*sin(i);

setcolor(14);
setfillstyle(1,14);
circle(x+100,y+100,R);
floodfill(x+100,y+100,14);

setcolor(14);
setfillstyle(1,14);
circle(xx+100,yy+100,R);
floodfill(xx+100,yy+100,14);

setcolor(14);
setfillstyle(1,14);
circle(X+100,Y+100,R);
floodfill(X+100,Y+100,14);

putpixel(X+100,Y+100,4);
delay(100);

setcolor(0);
setfillstyle(1,0);
circle(x+100,y+100,R);
floodfill(x+100,y+100,0);

setcolor(0);
setfillstyle(1,0);
circle(xx+100,yy+100,R);
floodfill(xx+100,yy+100,0);

setcolor(0);
setfillstyle(1,0);
circle(X+100,Y+100,R);
floodfill(X+100,Y+100,0);

if(kbhit())
   exit(1);
orbit();
}

getch();
}

void orbit()
{
for(float i=0;i<=60;i+=1)
{
float xx,yy,aa=15,bb=50,x,y,X,Y,a=34,b=0,A=100,B=60,ex,sq;
x=a*cos(i)-a*sin(i);
y=b*sin(i)+a*cos(i);

X=A*cos(i)-B*sin(i+90);
Y=B*sin(i)+B*cos(i+90);

xx=aa*cos(i);
yy=bb*sin(i);

putpixel(x+100,y+100,14);
putpixel(X+100,Y+100,14);
putpixel(xx+100,yy+100,14);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote