/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        C O U R B E   D E   H I L B E R T   B I D I M E N S I O N N E L L E :                                                      */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        Author of '$xtc/CHilbert_2D.11$c' :                                                                                        */
/*                                                                                                                                   */
/*                    Jean-Francois Colonna (LACTAMME, 20120415171624).                                                              */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

#include  "INCLUDES.01.I"

double    cos();
double    sin();
double    sqrt();

double    x,y;
double    rho,theta;
int       coordonnee_curviligne=0;

int       PRINT_regles=0;
int       PRINT_coordonnees=1;

#define   PRINT(chaine)                                                                                                                 \
                    {                                                                                                                   \
                    if        (PRINT_regles)                                                                                            \
                              {                                                                                                         \
                              printf("%s",chaine);                                                                                      \
                              }                                                                                                         \
                    else                                                                                                                \
                              {                                                                                                         \
                              }                                                                                                         \
                    }

#define   PLUS                                                                                                                          \
                    {                                                                                                                   \
                    PRINT("+");                                                                                                         \
                    theta = theta+PI_SUR_2;                                                                                             \
                    }
#define   MOINS                                                                                                                         \
                    {                                                                                                                   \
                    PRINT("-");                                                                                                         \
                    theta = theta-PI_SUR_2;                                                                                             \
                    }
#define   FORWARD                                                                                                                       \
                    {                                                                                                                   \
                    PRINT("F");                                                                                                         \
                                                                                                                                        \
                    if        (PRINT_coordonnees)                                                                                       \
                              {                                                                                                         \
                              printf("x=%f y=%f\n",x,y);                                                                                \
                              }                                                                                                         \
                                                                                                                                        \
                    else                                                                                                                \
                              {                                                                                                         \
                              }                                                                                                         \
                    x = x + (rho*cos(theta));                                                                                           \
                    y = y + (rho*sin(theta));                                                                                           \
                    coordonnee_curviligne++;                                                                                            \
                                                                                                                                        \
                    if        (PRINT_coordonnees)                                                                                       \
                              {                                                                                                         \
                              printf("x=%f y=%f\n",x,y);                                                                                \
                              }                                                                                                         \
                    else                                                                                                                \
                              {                                                                                                         \
                              }                                                                                                         \
                    }
#define   RIGHT                                                                                                                         \
                    {                                                                                                                   \
                    PRINT("R");                                                                                                         \
                    genere_R(n-1);                                                                                                      \
                    }
#define   LEFT                                                                                                                          \
                    {                                                                                                                   \
                    PRINT("L");                                                                                                         \
                    genere_L(n-1);                                                                                                      \
                    }

int       genere_L(n)
int       n;
          {
          if        (n > 0)
                    {
                    PLUS;
                    RIGHT;
                    FORWARD;
                    MOINS;
                    LEFT;
                    FORWARD;
                    LEFT;
                    MOINS;
                    FORWARD;
                    RIGHT;
                    PLUS;
                    }
          else
                    {
                    }

          return(0);
          }

int       genere_R(n)
int       n;
          {
          if        (n > 0)
                    {
                    MOINS;
                    LEFT;
                    FORWARD;
                    PLUS;
                    RIGHT;
                    FORWARD;
                    RIGHT;
                    PLUS;
                    FORWARD;
                    LEFT;
                    MOINS;
                    }
          else
                    {
                    }

          return(0);
          }

main()
          {
          int       n=5;

          rho=(1.0/2.0)/pow(2.0,(double)(n-2));

          x=rho/2.0;
          y=rho/2.0;

          theta=0;

          LEFT;

          PRINT("\n");
          }



Copyright © Jean-François Colonna, 2021-2023.
Copyright © CMAP (Centre de Mathématiques APpliquées) UMR CNRS 7641 / École polytechnique, Institut Polytechnique de Paris, 2021-2023.