SlideShare une entreprise Scribd logo
1  sur  11
Télécharger pour lire hors ligne
PROGRAM 1
Program to recursively subdivide a tetrahedron to
form 3D Sierpinski gasket. The number of recursive
steps is to be specified by the user.
3D Sierpinski gasket
• A fractal which can be constructed by
a recursive procedure; at each step a
triangle is divided into four new
triangles.
• The central triangle is removed and
each of the other three treated as the
original was, and so on, creating an
infinite regression in a finite space.
• Origin:
1970s: named after Wacław
Sierpiński (1882–1969), Polish
mathematician
• Application :
Fractal geometry
No. of divisions : 0
No. of divisions : 1
V0(0,0,10)
V1(0,10,-10)
V2(-10,-10,-10) V3(10,-10,-10)
-X +X
-Y
+Y
No. of divisions : 1
No. of divisions : 3
#include <stdio.h>
#include <GL/glut.h>
typedef float point[3];
/* initial tetrahedron */
point v[4] = { {0.0, 0.0, 10.0}, {0.0, 10.0, -10.0},
{-10.0, -10.0, -10.0}, {10.0, -10.0, -10.0}
};
int n;
/* display one triangle */
void triangle( point a, point b, point c)
{ glBegin(GL_POLYGON);
glVertex3fv(a);
glVertex3fv(b);
glVertex3fv(c);
glEnd();
}
/* triangle subdivision */
void divide_triangle(point a, point b, point c, int m)
{
point p1, p2, p3;
int i;
if(m>0)
{
for(i=0; i<3; i++) p1[i]=(a[i]+b[i])/2;
for(i=0; i<3; i++) p2[i]=(a[i]+c[i])/2;
for(i=0; i<3; i++) p3[i]=(b[i]+c[i])/2;
divide_triangle(a, p1, p2, m-1);
divide_triangle(c, p2, p3, m-1);
divide_triangle(b, p3, p1, m-1);
}
else
triangle(a,b,c); /* draw triangle at end of recursion */
}
/* Apply triangle subdivision to faces of tetrahedron */
void tetrahedron( int m)
{
glColor3f(1.0,0.0,0.0);
divide_triangle(v[0], v[1], v[2], m);
glColor3f(0.0,1.0,0.0);
divide_triangle(v[3], v[2], v[1], m);
glColor3f(0.0,0.0,1.0);
divide_triangle(v[0], v[3], v[1], m);
glColor3f(0.0,0.0,0.0);
divide_triangle(v[0], v[2], v[3], m);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// to reset the buffer and for hidden surface removal
glLoadIdentity();
tetrahedron(n);
glFlush();
}
void myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
// matrix mode – defines CTM, GL_PROJECTION to view in ortho
glLoadIdentity(); // identity matrix resets the matrix to its default state
if (w <= h)
glOrtho(-12.0, 12.0, -12.0 * (GLfloat) h / (GLfloat) w, 12.0 * (GLfloat) h / (GLfloat) w, -12.0, 12.0);
else
glOrtho(-12.0 * (GLfloat) w / (GLfloat) h, 12.0 * (GLfloat) w / (GLfloat) h, -12.0, 12.0, -12.0, 12.0);
glMatrixMode(GL_MODELVIEW); // transformations done in model view
glutPostRedisplay();
}
void main(int argc, char **argv)
{
printf(" No. of Divisions ? ");
scanf("%d",&n);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
/* This is to view the behind triangle */
glutInitWindowSize(500, 500);
glutCreateWindow("3D Gasket");
glClearColor (1.0, 1.0, 1.0, 1.0);
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
glEnable(GL_DEPTH_TEST); // enable the hidden surface
glutMainLoop();
}

Contenu connexe

Tendances

حساب النهايات جبرياً
حساب النهايات جبرياًحساب النهايات جبرياً
حساب النهايات جبرياًsdthgpr
 
79ecb3d9 65f4-4161-b97d-63711df5d6c5
79ecb3d9 65f4-4161-b97d-63711df5d6c579ecb3d9 65f4-4161-b97d-63711df5d6c5
79ecb3d9 65f4-4161-b97d-63711df5d6c5spoider
 
Calc224FinalExamReview
Calc224FinalExamReviewCalc224FinalExamReview
Calc224FinalExamReviewTori Peña
 
Bicubic interpolation codes
Bicubic interpolation codesBicubic interpolation codes
Bicubic interpolation codesmmjalbiaty
 
All three forms (variety)
All three forms (variety)All three forms (variety)
All three forms (variety)MsKendall
 
Fractal Rendering in Developer C++ - 2012-11-06
Fractal Rendering in Developer C++ - 2012-11-06Fractal Rendering in Developer C++ - 2012-11-06
Fractal Rendering in Developer C++ - 2012-11-06Aritra Sarkar
 
Giaotrinhmaplenguyenchanhtu1
Giaotrinhmaplenguyenchanhtu1Giaotrinhmaplenguyenchanhtu1
Giaotrinhmaplenguyenchanhtu1Thuy Lan
 

Tendances (19)

Rolle's theorem
Rolle's theorem Rolle's theorem
Rolle's theorem
 
New day 8 examples
New day 8 examplesNew day 8 examples
New day 8 examples
 
حساب النهايات جبرياً
حساب النهايات جبرياًحساب النهايات جبرياً
حساب النهايات جبرياً
 
79ecb3d9 65f4-4161-b97d-63711df5d6c5
79ecb3d9 65f4-4161-b97d-63711df5d6c579ecb3d9 65f4-4161-b97d-63711df5d6c5
79ecb3d9 65f4-4161-b97d-63711df5d6c5
 
Calc224FinalExamReview
Calc224FinalExamReviewCalc224FinalExamReview
Calc224FinalExamReview
 
Gradient
GradientGradient
Gradient
 
Hw #2
Hw #2Hw #2
Hw #2
 
MATHS SYMBOLS - #1 - EXPONENTIALS and THEIR PROPERTIES
MATHS SYMBOLS - #1 - EXPONENTIALS and THEIR PROPERTIESMATHS SYMBOLS - #1 - EXPONENTIALS and THEIR PROPERTIES
MATHS SYMBOLS - #1 - EXPONENTIALS and THEIR PROPERTIES
 
Bicubic interpolation codes
Bicubic interpolation codesBicubic interpolation codes
Bicubic interpolation codes
 
Gp
GpGp
Gp
 
All three forms (variety)
All three forms (variety)All three forms (variety)
All three forms (variety)
 
Fractal Rendering in Developer C++ - 2012-11-06
Fractal Rendering in Developer C++ - 2012-11-06Fractal Rendering in Developer C++ - 2012-11-06
Fractal Rendering in Developer C++ - 2012-11-06
 
Figures
FiguresFigures
Figures
 
Special factor patterns
Special factor patternsSpecial factor patterns
Special factor patterns
 
201707 SER332 Lecture 17
201707 SER332 Lecture 17   201707 SER332 Lecture 17
201707 SER332 Lecture 17
 
Htdp27.key
Htdp27.keyHtdp27.key
Htdp27.key
 
Notes 10-5
Notes 10-5Notes 10-5
Notes 10-5
 
Factoring
FactoringFactoring
Factoring
 
Giaotrinhmaplenguyenchanhtu1
Giaotrinhmaplenguyenchanhtu1Giaotrinhmaplenguyenchanhtu1
Giaotrinhmaplenguyenchanhtu1
 

Similaire à 10CSL67 CG LAB PROGRAM 1

Fourier series example
Fourier series exampleFourier series example
Fourier series exampleAbi finni
 
Delaunay triangulation from 2-d delaunay to 3-d delaunay
Delaunay triangulation   from 2-d delaunay to 3-d delaunayDelaunay triangulation   from 2-d delaunay to 3-d delaunay
Delaunay triangulation from 2-d delaunay to 3-d delaunaygreentask
 
TRIEST: Counting Local and Global Triangles in Fully-Dynamic Streams with Fix...
TRIEST: Counting Local and Global Triangles in Fully-Dynamic Streams with Fix...TRIEST: Counting Local and Global Triangles in Fully-Dynamic Streams with Fix...
TRIEST: Counting Local and Global Triangles in Fully-Dynamic Streams with Fix...Two Sigma
 
TM plane wave scattering from finite rectangular grooves in a conducting plan...
TM plane wave scattering from finite rectangular grooves in a conducting plan...TM plane wave scattering from finite rectangular grooves in a conducting plan...
TM plane wave scattering from finite rectangular grooves in a conducting plan...Yong Heui Cho
 
CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingMark Kilgard
 
CS 354 More Graphics Pipeline
CS 354 More Graphics PipelineCS 354 More Graphics Pipeline
CS 354 More Graphics PipelineMark Kilgard
 
Mm chap08 -_lossy_compression_algorithms
Mm chap08 -_lossy_compression_algorithmsMm chap08 -_lossy_compression_algorithms
Mm chap08 -_lossy_compression_algorithmsEellekwameowusu
 
Im looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfIm looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfcontact41
 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksJinTaek Seo
 
Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)
Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)
Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)Kyuseok Hwang(allosha)
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3Droxlu
 
Butterfly Counting in Bipartite Networks
Butterfly Counting in Bipartite NetworksButterfly Counting in Bipartite Networks
Butterfly Counting in Bipartite NetworksSeyed-Vahid Sanei-Mehri
 
TAO Fayan_X-Ray and MIP volume rendering
TAO Fayan_X-Ray and MIP volume renderingTAO Fayan_X-Ray and MIP volume rendering
TAO Fayan_X-Ray and MIP volume renderingFayan TAO
 

Similaire à 10CSL67 CG LAB PROGRAM 1 (20)

Fourier series example
Fourier series exampleFourier series example
Fourier series example
 
testpang
testpangtestpang
testpang
 
Delaunay triangulation from 2-d delaunay to 3-d delaunay
Delaunay triangulation   from 2-d delaunay to 3-d delaunayDelaunay triangulation   from 2-d delaunay to 3-d delaunay
Delaunay triangulation from 2-d delaunay to 3-d delaunay
 
DCT
DCTDCT
DCT
 
DCT
DCTDCT
DCT
 
DCT
DCTDCT
DCT
 
TRIEST: Counting Local and Global Triangles in Fully-Dynamic Streams with Fix...
TRIEST: Counting Local and Global Triangles in Fully-Dynamic Streams with Fix...TRIEST: Counting Local and Global Triangles in Fully-Dynamic Streams with Fix...
TRIEST: Counting Local and Global Triangles in Fully-Dynamic Streams with Fix...
 
TM plane wave scattering from finite rectangular grooves in a conducting plan...
TM plane wave scattering from finite rectangular grooves in a conducting plan...TM plane wave scattering from finite rectangular grooves in a conducting plan...
TM plane wave scattering from finite rectangular grooves in a conducting plan...
 
CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and Culling
 
CS 354 More Graphics Pipeline
CS 354 More Graphics PipelineCS 354 More Graphics Pipeline
CS 354 More Graphics Pipeline
 
Mm chap08 -_lossy_compression_algorithms
Mm chap08 -_lossy_compression_algorithmsMm chap08 -_lossy_compression_algorithms
Mm chap08 -_lossy_compression_algorithms
 
Im looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfIm looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdf
 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
 
5th Semester Electronic and Communication Engineering (2013-June) Question Pa...
5th Semester Electronic and Communication Engineering (2013-June) Question Pa...5th Semester Electronic and Communication Engineering (2013-June) Question Pa...
5th Semester Electronic and Communication Engineering (2013-June) Question Pa...
 
2013-June: 5th Semester E & C Question Papers
2013-June: 5th Semester E & C Question Papers2013-June: 5th Semester E & C Question Papers
2013-June: 5th Semester E & C Question Papers
 
Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)
Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)
Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3D
 
Butterfly Counting in Bipartite Networks
Butterfly Counting in Bipartite NetworksButterfly Counting in Bipartite Networks
Butterfly Counting in Bipartite Networks
 
Finger detection
Finger detectionFinger detection
Finger detection
 
TAO Fayan_X-Ray and MIP volume rendering
TAO Fayan_X-Ray and MIP volume renderingTAO Fayan_X-Ray and MIP volume rendering
TAO Fayan_X-Ray and MIP volume rendering
 

Plus de Vanishree Arun

10CSL67 CG LAB PROGRAM 10
10CSL67 CG LAB PROGRAM 1010CSL67 CG LAB PROGRAM 10
10CSL67 CG LAB PROGRAM 10Vanishree Arun
 
10CSL67 CG LAB PROGRAM 9
10CSL67 CG LAB PROGRAM 910CSL67 CG LAB PROGRAM 9
10CSL67 CG LAB PROGRAM 9Vanishree Arun
 
10CSL67 CG LAB PROGRAM 8
10CSL67 CG LAB PROGRAM 810CSL67 CG LAB PROGRAM 8
10CSL67 CG LAB PROGRAM 8Vanishree Arun
 
10CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 710CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 7Vanishree Arun
 
10CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 610CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 6Vanishree Arun
 
10CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 510CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 5Vanishree Arun
 
10CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 410CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 4Vanishree Arun
 
10CSL67 CG LAB PROGRAM 3
10CSL67 CG LAB PROGRAM 310CSL67 CG LAB PROGRAM 3
10CSL67 CG LAB PROGRAM 3Vanishree Arun
 
10CSL67 CG LAB PROGRAM 2
 10CSL67 CG LAB PROGRAM 2 10CSL67 CG LAB PROGRAM 2
10CSL67 CG LAB PROGRAM 2Vanishree Arun
 

Plus 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 6
10CSL67 CG LAB PROGRAM 610CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 6
 
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
 

Dernier

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
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...Call Girls in Nagpur High Profile
 
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 torqueBhangaleSonal
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
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 Bookingdharasingh5698
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoordharasingh5698
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
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...roncy bisnoi
 

Dernier (20)

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
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...
 
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
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
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
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
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
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 

10CSL67 CG LAB PROGRAM 1

  • 1. PROGRAM 1 Program to recursively subdivide a tetrahedron to form 3D Sierpinski gasket. The number of recursive steps is to be specified by the user.
  • 2. 3D Sierpinski gasket • A fractal which can be constructed by a recursive procedure; at each step a triangle is divided into four new triangles. • The central triangle is removed and each of the other three treated as the original was, and so on, creating an infinite regression in a finite space. • Origin: 1970s: named after Wacław Sierpiński (1882–1969), Polish mathematician • Application : Fractal geometry
  • 7. #include <stdio.h> #include <GL/glut.h> typedef float point[3]; /* initial tetrahedron */ point v[4] = { {0.0, 0.0, 10.0}, {0.0, 10.0, -10.0}, {-10.0, -10.0, -10.0}, {10.0, -10.0, -10.0} }; int n; /* display one triangle */ void triangle( point a, point b, point c) { glBegin(GL_POLYGON); glVertex3fv(a); glVertex3fv(b); glVertex3fv(c); glEnd(); }
  • 8. /* triangle subdivision */ void divide_triangle(point a, point b, point c, int m) { point p1, p2, p3; int i; if(m>0) { for(i=0; i<3; i++) p1[i]=(a[i]+b[i])/2; for(i=0; i<3; i++) p2[i]=(a[i]+c[i])/2; for(i=0; i<3; i++) p3[i]=(b[i]+c[i])/2; divide_triangle(a, p1, p2, m-1); divide_triangle(c, p2, p3, m-1); divide_triangle(b, p3, p1, m-1); } else triangle(a,b,c); /* draw triangle at end of recursion */ }
  • 9. /* Apply triangle subdivision to faces of tetrahedron */ void tetrahedron( int m) { glColor3f(1.0,0.0,0.0); divide_triangle(v[0], v[1], v[2], m); glColor3f(0.0,1.0,0.0); divide_triangle(v[3], v[2], v[1], m); glColor3f(0.0,0.0,1.0); divide_triangle(v[0], v[3], v[1], m); glColor3f(0.0,0.0,0.0); divide_triangle(v[0], v[2], v[3], m); }
  • 10. void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // to reset the buffer and for hidden surface removal glLoadIdentity(); tetrahedron(n); glFlush(); } void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); // matrix mode – defines CTM, GL_PROJECTION to view in ortho glLoadIdentity(); // identity matrix resets the matrix to its default state if (w <= h) glOrtho(-12.0, 12.0, -12.0 * (GLfloat) h / (GLfloat) w, 12.0 * (GLfloat) h / (GLfloat) w, -12.0, 12.0); else glOrtho(-12.0 * (GLfloat) w / (GLfloat) h, 12.0 * (GLfloat) w / (GLfloat) h, -12.0, 12.0, -12.0, 12.0); glMatrixMode(GL_MODELVIEW); // transformations done in model view glutPostRedisplay(); }
  • 11. void main(int argc, char **argv) { printf(" No. of Divisions ? "); scanf("%d",&n); glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); /* This is to view the behind triangle */ glutInitWindowSize(500, 500); glutCreateWindow("3D Gasket"); glClearColor (1.0, 1.0, 1.0, 1.0); glutReshapeFunc(myReshape); glutDisplayFunc(display); glEnable(GL_DEPTH_TEST); // enable the hidden surface glutMainLoop(); }