1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

用php实现的极限方程函数的图像

本帖由 小叶2006-06-29 发布。版面名称:后端开发

  1. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
    PHP:
    <?php
    ##########################
    #一些极限方程函数的图像                #
    #PHP_Function_Draw v1.0 by echo"沙加"   #
    # 2006-05-19                           #
    # Nothing special. Just for Fun.               #
    #math_function_1()#三叶玫瑰线              #
    #math_function_2()#阿基米德螺线              #
    #math_function_3()#心形线                  #
    #math_function_4()#伯努利双曲线              #
    #math_function_5()#星形线                  #
    # Nothing special. Just for Fun.                   #
    ##########################
    math_function_1();

    function 
    math_function_1()#三叶玫瑰线
    {
        
    #设置参数
        
    $n 3#设置叶片数
        
    $m 100#控制大小
        
        
    $height 400;
        
    $width 400;
        
    $im imagecreatetruecolor($height,$width);
        
    $blue imagecolorallocate ($im,0,0,64);
        
    $white imagecolorallocate ($im,255,255,255);
        
        
    imagefill($im,0,0,$blue); #背景
        
        
    for ($a=0;$a<=360;$a=$a+0.01)  #循环一周  若累加数增大,将产生虚线效果
        
    {
            
    $p $m sin($n*$a);            #计算极坐标
            
    $x $p cos($a) + $height/2;  #转换为平面直角坐标,并平移至中心位置
            
    $y $p sin($a)+ $width/2;
            
    imageline($im,$x,$y,$x,$y,$white);
        }
        
        
    #输出图像
        
    header('content-type:image/png');
        
    imagepng($im);
        
        
    #清理
        
    inagedestory($im);
    }

    function 
    math_function_2()#阿基米德螺线
    {
        
    #设置参数
        
        
    $m 5#控制大小
        
        
    $height 400;
        
    $width 400;
        
    $im imagecreatetruecolor($height,$width);
        
    $blue imagecolorallocate ($im,0,0,64);
        
    $white imagecolorallocate ($im,255,255,255);
        
        
    imagefill($im,0,0,$blue); #背景
        
        
    for ($a=0;$a<=360;$a=$a+0.01)  #循环一周  若累加数增大,将产生虚线效果
        
    {
            
    $p $m $a;            #计算极坐标
            
    $x $p cos($a) + $height/2;  #转换为平面直角坐标,并平移至中心位置
            
    $y $p sin($a)+ $width/2;
            
    imageline($im,$x,$y,$x,$y,$white);
        }
        
        
    #输出图像
        
    header('content-type:image/png');
        
    imagepng($im);
        
        
    #清理
        
    inagedestory($im);
    }

    function 
    math_function_3()#心形线
    {
        
    #设置参数
        
        
    $m 50#控制大小
        
        
    $height 400;
        
    $width 400;
        
    $im imagecreatetruecolor($height,$width);
        
    $blue imagecolorallocate ($im,0,0,64);
        
    $white imagecolorallocate ($im,255,255,255);
        
        
    imagefill($im,0,0,$blue); #背景
        
        
    for ($a=0;$a<=360;$a=$a+0.01)  #循环一周  若累加数增大,将产生虚线效果
        
    {
            
    $p $m * (1-cos($a));            #计算极坐标
            
    $x $p cos($a) + $height/2;  #转换为平面直角坐标,并平移至中心位置
            
    $y $p sin($a)+ $width/2;
            
    imageline($im,$x,$y,$x,$y,$white);
        }
        
        
    #输出图像
        
    header('content-type:image/png');
        
    imagepng($im);
        
        
    #清理
        
    inagedestory($im);
    }
    function 
    math_function_4()#伯努利双曲线
    {
        
    #设置参数
        
        
    $m 10#控制大小
        
        
    $height 400;
        
    $width 400;
        
    $im imagecreatetruecolor($height,$width);
        
    $blue imagecolorallocate ($im,0,0,64);
        
    $white imagecolorallocate ($im,255,255,255);
        
        
    imagefill($im,0,0,$blue); #背景
        
        
    for ($a=0;$a<=360;$a=$a+0.01)  #循环一周  若累加数增大,将产生虚线效果
        
    {
            
    $p sqrt ($a*$a sin(2*$a) );            #计算极坐标
            
    $x $p cos($a) + $height/2;  #转换为平面直角坐标,并平移至中心位置
            
    $y $p sin($a)+ $width/2;
            
    imageline($im,$x,$y,$x,$y,$white);
        }
        
        
    #输出图像
        
    header('content-type:image/png');
        
    imagepng($im);
        
        
    #清理
        
    inagedestory($im);
    }

    function 
    math_function_5()#星形线
    {
        
    #设置参数
        
        
    $m 100#控制大小
        
        
    $height 400;
        
    $width 400;
        
    $im imagecreatetruecolor($height,$width);
        
    $blue imagecolorallocate ($im,0,0,64);
        
    $white imagecolorallocate ($im,255,255,255);
        
        
    imagefill($im,0,0,$blue); #背景
        
        
    for ($a=0;$a<=360;$a=$a+0.01)  #循环一周  若累加数增大,将产生虚线效果
        
    {
            
    //$p = $m / $a;            #计算极坐标
            
    $x $m cos($a)*cos($a)*cos($a) + $height/2;  #转换为平面直角坐标,并平移至中心位置
            
    $y $m sin($a)*sin($a)*sin($a)+ $width/2;
            
    imageline($im,$x,$y,$x,$y,$white);
        }
            
        
    #输出图像
        
    header('content-type:image/png');
        
    imagepng($im);
        
        
    #清理
        
    inagedestory($im);
    }

    ?>
     
  2. 狂狂

    狂狂 New Member

    注册:
    2006-06-07
    帖子:
    57
    赞:
    1
    路过,友情顶贴一下.
     
  3. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
    :ghost: :ghost:
     

    附件文件:

    • 1.png
      1.png
      文件大小:
      2.6 KB
      浏览:
      20
    • 2.png
      2.png
      文件大小:
      8.1 KB
      浏览:
      15
    • 4.png
      4.png
      文件大小:
      15.9 KB
      浏览:
      17
  4. wm_chief

    wm_chief New Member

    注册:
    2005-09-05
    帖子:
    17,890
    赞:
    46
  5. 89291569

    89291569 New Member

    注册:
    2006-06-29
    帖子:
    18
    赞:
    0
    哗`~``PHP还能这样啊?厉害~``长见识了
     
  6. knmduiemd

    knmduiemd New Member

    注册:
    2006-06-17
    帖子:
    55
    赞:
    0
    :ft::lol::ft: :ft:
     
  7. comic

    comic New Member

    注册:
    2006-03-05
    帖子:
    302
    赞:
    2
    OH MY GOOD.
     
  8. 李鸿章

    李鸿章 New Member

    注册:
    2006-05-20
    帖子:
    14
    赞:
    0
    超级喜欢 收藏了 呵呵 学数学得就喜欢这个啊~~