0% found this document useful (0 votes)
21 views

Program:-#Include #Include #Include #Include Int Main (Int X (4), y (4), I Double Put - X, Put - Y, T

The document describes a C program that calculates and draws a Bezier curve passing through four user-input control points. It prompts the user to enter the x and y coordinates of the points, calculates the curve equation parametrically, and draws the curve by plotting points.

Uploaded by

Kartik Guleria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Program:-#Include #Include #Include #Include Int Main (Int X (4), y (4), I Double Put - X, Put - Y, T

The document describes a C program that calculates and draws a Bezier curve passing through four user-input control points. It prompts the user to enter the x and y coordinates of the points, calculates the curve equation parametrically, and draws the curve by plotting points.

Uploaded by

Kartik Guleria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

WORKSHEET 3.

Name: Kartik Guleria UID: 19BCS2241

Section/Group
Branch: BE-CSE
: CSE-9/A
Semester: 5th

Subject Name: CG Lab Subject Code: CSP-305

Aim: - a) AIM-To calculate and draw a Bezier curve passing through four control
points.
b) AIM-To draw a B-Spline curve.

Program:-

#include<graphics.h>

#include<math.h>

#include<conio.h>

#include<stdio.h>

int main()

int x[4],y[4],i;

double put_x,put_y,t;
int gr=DETECT,gm;

initgraph(&gr,&gm,"C:\\TURBOC3\\BGI");

printf("\n*** Bezier Curve ****");

printf("\n Please enter x and y coordinates ");

for(i=0;i<4;i++)

scanf("%d%d",&x[i],&y[i]);

putpixel(x[i],y[i],3);

for(t=0.0;t<=1.0;t=t+0.001)

put_x = pow(1-t,3)x[0] + 3*t*pow(1-t,2)*x[1] + 3*t*t(1-t)*x[2] +

pow(t,3)*x[3];

put_y = pow(1-t,3)y[0] + 3*t*pow(1-t,2)*y[1] + 3*t*t(1-t)*y[2] +

pow(t,3)*y[3];

putpixel(put_x,put_y, WHITE);

}
getch();

closegraph();

}
Output :-

You might also like