SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
Prog_2 course- 2014 
2 bytes team 
Kinan keshkeh 
IT Engineering-Damascus University 
3rd year
GRAPH
Introduction 
In all programs we were using TXTmode (all outputs 
were in Text). 
In PASCAL there is a Graph Unit, which allow us 
to change into Graphicmode and draw diagrams.
Change into Graph mode 
Uses Graph; 
procedure my_initgraph; 
var gd, gm, error,detect:integer; begin gd:=detect; initgraph(gd,gm,'c:evgrga.bgi'); error:=graphresult; if error<>grok then begin writeln('graphic error',GraphErrorMsg(error)); halt(1); 
end; 
end;
1- Uses Graph : to include Graph library. 
2- gd:=detect : detect ,to determine the kind of 
display card . 
3- initgraph(gd,gm,'c:evgrga.bgi') 
that in (2) 
display system : ex: gm=VGAHI , so the screen will be 2640*480*16 (16 number of colors ). 
4- error:=graphresult : to insure if initgraph success in 
changing to Graph mode, it return a value if success or error. 
5-GraphErrorMsg(error) : display an error message , if an error happens when changing into graphic mode. 
6-Halt: to exit the procedure.
Note: 
If we have this folder to save code file in it : C:MyFolderpro.pas 
Go to (Turbo Pascal) folder , open ‘BGI’ folder 
1)Copy this file EGAVGA.BGI and paste it in ‘C:MyFolder’ 2)Copy this fileGRAPH.TPU’ unit from ‘Units’ folder (in Turbo 
Pascal folder).and paste it in the path ‘C:MyFolder’ too. 
3)From pascal program , choose File -> Change dir -> 
C:MyFolder . 
* That to initialize Graph environment in pascal !
How to paint a Normal function: 
1) The function : Y= f(x) ex: (y=2x) . 
2) X domain: ex: x in [ x0=-100, xn=100] . 
4) Painting step dx : dx=(xn-x0)/n . 
3) N number of points. 
5) The Algorithm : 
x1=x0; y1=F(x0); 
For(i:=1) to (N) do 
begin 
x2 = x0+i*dx; 
y2 = F(x2); 
line(x1,y1,x2,y2); 
x1:=x2; y1:=y2 
end;
Example : 
paint ( Y=f(x) = x ) : 
1- (f(x) = x ) 2- let x in [0,50] 3- n=100 
4-dx=(50-0)/100 = 0.5 ; 
5- Algorithm: 
x1=x0; y1=x0; 
For(i:=1) to (n) do 
begin 
x2 = x0+i*dx; 
y2 = x2; 
line(x1,y1,x2,y2); 
x1:=x2; y1:=y2 
end; 
x1 
y1 
x2 
y2 
x2 
y2
How to paint a Polar function: 
1) The function :R= F(u) ex: (y=cos(x) ) . 
2) U domain: ex: U in [ u0=-100, un=100] . 
4) Painting step du : du=(Un-U0)/n . 
3) N number of points. 
5) The Algorithm : 
x1=F(u0)*cos(u0); y1=F(u0)*sin(u0); 
For(i:=1) to (N) do 
begin 
U= u0+ i*du; 
x2=F(u)*cos(u); 
y2=F(u)*sin(u); 
line(x1,y1,x2,y2); 
x1:=x2; y1:=y2 
end; 
x 
y 
U
the Coordinates 
(wXb,wYb) 
paper 
bottom 
(wXt,wYt) 
top 
(vXb,vYb) 
screen 
bottom 
(vXt,vYt) 
top
Coordinates appropriate 
- If you have On paper x in [0..460] 
..it would be On Screen x in [0..230] 
- So each two points on screen , one point on paper . 
(6,0) paper -> (3,0) screen 
- So the Ratio: 
Sx = | vXb – vXt | / | wXt – wXb | 
Sy = | vYb – vYt | / | wYt – wYb | 
0 
460 
230 
0 
vXt 
vXb 
wXb 
wXt 
3 
6 
1)Increasing and decreasing coordinates:
EX: 
If the paper Coordinates are 640*320 , and the screen Coordinates are 1280*640 . 
What are the coordinates on screen of the point (4,6) on paper ? 
answer : 
Sx=(1280-0) / (640-0) = 2 
Sy=(640-0) / (320-0) = 2 
the point on paper(4,6) -> (8,12) on screen
Xv= (x-wXb)*Sx + vXt 
2)Displacement coordinates: 
0 
200 
vXt 
vXb 
-50 
50 
wXb 
wXt 
Ex: the point (50,0) -> Xv=(50+50)*2 + 0 = 200 (x on screen). 
paper 
Screen
Yv= (y-wYb)*Sy + (GetMaxY – vYb) 
0 
0 
paper 
wYb 
100 
100 
vYt 
wYt 
vYb 
Screen 
GetMaxY = 100 
Ex: the point (0,100) -> Yv=(100-0)*1 +(100-100) = 100 (x on screen).
Some important functions and procedures : 
Line(x1,y1,x2,y2) : draw a line between the two points. 
Circle(x,y,radius) : draw a circle . 
Rectangle(x1,y1,x2,y2): draw a rectangle between the two points . 
Setcolor(color): change the color where the color is a number from [0..15] and each number is a color. 
Setviewport(x1,y1,x2,y2,clipOn/clipOff): determine a specific display window 
clipOn: inside it we can see, clipOff: outside it we can see. 
TXTout(“Hello world”) or TXToutXY(50,20,“Hello world”) : print a text on screen with Graphicmode (at specific coordinate), 
whereas at TXTmode we use writeln,write .
Lets make it real :D !! 
What u do in Exams
Normal functions: F(x)=1+x2 
س:ارسم الخط البياني للتابع: 
2+x1 
F(x)= 
حيث x ضمن المجال ]100,+100-[ 
2000 
N= 
Program draw; 
const n=2000; x0=-100; xm=100; dx=0.1 ; { (xm-x0)/n= [100-(-100)]/2000=0.1} uses graph; var x1,x2,y1,y2:real; nx1,nx2,ny1,ny2:real; maxx , maxy , i : integer; alpha , beta :real;
procedure my_initgraph; {initialize screen for drawing} var gd,gm,error,detect :integer; begin gd:=detect; initgraph(gd,gm,'c:evgrga.bgi'); error:=graphresult; if error<>grok then begin writeln('graphic error',GraphErrorMsg(error) ); halt(1); end; 
function f(x:real):real begin f:=x*x+1; end;
Begin my_initgraph; x1:=x0; y1:=f(x0); maxx:=getmaxx; maxy:=getmaxy; alpha:=maxx/(xm-x0); beta:=maxy/abs( f(xm) - f(x0) );; line(0,maxy div 2,maxx,maxy div 2); line(maxx div 2,0,maxx div 2,maxy); for i:=1 to n do begin x2:=x0+i*dx; y2:=f(x2); nx1:=round(x1*alpha)+maxx div 2; nx2:=round(x2*alpha)+maxx div 2; ny1:= -round(y1*beta)+maxy div 2; ny2:= -round(y2*beta)+maxy div 2; line(nx1,ny1,nx2,ny2); x1:=x2; y1:=y2; end; close graph; End; 
appropriate the coordinate 
Displacement 
Draw the axis
Polar functions: F(u)=1+sin(u) 
س:ارسم منحني التابع 
+sin(u)1 
F(u)= 
0.02du=, 0 =0 
U 
Program draw; 
const n=2500; u0=0; du=0.02; 
uses graph; var x1,x2,y1,y2:real; nx1,nx2,ny1,ny2:real; maxx , maxy,i :integer; alpha ,beta :real;
procedure my_initgraph; {initialize screen for drawing} var gd,gm,error,detect :integer; begin gd:=detect; initgraph(gd,gm,'c:evgrga.bgi'); error:=graphresult; if error<>grok then begin writeln('graphic error',GraphErrorMsg(error) ); halt(1); end; 
function f(u:real):real begin f:=1+sin(u); end;
Begin my_initgraph; x1:=f(u0)*cos(u0); y1:=f(u0)*sin(u0); maxx:=getmaxx; maxy:=getmaxy; alpha:=maxx/ ( n*du) beta:= maxy/abs( f(u0+n*du) - f(u0) ); line(0,maxy div 2,maxx,maxy div 2); line(maxx div 2,0,maxx div 2,maxy); for i:=1 to n do begin u:=u0+i*du; x2:=f(u)*cos(u); y2:=f(u)*sin(u); nx1:=round(x1*alpha)+maxx div 2; nx2:=round(x2*alpha)+maxx div 2; ny1:= -round(y1*beta)+maxy div 2; ny2:= -round(y2*beta)+maxy div 2; line(nx1,ny1,nx2,ny2); x1:=x2; y1:=y2; end; close graph; End; 
Draw the axis
The End of the course !!
Group : group link 
Mobile phone- Kinan : 0994385748 
Facebook account : kinan’s account 
2 bytes team

Contenu connexe

Tendances

Tabela completa de derivadas e integrais
Tabela completa de derivadas e integraisTabela completa de derivadas e integrais
Tabela completa de derivadas e integraisDiego Rodrigues Vaz
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversionMohd Arif
 
10CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 410CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 4Vanishree Arun
 
Tablas integrales
Tablas integralesTablas integrales
Tablas integralesPaulo0415
 
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericosKristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericosKristhyanAndreeKurtL
 
Computer Aided Manufacturing Design
Computer Aided Manufacturing DesignComputer Aided Manufacturing Design
Computer Aided Manufacturing DesignV Tripathi
 
Clase funcion cuadratica
Clase funcion cuadraticaClase funcion cuadratica
Clase funcion cuadraticasainpereztorres
 
Distributed Machine Learning with Apache Mahout
Distributed Machine Learning with Apache MahoutDistributed Machine Learning with Apache Mahout
Distributed Machine Learning with Apache MahoutSuneel Marthi
 
Lab lecture 1 line_algo
Lab lecture 1 line_algoLab lecture 1 line_algo
Lab lecture 1 line_algosimpleok
 
Tugas matematika menemukan konsep persamaan kuadrat
Tugas matematika menemukan konsep persamaan kuadratTugas matematika menemukan konsep persamaan kuadrat
Tugas matematika menemukan konsep persamaan kuadrattrisnasariasih
 

Tendances (17)

Tabela completa de derivadas e integrais
Tabela completa de derivadas e integraisTabela completa de derivadas e integrais
Tabela completa de derivadas e integrais
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversion
 
10CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 410CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 4
 
Integrales
IntegralesIntegrales
Integrales
 
Tablas integrales
Tablas integralesTablas integrales
Tablas integrales
 
Funcion cuadratica
Funcion cuadraticaFuncion cuadratica
Funcion cuadratica
 
OOXX
OOXXOOXX
OOXX
 
PythonArtCode
PythonArtCodePythonArtCode
PythonArtCode
 
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericosKristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
 
Computer Aided Manufacturing Design
Computer Aided Manufacturing DesignComputer Aided Manufacturing Design
Computer Aided Manufacturing Design
 
Clase funcion cuadratica
Clase funcion cuadraticaClase funcion cuadratica
Clase funcion cuadratica
 
Ch16 11
Ch16 11Ch16 11
Ch16 11
 
Distributed Machine Learning with Apache Mahout
Distributed Machine Learning with Apache MahoutDistributed Machine Learning with Apache Mahout
Distributed Machine Learning with Apache Mahout
 
Tabla integrales
Tabla integralesTabla integrales
Tabla integrales
 
Exam1 101
Exam1 101Exam1 101
Exam1 101
 
Lab lecture 1 line_algo
Lab lecture 1 line_algoLab lecture 1 line_algo
Lab lecture 1 line_algo
 
Tugas matematika menemukan konsep persamaan kuadrat
Tugas matematika menemukan konsep persamaan kuadratTugas matematika menemukan konsep persamaan kuadrat
Tugas matematika menemukan konsep persamaan kuadrat
 

En vedette

2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templateskinan keshkeh
 
10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)kinan keshkeh
 
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays 2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays kinan keshkeh
 
أخلاقيات العالم الافتراضي نهائي
أخلاقيات العالم الافتراضي نهائيأخلاقيات العالم الافتراضي نهائي
أخلاقيات العالم الافتراضي نهائيAlaa Bar Avi
 
Ise rt c2_s14_nour_40714
Ise rt c2_s14_nour_40714Ise rt c2_s14_nour_40714
Ise rt c2_s14_nour_40714Alaa Bar Avi
 
النشرالإلكتروني
النشرالإلكترونيالنشرالإلكتروني
النشرالإلكترونيAlaa Bar Avi
 
تصميم مواقع الشرق الأوسط
تصميم مواقع الشرق الأوسطتصميم مواقع الشرق الأوسط
تصميم مواقع الشرق الأوسطAlaa Bar Avi
 
مبادئ التحرير الإعلامي
مبادئ التحرير الإعلاميمبادئ التحرير الإعلامي
مبادئ التحرير الإعلاميAlaa Bar Avi
 
التحرير الإخباري
التحرير الإخباريالتحرير الإخباري
التحرير الإخباريAlaa Bar Avi
 

En vedette (9)

2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates
 
10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)
 
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays 2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
 
أخلاقيات العالم الافتراضي نهائي
أخلاقيات العالم الافتراضي نهائيأخلاقيات العالم الافتراضي نهائي
أخلاقيات العالم الافتراضي نهائي
 
Ise rt c2_s14_nour_40714
Ise rt c2_s14_nour_40714Ise rt c2_s14_nour_40714
Ise rt c2_s14_nour_40714
 
النشرالإلكتروني
النشرالإلكترونيالنشرالإلكتروني
النشرالإلكتروني
 
تصميم مواقع الشرق الأوسط
تصميم مواقع الشرق الأوسطتصميم مواقع الشرق الأوسط
تصميم مواقع الشرق الأوسط
 
مبادئ التحرير الإعلامي
مبادئ التحرير الإعلاميمبادئ التحرير الإعلامي
مبادئ التحرير الإعلامي
 
التحرير الإخباري
التحرير الإخباريالتحرير الإخباري
التحرير الإخباري
 

Similaire à 2Bytesprog2 course_2014_c9_graph

Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignmentAbdullah Al Shiam
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programsAmit Kapoor
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignmentashikul akash
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4Roziq Bahtiar
 
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfimport java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfanyacarpets
 
Natural and Clamped Cubic Splines
Natural and Clamped Cubic SplinesNatural and Clamped Cubic Splines
Natural and Clamped Cubic SplinesMark Brandao
 
COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALVivek Kumar Sinha
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cppAlamgir Hossain
 
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdfimplement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdfforladies
 
PMHMathematicaSample
PMHMathematicaSamplePMHMathematicaSample
PMHMathematicaSamplePeter Hammel
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineersvarun arora
 
Introduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdfIntroduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdffathimafancyjeweller
 
4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptxssuser255bf1
 

Similaire à 2Bytesprog2 course_2014_c9_graph (20)

Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
Cs580
Cs580Cs580
Cs580
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programs
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
 
Graphics point clipping c program
Graphics point clipping c programGraphics point clipping c program
Graphics point clipping c program
 
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfimport java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
 
No3
No3No3
No3
 
Natural and Clamped Cubic Splines
Natural and Clamped Cubic SplinesNatural and Clamped Cubic Splines
Natural and Clamped Cubic Splines
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUAL
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
 
Line circle draw
Line circle drawLine circle draw
Line circle draw
 
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdfimplement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
PMHMathematicaSample
PMHMathematicaSamplePMHMathematicaSample
PMHMathematicaSample
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineers
 
Introduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdfIntroduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdf
 
4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx
 

Plus de kinan keshkeh

Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods kinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptkinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptkinan keshkeh
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm kinan keshkeh
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...kinan keshkeh
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_unitskinan keshkeh
 
2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_listskinan keshkeh
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked listkinan keshkeh
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointerskinan keshkeh
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfileskinan keshkeh
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfileskinan keshkeh
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_recordskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphismkinan keshkeh
 
2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritancekinan keshkeh
 
2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces 2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces kinan keshkeh
 
2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings 2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings kinan keshkeh
 

Plus de kinan keshkeh (20)

Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units
 
2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism
 
2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance
 
2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces 2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces
 
2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings 2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings
 

Dernier

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 

Dernier (20)

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

2Bytesprog2 course_2014_c9_graph

  • 1. Prog_2 course- 2014 2 bytes team Kinan keshkeh IT Engineering-Damascus University 3rd year
  • 3. Introduction In all programs we were using TXTmode (all outputs were in Text). In PASCAL there is a Graph Unit, which allow us to change into Graphicmode and draw diagrams.
  • 4. Change into Graph mode Uses Graph; procedure my_initgraph; var gd, gm, error,detect:integer; begin gd:=detect; initgraph(gd,gm,'c:evgrga.bgi'); error:=graphresult; if error<>grok then begin writeln('graphic error',GraphErrorMsg(error)); halt(1); end; end;
  • 5. 1- Uses Graph : to include Graph library. 2- gd:=detect : detect ,to determine the kind of display card . 3- initgraph(gd,gm,'c:evgrga.bgi') that in (2) display system : ex: gm=VGAHI , so the screen will be 2640*480*16 (16 number of colors ). 4- error:=graphresult : to insure if initgraph success in changing to Graph mode, it return a value if success or error. 5-GraphErrorMsg(error) : display an error message , if an error happens when changing into graphic mode. 6-Halt: to exit the procedure.
  • 6.
  • 7. Note: If we have this folder to save code file in it : C:MyFolderpro.pas Go to (Turbo Pascal) folder , open ‘BGI’ folder 1)Copy this file EGAVGA.BGI and paste it in ‘C:MyFolder’ 2)Copy this fileGRAPH.TPU’ unit from ‘Units’ folder (in Turbo Pascal folder).and paste it in the path ‘C:MyFolder’ too. 3)From pascal program , choose File -> Change dir -> C:MyFolder . * That to initialize Graph environment in pascal !
  • 8. How to paint a Normal function: 1) The function : Y= f(x) ex: (y=2x) . 2) X domain: ex: x in [ x0=-100, xn=100] . 4) Painting step dx : dx=(xn-x0)/n . 3) N number of points. 5) The Algorithm : x1=x0; y1=F(x0); For(i:=1) to (N) do begin x2 = x0+i*dx; y2 = F(x2); line(x1,y1,x2,y2); x1:=x2; y1:=y2 end;
  • 9. Example : paint ( Y=f(x) = x ) : 1- (f(x) = x ) 2- let x in [0,50] 3- n=100 4-dx=(50-0)/100 = 0.5 ; 5- Algorithm: x1=x0; y1=x0; For(i:=1) to (n) do begin x2 = x0+i*dx; y2 = x2; line(x1,y1,x2,y2); x1:=x2; y1:=y2 end; x1 y1 x2 y2 x2 y2
  • 10. How to paint a Polar function: 1) The function :R= F(u) ex: (y=cos(x) ) . 2) U domain: ex: U in [ u0=-100, un=100] . 4) Painting step du : du=(Un-U0)/n . 3) N number of points. 5) The Algorithm : x1=F(u0)*cos(u0); y1=F(u0)*sin(u0); For(i:=1) to (N) do begin U= u0+ i*du; x2=F(u)*cos(u); y2=F(u)*sin(u); line(x1,y1,x2,y2); x1:=x2; y1:=y2 end; x y U
  • 11. the Coordinates (wXb,wYb) paper bottom (wXt,wYt) top (vXb,vYb) screen bottom (vXt,vYt) top
  • 12. Coordinates appropriate - If you have On paper x in [0..460] ..it would be On Screen x in [0..230] - So each two points on screen , one point on paper . (6,0) paper -> (3,0) screen - So the Ratio: Sx = | vXb – vXt | / | wXt – wXb | Sy = | vYb – vYt | / | wYt – wYb | 0 460 230 0 vXt vXb wXb wXt 3 6 1)Increasing and decreasing coordinates:
  • 13. EX: If the paper Coordinates are 640*320 , and the screen Coordinates are 1280*640 . What are the coordinates on screen of the point (4,6) on paper ? answer : Sx=(1280-0) / (640-0) = 2 Sy=(640-0) / (320-0) = 2 the point on paper(4,6) -> (8,12) on screen
  • 14. Xv= (x-wXb)*Sx + vXt 2)Displacement coordinates: 0 200 vXt vXb -50 50 wXb wXt Ex: the point (50,0) -> Xv=(50+50)*2 + 0 = 200 (x on screen). paper Screen
  • 15. Yv= (y-wYb)*Sy + (GetMaxY – vYb) 0 0 paper wYb 100 100 vYt wYt vYb Screen GetMaxY = 100 Ex: the point (0,100) -> Yv=(100-0)*1 +(100-100) = 100 (x on screen).
  • 16. Some important functions and procedures : Line(x1,y1,x2,y2) : draw a line between the two points. Circle(x,y,radius) : draw a circle . Rectangle(x1,y1,x2,y2): draw a rectangle between the two points . Setcolor(color): change the color where the color is a number from [0..15] and each number is a color. Setviewport(x1,y1,x2,y2,clipOn/clipOff): determine a specific display window clipOn: inside it we can see, clipOff: outside it we can see. TXTout(“Hello world”) or TXToutXY(50,20,“Hello world”) : print a text on screen with Graphicmode (at specific coordinate), whereas at TXTmode we use writeln,write .
  • 17. Lets make it real :D !! What u do in Exams
  • 18. Normal functions: F(x)=1+x2 س:ارسم الخط البياني للتابع: 2+x1 F(x)= حيث x ضمن المجال ]100,+100-[ 2000 N= Program draw; const n=2000; x0=-100; xm=100; dx=0.1 ; { (xm-x0)/n= [100-(-100)]/2000=0.1} uses graph; var x1,x2,y1,y2:real; nx1,nx2,ny1,ny2:real; maxx , maxy , i : integer; alpha , beta :real;
  • 19. procedure my_initgraph; {initialize screen for drawing} var gd,gm,error,detect :integer; begin gd:=detect; initgraph(gd,gm,'c:evgrga.bgi'); error:=graphresult; if error<>grok then begin writeln('graphic error',GraphErrorMsg(error) ); halt(1); end; function f(x:real):real begin f:=x*x+1; end;
  • 20. Begin my_initgraph; x1:=x0; y1:=f(x0); maxx:=getmaxx; maxy:=getmaxy; alpha:=maxx/(xm-x0); beta:=maxy/abs( f(xm) - f(x0) );; line(0,maxy div 2,maxx,maxy div 2); line(maxx div 2,0,maxx div 2,maxy); for i:=1 to n do begin x2:=x0+i*dx; y2:=f(x2); nx1:=round(x1*alpha)+maxx div 2; nx2:=round(x2*alpha)+maxx div 2; ny1:= -round(y1*beta)+maxy div 2; ny2:= -round(y2*beta)+maxy div 2; line(nx1,ny1,nx2,ny2); x1:=x2; y1:=y2; end; close graph; End; appropriate the coordinate Displacement Draw the axis
  • 21. Polar functions: F(u)=1+sin(u) س:ارسم منحني التابع +sin(u)1 F(u)= 0.02du=, 0 =0 U Program draw; const n=2500; u0=0; du=0.02; uses graph; var x1,x2,y1,y2:real; nx1,nx2,ny1,ny2:real; maxx , maxy,i :integer; alpha ,beta :real;
  • 22. procedure my_initgraph; {initialize screen for drawing} var gd,gm,error,detect :integer; begin gd:=detect; initgraph(gd,gm,'c:evgrga.bgi'); error:=graphresult; if error<>grok then begin writeln('graphic error',GraphErrorMsg(error) ); halt(1); end; function f(u:real):real begin f:=1+sin(u); end;
  • 23. Begin my_initgraph; x1:=f(u0)*cos(u0); y1:=f(u0)*sin(u0); maxx:=getmaxx; maxy:=getmaxy; alpha:=maxx/ ( n*du) beta:= maxy/abs( f(u0+n*du) - f(u0) ); line(0,maxy div 2,maxx,maxy div 2); line(maxx div 2,0,maxx div 2,maxy); for i:=1 to n do begin u:=u0+i*du; x2:=f(u)*cos(u); y2:=f(u)*sin(u); nx1:=round(x1*alpha)+maxx div 2; nx2:=round(x2*alpha)+maxx div 2; ny1:= -round(y1*beta)+maxy div 2; ny2:= -round(y2*beta)+maxy div 2; line(nx1,ny1,nx2,ny2); x1:=x2; y1:=y2; end; close graph; End; Draw the axis
  • 24. The End of the course !!
  • 25. Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 2 bytes team