Re: Draw function diagram

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi
I worked alittle with gd
It is my code for y(x)=sin(x)+cos(x):

   function Graph($rangeLow, $rangeHigh, $step)
   {
       $img = ImageCreate($this->width, $this->height);
       $background_color = imagecolorallocate($img, 0, 0, 0);
       $white = ImageColorAllocate($img, 255, 255, 255);
       imageline($img, $this->width/2, 0,$this->width/2 , $this->height,
$white);
       imageline($img, 0, $this->height/2, $this->width, $this->height/2,
$white);
       for ($x=rangeLow;$x<=$rangeHigh,$x+=$step)
       {
            y=sin(x)*cos(x);//custom function
            //i dont know what should write here but i know that I should
write imageline() function
        }
       header("Content-type: image/jpeg");
       ImageJpeg($img);
       imagedestroy($img);
   }


could anyone write a simple code that complete this code
I want to learn it
I dont want to use any software package
Thanks


On 6/6/07, Richard Lynch <ceo@xxxxxxxxx> wrote:

On Tue, June 5, 2007 4:36 pm, Khorosh Irani wrote:
> Hello
> I have a function like (y(x)=sin(x)) that i convert it to post fix and
> then
> execute it.means that i coud get y for each x value
> now I have a simple question
> I want to draw diagram of function.
> how I should do this
> I dont work with gd and also i donot now how I should done this.but i
> think
> that i should get a range for x and get y for each x but i dont know
> how I
> shold draw diagram after this

Start working with GD would be my first answer...

If you can't use GD, then I would guess that somewhere "out there"
there may exist a software package that you can pass "sin(x)" to it,
and it will create a graph for you...  No idea what it's called,
though...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux