duci.ro FORUM at forumco.com
duci.ro FORUM at forumco.com
Home | Profile | Register | Active Topics | Active Polls | Members | Private Messages | Search | FAQ

 All Forums
 ProgrammingPool environment
 Functii grafice WinBGI (Pascal, C )
 Grafic simplu 2D (PASCAL & C)

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Enter Anti SPAM Code: Please enter this code in the box below. If you cannot read it refresh the page. Click here for more detailed instructions.Play Sound
Click here to refresh this page
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Insert youTube videoInsert Windows Media AudioInsert Windows Media VideoInsert Macromedia FlashInsert Google Video
   
Message Icon:              
             
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
duci Posted - 08/07/2005 : 10:13:27
Exemplu WinBGI - graficul functiei sin(x)/x - limbajul C

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <winbgim.h>

/* O reprezentare grafica elementara a unei functii de
o singura variabila */

double func(double x,double pi)
{
double z;
z = 50.0 * sin ( x * x ) / 1000.0 * exp( - x / 2.0 );
return (z);
}
double MAX ( double a , double b )
{
if ( a >= b ) return a ; else return b ;
}
double MIN(double a, double b)
{
if ( a <= b ) return a ; else return b ;
}

void plot ( double v[] , double may , double miy)
{
int i,j;
for ( i = 0 ; i < 640 ; i++ )
{
j = 349 - 350 / (may-miy) * ( v[i] - miy );// Intreg !!!
putpixel ( i , j , 15 );//Functia plotata cu puncte
}
}

int main()

{
double y,a,b,h,may,miy;
double v[640];//vector continand esantionarea functiei
int i,j,k;
double pi=atan(1.0)*4.0;
a = 0.0 ;//Intervalul de plotare [a,b]
b = 6.0 ;
h= ( b - a ) / 640 ;//Pasul in reprezentarea grafica
//Calculam functia pe intervalul [a,b] cu pasul h
for ( i = 0 ; i < 640 ;
v[ i ] = func( a + i * h , pi ),i++);
//********scalare
may=v[0];
miy=v[0];
for ( i = 1 ; i < 640 ; i++ )
{
may = MAX ( may , v[i] );
miy = MIN ( miy , v[i] );
}
i = DETECT ;//Grafic BGI
j = DETECT ;
initgraph (&i,&j,"d:\\tc");
cleardevice ();
plot ( v,may,miy);//Graficul propriu-zis
closegraph ;
system ( "pause" );
return 0 ;
}
1   L A T E S T    R E P L I E S    (Newest First)
duci Posted - 08/07/2005 : 10:17:41
Exemplu WinBGI- graficul functiei sin(x)/x - limbajul Pascal
Program grafic_elementar;
(* O reprezentare grafica elementara a unei functii de
o singura variabila *)

uses graph ;
const
npct = 640 ;
type
vec = array [1..npct] of real ;

var
v : vec ; {vector continand esantionarea functiei}
i,j :integer ;
x,a,b,h,may,miy :real ;

function func (var x : real ) : real ;
Begin
func := 50.0 * sin ( x ) * 1000.0 ;
End ;
{**************************************************************}

function max(a,b:real):real; { Val. maxima intre 2 nr. reale }
Begin
if a>b then max:=a else max:=b;
End ;

{**************************************************************}

function min(a,b:real):real; { Val. minima intre 2 nr. reale }
Begin
if a>b then min:=b else min:=a;
End ;

BEGIN
a := 0.0 ;{Intervalul de plotare [a,b]}
b := 6.0 ;
h := ( b - a ) / npct ;{Pasul in reprezentarea grafica}
{Calculam functia pe intervalul [a,b] cu pasul h}
for i := 1 to npct do
begin
x := a + i * h ;
v[ i ] := func( x );
end ;
{********scalare}
may := v[ 1 ];
miy := v[ 1 ];
for i := 1 to npct do
begin
may := max ( may , v[ i ] );
miy := min ( miy , v[ i ] );
end ;
{Grafic BGI }
i := DETECT ;
j := DETECT ;
initgraph ( i , j , 'd:\tp\bgi');
cleardevice ();
outtextxy ( 1 , 10 , 'Text in fereastra grafica');
{Graficul propriu-zis}
for i := 1 to 640 do
begin
j := 349 - round (350.0 /
( may - miy ) * ( v[ i ] - miy ) );{ Intreg !!!}
putpixel ( i , j , 15 ) ; {Functia plotata cu puncte}
end ;
writeln ('Gata. Apasa orice tasta in fereastra consola.');
readln ;
closegraph ;
END.

duci.ro FORUM at forumco.com © 2000-05 ForumCo.com Go To Top Of Page
Generated in 0.12 seconds. Hello from Duci !!! Snitz Forums 2000
RSS Feed 1 RSS Feed 2
Powered by ForumCo 2000-2008
TOS - AUP - URA
ForumCo Free Blogs and Galleries
Signup for a free forum or Go Banner Free