Courbes de Lissajous : code source


  Recherche :

Coordonnées complètes  
AJORNET
78190 Trappes
tél/fax : 01.30.66.64.32
port : 06.73.48.61.37
contact@ajornet.com

<?php
/*
 * Site : http://www.ajornet.com/
 * But  : Tracé de courbes de Lissajous
 *
 * Copyright (c) 2001 Ajornet http://www.ajornet.com/
 * Auteur : Daniel Lucazeau mailto:daniel.lucazeau@ajornet.com
 *
 * $Id: courbeLissajous.php,v 1.0 2001-10-22 23:32:23+02 lucazeau_daniel Exp lucazeau_daniel $
 *
 */

function drawGraph$nbPoints$color$a$b) {
    global 
$hImg$diagramWidth$diagramHeight;

    
$plotScale = ($diagramHeight) / 2;
    
$plotCenter = ($diagramHeight) / 2;
    for( 
$i 0$i <= $nbPoints$i++) {
        
$theta $i pi() / $nbPoints;
        
$x sin$a $theta);
        
$y sin$b $theta);

        
$x $x * (float)$plotScale + (float)$plotCenter;
        
$y = (float)$plotCenter $y * (float)$plotScale;

        if( 
$i 0)
            
imageLine$hImg$oldX$oldY$x$y$color);

        
$oldX $x;
        
$oldY $y;
    }
}

// Paramètres du graphique
$diagramWidth 300;
$diagramHeight 300;
if( !isSet( 
$nbX)) $nbX =4;
if( !isSet( 
$nbY)) $nbY =7;

// creation de l'image
$hImg imageCreate($diagramWidth$diagramHeight);

//$colorBackgr       = imageColorAllocate( $hImg, 192, 223, 224);
$colorBackgr       imageColorAllocate$hImg255255255);
$colorCourbe     imageColorAllocate$hImg88126127);

imageFilledRectangle$hImg00$diagramWidth 1$diagramHeight 1$colorBackgr);

drawGraph1000$colorCourbe$nbX$nbY);
imageInterlace$hImg1);

header("Content-type: image/png");
imagePng$hImg);
?>

mise à jour du 05.02.2008
Site hébergé sur un serveur dédié de I-P-T