top of page

Computer Graphics Lab

CSE:3016

Faculty In charge : Prof. Rajesh Kanna

Home: Welcome
Home: Blog2
Search

Bezier Curve

Writer's picture: theBloggerstheBloggers

Updated: Apr 3, 2019


Code:

#include<iostream>

#include<conio.h>

#include<dos.h>

#include<graphics.h>

using namespace std;

int main(){

int gd=DETECT,gm;

initgraph(&gd,&gm,"C:\\TC\\BGI");

int px,py,i,n;

cout<<"Enter the number of control points: ";

cin>>n;

int x[n],y[n];

cout<<"Enter the coordinates of control points for bezier curve: ";

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

{

cin>>x[i]>>y[i];

}

for(i=0;i<n-1;i++)

{

line(x[i],y[i],x[i+1],y[i+1]);

}

double t;

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

{

px=(1-t)*(1-t)*(1-t)*x[0]+3*t*(1-t)*(1-t)*x[1]+3*t*t*(1-t)*x[2]+t*t*t*x[3];

py=(1-t)*(1-t)*(1-t)*y[0]+3*t*(1-t)*(1-t)*y[1]+3*t*t*(1-t)*y[2]+t*t*t*y[3];

putpixel(px,py,YELLOW);

delay(1);

}

getch();

closegraph();

return 0;

}


Output:







32 views0 comments

Recent Posts

See All

Comments


Home: Blog Feed

Meet theBloggers !

This Blog was created by students of Computer Graphics and Design Class (CSE3016) with sole purpose of relaying information of the different activities performed throughout the course period.

theBloggers
Ibra Nafis - 17BCE1230

Bhavya S Chauhan - 17BCE1270

Home: About

© Proudly created with Wix.com

bottom of page