/******************************************************************************
Curve Tracing - Cissoid
*******************************************************************************/
#include <iostream.h>
#include <math.h>
#include <graphics.h>
const int WIDTH = 640;
const int HEIGHT = 480;
// Function to plot a point at (x, y) with color
void plotPixel(int x, int y, int color) {
putpixel(x + WIDTH / 2, HEIGHT / 2 - y, color);
}
// Function to draw the cissoid curve
void drawCissoid(int a) {
int x, y;
for (int theta = 0; theta <= 360; theta++) {
double radian = theta * M_PI / 180.0;
double cos_theta = cos(radian);
double sin_theta = sin(radian);
// Calculate x and y coordinates using the cissoid formula
x = (a * sqrt(cos_theta)) / (1 + sin_theta * sin_theta);
y = (a * sqrt(cos_theta) * sin_theta) / (1 + sin_theta * sin_theta);
// Plot the point
plotPixel(x, y, WHITE);
}
}
void main()
{
int r;
int gd = DETECT ,gm;
initgraph(&gd, &gm, "C:\\TC\\BGI");
int a = 1000;
drawCissoid(a);
}