CG 33
CG 33
Interactive Learning: Enhances understanding of the solar system through a visual and
engaging representation.
Programming Skills: Develops expertise in using the Xe language for animation and
simulation.
Integrate physics and motion principles into programming for real-world applications.
1. Requirement Analysis: Study the solar system's components, orbital mechanics, and motion
characteristics.
2. Design: Create a storyboard outlining the animation flow, including planets, orbits, and
celestial interactions.
3. Development: Use Xe language to code the animation with features like planet rotation,
revolution, and scaling.
4. Testing and Debugging: Ensure smooth transitions, accurate orbital paths, and
synchronization of planetary motion.
5. Documentation: Record observations, code structure, and user guidelines for
future reference..
Literature Review:
The information about the topic was collected by different sources such as a different reference
book, YouTube, and also we meet the teacher relate with this topic the corresponding subject in
our college we got good information from our subject teacher Mrs. S. K. Kharkate
Problem Analysis: Define the scope of the animation (e.g., number of planets, speed of motion,
and graphical accuracy).
Resource Preparation: Install and configure the C compiler (like Turbo C++) and graphics
library (graphics.h).
Algorithm Design:
Development:
Draw celestial bodies using functions like circle(), ellipse(), and line().
4.Draw Planets:
For each planet, draw it using pieslice() at the appropriate coordinates based on
the precomputed orbital positions.
Display each planet’s name beside it using outtextxy().
Update the position of each planet by decreasing the position index (pos[i] =
(pos[i] <= 0) ? 59 : pos[i] - 1;) to simulate motion.
6. Pause for Delay:
Once the loop ends (when a key is pressed), use getch() to capture the input
and exit the program.
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <dos.h>
#include <math.h>
void planetmotion(int xrad, int yrad, int midx, int midy, int x[60], int y[60]) {
int i, j = 0;
for (i = 0; i < 360; i += 6) {
x[j] = midx - (int)(xrad * cos(i * 3.14159 / 180));
y[j++] = midy - (int)(yrad * sin(i * 3.14159 / 180));
}
}
void main() {
int gd = DETECT, gm, midx, midy;
int xrad[9], yrad[9], x[9][60], y[9][60];
int pos[9] = {0, 6, 12, 18, 24, 30, 36, 42, 48};
int planet[9] = {7, 8, 9, 10, 11, 12, 13, 14, 15};
int planetColors[9] = {CYAN, GREEN, BLUE, RED, BROWN, LIGHTGRAY, BROWN,
LIGHTBLUE, LIGHTRED};
char *planetNames[9] = {"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus",
"Neptune", "Pluto"};
int i;
xrad[0] = 60;
yrad[0] = 30;
for (i = 1; i < 9; i++) {
xrad[i] = xrad[i - 1] + 30;
yrad[i] = yrad[i - 1] + 15;
}
// Animation loop
while (!kbhit()) {
setcolor(WHITE);
for (i = 0; i < 9; i++) {
ellipse(midx, midy, 0, 360, xrad[i], yrad[i]);
}
// Draw Sun
setcolor(YELLOW);
setfillstyle(SOLID_FILL, YELLOW);
circle(midx, midy, 20);
floodfill(midx, midy, YELLOW);
delay(100);
cleardevice();
}
getch();
closegraph();
}
OUTPUT:-