SlideShare uma empresa Scribd logo
1 de 16
Baixar para ler offline
PROGRAM 6
Program to create a cylinder and Parallelepiped
by extruding Circle and Quadrilateral respectively.
Allow the user to specify the circle and
quadrilateral.
Output :
Midpoint Circle Algorithm
In the mid-point circle algorithm, we use eight-way
symmetry.
Calculate the points for the top right eighth of a
circle, and then use symmetry to get the rest of the
points.
Eight-Way Symmetry
(1, 3)
(3, 1)
(3, -1)
(1, -3)(-1, -3)
(-3, -1)
(-3, 1)
(-1, 3)
2
R
Assume x=1, y=3
(x, y)(-x, y)
(-y, x)
(-y,-x)
(y, x)
(y, -x)
(x, -y)(-x, -y)
The equation of the circle:
The equation evaluates as follows:
If we choose a point inside a circle, x2+y2<r2
If we choose a point outside a circle, x2+y2>r2
If we choose a point on the circle, x2+y2=r2
222
),( ryxyxfcirc
,0
,0
,0
),( yxfcirc
boundarycircletheinsideis),(if yx
boundarycircleon theis),(if yx
boundarycircletheoutsideis),(if yx
Midpoint Circle Algorithm
(xk+1, yk)
(xk+1, yk-1)
(xk, yk)
E
SE
(xk+1, yk- ½ )
Assuming we have just plotted the
pixel at (xk, yk) so we need to choose
between (xk+1,yk) and (xk+1,yk-1)
Our decision variable can be defined
as:
If pk < 0, the pixel at yk is closer to the
circle.
Otherwise yk-1 is closer.
222
)
2
1()1(
)
2
1,1(
ryx
yxfp
kk
kkcirck
Midpoint Circle Algorithm
(xk+1, yk)
(xk+1, yk-1)
(xk, yk)
E
SE
(xk+1, yk- ½ )
Let pk=d
dold=F(M)
dold=F(Xk+1,Yk- ½ )
If d<0, choose E
x=x+1 which gives dnew
dnew=(Xk+1)+1, (Yk- ½ )
( d)E = dnew- dold
F(Xk+2, Yk- ½ ) – F(Xk+1, Yk- ½ )
( d)E = 2Xk+3
Midpoint Circle Algorithm
(xk+1, yk)
(xk+1, yk-1)
(xk, yk)
E
SE
(xk+1, yk- ½ )
Let pk=d
dold=F(M)
dold=F(Xk+1,Yk- ½ )
If d>=0, choose SE
x=x+1
y=y-1 which gives dnew
dnew=(Xk+1)+1, (Yk- ½)-1
( d)SE = dnew-dold
F(Xk+2, Yk- 3/2) – F(Xk+1, Yk- ½)
( d)SE = 2Xk-2Yk+5
Midpoint Circle Algorithm
222
)
2
1()1(
)
2
1,1(
ryx
yxfp
kk
kkcirck
For the boundary condition, x=0, y=r
Substitute in the equation
p0=d
d=(0+1)2 + (r- ½ )2 – r2
d = 5/4 – r 1-r
For integer values of pixel coordinates, we
can approximate p0= d =1-r
#include<GL/glut.h>
void draw_pixel(GLint cx, GLint cy)
{
glColor3f(1.0,0.0,0.0);
glBegin(GL_POINTS);
glVertex2i(cx,cy);
glEnd();
}
void plotpixels(GLint h, GLint k, GLint x, GLint y)
{
draw_pixel(x+h,y+k);
draw_pixel(-x+h,y+k);
draw_pixel(x+h,-y+k);
draw_pixel(-x+h,-y+k);
draw_pixel(y+h,x+k);
draw_pixel(-y+h,x+k);
draw_pixel(y+h,-x+k);
draw_pixel(-y+h,-x+k);
}
x and y of the
window
x and y of the
circle
// Midpoint Circle Drawing Algorithm
void Circle_draw(GLint h, GLint k, GLint r)
{
GLint d =1-r, x=0, y=r;
while(y > x)
{
plotpixels(h,k,x,y);
if(d < 0) // choose E, ( d)E = 2Xk+3
d+=2*x+3;
else // choose SE, ( d)SE = 2Xk-2Yk+5
{
d+=2*(x-y)+5;
--y;
}
++x;
}
plotpixels(h,k,x,y);
}
void Cylinder_draw()
{
GLint xc=100, yc=100, r=50, i,n=50;
for(i=0;i<n;i+=3)
Circle_draw(xc,yc+i,r);
}
void parallelepiped(int x1,int x2,int y1,int y2)
{
glColor3f(0.0, 0.0, 1.0);
glBegin(GL_LINE_LOOP);
glVertex2i(x1,y1);
glVertex2i(x2,y1);
glVertex2i(x2,y2);
glVertex2i(x1,y2);
glEnd();
}
void parallelepiped_draw()
{
int x1=200,x2=300,y1=100,y2=175, i, n=40;
for(i=0;i<n;i+=2)
parallelepiped(x1+i,x2+i,y1+i,y2+i);
}
void init(void)
{
glClearColor(1.0,1.0,1.0,0.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0,400.0,0.0,300.0);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
Cylinder_draw();
parallelepiped_draw();
glFlush();
}
void main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(50,50);
glutInitWindowSize(400,300);
glutCreateWindow("Cylinder,parallelePiped Disp by Extruding
Circle &Quadrilaterl ");
init();
glutDisplayFunc(display);
glutMainLoop();
}

Mais conteúdo relacionado

Mais procurados

Mid-Point Cirle Drawing Algorithm
Mid-Point Cirle Drawing AlgorithmMid-Point Cirle Drawing Algorithm
Mid-Point Cirle Drawing Algorithm
Neha Kaurav
 
Funciones1
Funciones1Funciones1
Funciones1
Ray Mera
 
01 derivadas
01   derivadas01   derivadas
01 derivadas
klorofila
 
Howard, anton cálculo ii- um novo horizonte - exercicio resolvidos v2
Howard, anton   cálculo ii- um novo horizonte - exercicio resolvidos v2Howard, anton   cálculo ii- um novo horizonte - exercicio resolvidos v2
Howard, anton cálculo ii- um novo horizonte - exercicio resolvidos v2
Breno Costa
 

Mais procurados (20)

Solution Manual : Chapter - 02 Limits and Continuity
Solution Manual : Chapter - 02 Limits and ContinuitySolution Manual : Chapter - 02 Limits and Continuity
Solution Manual : Chapter - 02 Limits and Continuity
 
2.circle
2.circle2.circle
2.circle
 
Solution Manual : Chapter - 01 Functions
Solution Manual : Chapter - 01 FunctionsSolution Manual : Chapter - 01 Functions
Solution Manual : Chapter - 01 Functions
 
Solution Manual : Chapter - 07 Exponential, Logarithmic and Inverse Trigonome...
Solution Manual : Chapter - 07 Exponential, Logarithmic and Inverse Trigonome...Solution Manual : Chapter - 07 Exponential, Logarithmic and Inverse Trigonome...
Solution Manual : Chapter - 07 Exponential, Logarithmic and Inverse Trigonome...
 
Hand book of Howard Anton calculus exercises 8th edition
Hand book of Howard Anton calculus exercises 8th editionHand book of Howard Anton calculus exercises 8th edition
Hand book of Howard Anton calculus exercises 8th edition
 
Sbma 4603 numerical methods Assignment
Sbma 4603 numerical methods AssignmentSbma 4603 numerical methods Assignment
Sbma 4603 numerical methods Assignment
 
Tabela completa de derivadas e integrais
Tabela completa de derivadas e integraisTabela completa de derivadas e integrais
Tabela completa de derivadas e integrais
 
Mid-Point Cirle Drawing Algorithm
Mid-Point Cirle Drawing AlgorithmMid-Point Cirle Drawing Algorithm
Mid-Point Cirle Drawing Algorithm
 
Tabla integrales
Tabla integralesTabla integrales
Tabla integrales
 
Funciones1
Funciones1Funciones1
Funciones1
 
Leidy rivadeneira deber_1
Leidy rivadeneira deber_1Leidy rivadeneira deber_1
Leidy rivadeneira deber_1
 
Integral
IntegralIntegral
Integral
 
Basic m4-2-chapter1
Basic m4-2-chapter1Basic m4-2-chapter1
Basic m4-2-chapter1
 
Integral table
Integral tableIntegral table
Integral table
 
Bresenhams
BresenhamsBresenhams
Bresenhams
 
01 derivadas
01   derivadas01   derivadas
01 derivadas
 
Consolidated.m2-satyabama university
Consolidated.m2-satyabama universityConsolidated.m2-satyabama university
Consolidated.m2-satyabama university
 
Howard, anton cálculo ii- um novo horizonte - exercicio resolvidos v2
Howard, anton   cálculo ii- um novo horizonte - exercicio resolvidos v2Howard, anton   cálculo ii- um novo horizonte - exercicio resolvidos v2
Howard, anton cálculo ii- um novo horizonte - exercicio resolvidos v2
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
 
Tablas integrales
Tablas integralesTablas integrales
Tablas integrales
 

Semelhante a 10CSL67 CG LAB PROGRAM 6

48 circle part 1 of 2
48 circle part 1 of 248 circle part 1 of 2
48 circle part 1 of 2
tutulk
 
math1مرحلة اولى -compressed.pdf
math1مرحلة اولى -compressed.pdfmath1مرحلة اولى -compressed.pdf
math1مرحلة اولى -compressed.pdf
HebaEng
 

Semelhante a 10CSL67 CG LAB PROGRAM 6 (20)

Equation of a Circle in standard and general form
Equation of  a Circle in standard and general formEquation of  a Circle in standard and general form
Equation of a Circle in standard and general form
 
CIRCLES.pptx
CIRCLES.pptxCIRCLES.pptx
CIRCLES.pptx
 
Circle
CircleCircle
Circle
 
Computer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.pptComputer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.ppt
 
Week_3-Circle.pptx
Week_3-Circle.pptxWeek_3-Circle.pptx
Week_3-Circle.pptx
 
Circles any centre
Circles any centreCircles any centre
Circles any centre
 
10994479.ppt
10994479.ppt10994479.ppt
10994479.ppt
 
48 circle part 1 of 2
48 circle part 1 of 248 circle part 1 of 2
48 circle part 1 of 2
 
3. apply distance and midpoint
3.  apply distance and midpoint3.  apply distance and midpoint
3. apply distance and midpoint
 
Bresenhamcircle derivation
Bresenhamcircle derivationBresenhamcircle derivation
Bresenhamcircle derivation
 
Formulario Geometria Analitica
Formulario Geometria AnaliticaFormulario Geometria Analitica
Formulario Geometria Analitica
 
Unit 3
Unit 3Unit 3
Unit 3
 
Assignment For Matlab Report Subject Calculus 2
Assignment For Matlab Report Subject  Calculus 2Assignment For Matlab Report Subject  Calculus 2
Assignment For Matlab Report Subject Calculus 2
 
math1مرحلة اولى -compressed.pdf
math1مرحلة اولى -compressed.pdfmath1مرحلة اولى -compressed.pdf
math1مرحلة اولى -compressed.pdf
 
2.7 more parabolas a&amp; hyperbolas (optional) t
2.7 more parabolas a&amp; hyperbolas (optional) t2.7 more parabolas a&amp; hyperbolas (optional) t
2.7 more parabolas a&amp; hyperbolas (optional) t
 
MA8353 TPDE
MA8353 TPDEMA8353 TPDE
MA8353 TPDE
 
Maths05
Maths05Maths05
Maths05
 
Line circle draw
Line circle drawLine circle draw
Line circle draw
 
17 integrals of rational functions x
17 integrals of rational functions x17 integrals of rational functions x
17 integrals of rational functions x
 
Cricle.pptx
Cricle.pptxCricle.pptx
Cricle.pptx
 

Mais de Vanishree Arun

Mais de Vanishree Arun (9)

10CSL67 CG LAB PROGRAM 10
10CSL67 CG LAB PROGRAM 1010CSL67 CG LAB PROGRAM 10
10CSL67 CG LAB PROGRAM 10
 
10CSL67 CG LAB PROGRAM 9
10CSL67 CG LAB PROGRAM 910CSL67 CG LAB PROGRAM 9
10CSL67 CG LAB PROGRAM 9
 
10CSL67 CG LAB PROGRAM 8
10CSL67 CG LAB PROGRAM 810CSL67 CG LAB PROGRAM 8
10CSL67 CG LAB PROGRAM 8
 
10CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 710CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 7
 
10CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 510CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 5
 
10CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 410CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 4
 
10CSL67 CG LAB PROGRAM 3
10CSL67 CG LAB PROGRAM 310CSL67 CG LAB PROGRAM 3
10CSL67 CG LAB PROGRAM 3
 
10CSL67 CG LAB PROGRAM 2
 10CSL67 CG LAB PROGRAM 2 10CSL67 CG LAB PROGRAM 2
10CSL67 CG LAB PROGRAM 2
 
10CSL67 CG LAB PROGRAM 1
10CSL67 CG LAB PROGRAM 110CSL67 CG LAB PROGRAM 1
10CSL67 CG LAB PROGRAM 1
 

Último

VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 

Último (20)

Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 

10CSL67 CG LAB PROGRAM 6

  • 1. PROGRAM 6 Program to create a cylinder and Parallelepiped by extruding Circle and Quadrilateral respectively. Allow the user to specify the circle and quadrilateral.
  • 3. Midpoint Circle Algorithm In the mid-point circle algorithm, we use eight-way symmetry. Calculate the points for the top right eighth of a circle, and then use symmetry to get the rest of the points.
  • 4. Eight-Way Symmetry (1, 3) (3, 1) (3, -1) (1, -3)(-1, -3) (-3, -1) (-3, 1) (-1, 3) 2 R Assume x=1, y=3 (x, y)(-x, y) (-y, x) (-y,-x) (y, x) (y, -x) (x, -y)(-x, -y)
  • 5. The equation of the circle: The equation evaluates as follows: If we choose a point inside a circle, x2+y2<r2 If we choose a point outside a circle, x2+y2>r2 If we choose a point on the circle, x2+y2=r2 222 ),( ryxyxfcirc ,0 ,0 ,0 ),( yxfcirc boundarycircletheinsideis),(if yx boundarycircleon theis),(if yx boundarycircletheoutsideis),(if yx Midpoint Circle Algorithm
  • 6. (xk+1, yk) (xk+1, yk-1) (xk, yk) E SE (xk+1, yk- ½ ) Assuming we have just plotted the pixel at (xk, yk) so we need to choose between (xk+1,yk) and (xk+1,yk-1) Our decision variable can be defined as: If pk < 0, the pixel at yk is closer to the circle. Otherwise yk-1 is closer. 222 ) 2 1()1( ) 2 1,1( ryx yxfp kk kkcirck Midpoint Circle Algorithm
  • 7. (xk+1, yk) (xk+1, yk-1) (xk, yk) E SE (xk+1, yk- ½ ) Let pk=d dold=F(M) dold=F(Xk+1,Yk- ½ ) If d<0, choose E x=x+1 which gives dnew dnew=(Xk+1)+1, (Yk- ½ ) ( d)E = dnew- dold F(Xk+2, Yk- ½ ) – F(Xk+1, Yk- ½ ) ( d)E = 2Xk+3 Midpoint Circle Algorithm
  • 8. (xk+1, yk) (xk+1, yk-1) (xk, yk) E SE (xk+1, yk- ½ ) Let pk=d dold=F(M) dold=F(Xk+1,Yk- ½ ) If d>=0, choose SE x=x+1 y=y-1 which gives dnew dnew=(Xk+1)+1, (Yk- ½)-1 ( d)SE = dnew-dold F(Xk+2, Yk- 3/2) – F(Xk+1, Yk- ½) ( d)SE = 2Xk-2Yk+5 Midpoint Circle Algorithm
  • 9. 222 ) 2 1()1( ) 2 1,1( ryx yxfp kk kkcirck For the boundary condition, x=0, y=r Substitute in the equation p0=d d=(0+1)2 + (r- ½ )2 – r2 d = 5/4 – r 1-r For integer values of pixel coordinates, we can approximate p0= d =1-r
  • 10. #include<GL/glut.h> void draw_pixel(GLint cx, GLint cy) { glColor3f(1.0,0.0,0.0); glBegin(GL_POINTS); glVertex2i(cx,cy); glEnd(); }
  • 11. void plotpixels(GLint h, GLint k, GLint x, GLint y) { draw_pixel(x+h,y+k); draw_pixel(-x+h,y+k); draw_pixel(x+h,-y+k); draw_pixel(-x+h,-y+k); draw_pixel(y+h,x+k); draw_pixel(-y+h,x+k); draw_pixel(y+h,-x+k); draw_pixel(-y+h,-x+k); } x and y of the window x and y of the circle
  • 12. // Midpoint Circle Drawing Algorithm void Circle_draw(GLint h, GLint k, GLint r) { GLint d =1-r, x=0, y=r; while(y > x) { plotpixels(h,k,x,y); if(d < 0) // choose E, ( d)E = 2Xk+3 d+=2*x+3; else // choose SE, ( d)SE = 2Xk-2Yk+5 { d+=2*(x-y)+5; --y; } ++x; } plotpixels(h,k,x,y); }
  • 13. void Cylinder_draw() { GLint xc=100, yc=100, r=50, i,n=50; for(i=0;i<n;i+=3) Circle_draw(xc,yc+i,r); } void parallelepiped(int x1,int x2,int y1,int y2) { glColor3f(0.0, 0.0, 1.0); glBegin(GL_LINE_LOOP); glVertex2i(x1,y1); glVertex2i(x2,y1); glVertex2i(x2,y2); glVertex2i(x1,y2); glEnd(); }
  • 14. void parallelepiped_draw() { int x1=200,x2=300,y1=100,y2=175, i, n=40; for(i=0;i<n;i+=2) parallelepiped(x1+i,x2+i,y1+i,y2+i); } void init(void) { glClearColor(1.0,1.0,1.0,0.0); glMatrixMode(GL_PROJECTION); gluOrtho2D(0.0,400.0,0.0,300.0); }
  • 16. void main(int argc, char **argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowPosition(50,50); glutInitWindowSize(400,300); glutCreateWindow("Cylinder,parallelePiped Disp by Extruding Circle &Quadrilaterl "); init(); glutDisplayFunc(display); glutMainLoop(); }