mardi 9 août 2011

POV-Ray vs PStricks

POV-Ray peut-être utilisé pour représenter les sections d'un cône avec un plan. Les images obtenues, non-vectorielles, sont très belles.
Voici trois essais (à peine ébauchés) qui doivent beaucoup aux pages de Friedrich Lohmueller . Je lui ai emprunté, pour ces exemples, les macros permettant de dessiner les axes et l'astuce pour tracer les courbes en 3D. Tous les fichiers sont dans l'archive :
1- Section elliptique : ( ellipse_1.pov )

// POV-Ray 3.6 / 3.7 Scene File "ellipse_1.pov"
// d'après Friedrich A. Lohmueller
// date: Aug-2011
// email: Friedrich.Lohmueller_at_t-online.de
// http:// www.friedrich.lohmueller.de/
//------------------------------------------------------------------------
// Choose image_size by               Wählen Sie die Bildgröße, indem
// adding to the commandline:         sie in der Kommandozeile einfügen:
//
//                      +h700 +w700
//
//------------------------------------------------------------------------
#version 3.6; // 3.7;
global_settings{assumed_gamma 1.0}
#default{ finish{ ambient 0.1 diffuse 0.9 }}
//------------------------------------------------------------------------
#include "colors.inc"
#include "textures.inc"
#include "stones.inc"
//------------------------------------------------------------------------
#declare Camera_0 = camera { perspective
                             location  < 50, 25,30>
                             look_at   < 0.00, 0.00, 0.00>
                             angle 15
                             right     x*image_width/image_height
                           }
camera{Camera_0}

//Place a light--you can have more than one!
light_source {
  <10,0,10>    //Change this if you want to put the light at a different point
  color White*2        //Multiplying by 2 doubles the brightness
}
background { color rgb <0.5, 0.5, 1> }
//------------------------------ the Axes --------------------------------
//------------------------------------------------------------------------
#macro Axis_( AxisLen, Dark_Texture,Light_Texture)
 union{
    cylinder { <0,-AxisLen-3,0>,<0,AxisLen,0>,0.05
               texture{checker texture{Dark_Texture }
                               texture{Light_Texture}
                       translate<0.1,0,0.1>}
             }
    cone{<0,AxisLen,0>,0.2,<0,AxisLen+0.7,0>,0
          texture{Dark_Texture}
         }
     } // end of union                  
#end // of macro "Axis()"
//------------------------------------------------------------------------
#macro AxisXYZ( AxisLenX, AxisLenY, AxisLenZ, Tex_Dark, Tex_Light)
//--------------------- drawing of 3 Axes --------------------------------
union{
#if (AxisLenX != 0)
 object { Axis_(AxisLenX, Tex_Dark, Tex_Light)   rotate< 0,0,-90>}// x-Axis
 text   { ttf "arial.ttf",  "x",  0.15,  0  texture{Tex_Dark}
          scale 0.5 translate }
#end // of #if
#if (AxisLenY != 0)
 object { Axis_(AxisLenY, Tex_Dark, Tex_Light)   rotate< 0,0,  0>}// y-Axis
 text   { ttf "arial.ttf",  "y",  0.15,  0  texture{Tex_Dark}   
           scale 0.5 translate <-0.55,AxisLenY+0.20,-0.10>}
#end // of #if
#if (AxisLenZ != 0)
 object { Axis_(AxisLenZ, Tex_Dark, Tex_Light)   rotate<90,0,  0>}// z-Axis
 text   { ttf "arial.ttf",  "z",  0.15,  0  texture{Tex_Dark}
               scale 0.5 translate <-0.55,0.1,AxisLenZ+0.10>}
#end // of #if
} // end of union
#end// of macro "AxisXYZ( ... )"
//------------------------------------------------------------------------

#declare Texture_A_Dark  = texture {
                               pigment{color rgb<1,0.35,0>}
                               finish {ambient 0.15 diffuse 0.85 phong 1}
                             }
#declare Texture_A_Light = texture {
                               pigment{color rgb<1,1,1>}
                               finish {ambient 0.15 diffuse 0.85 phong 1}
                             }

object{ AxisXYZ( 6.0, 4.0, 7.0, Texture_A_Dark, Texture_A_Light)} // <<<<<<<<<<<<<<<<< adapt the axes here !!!
//-------------------------------------------------- end of coordinate axes

//--------------------------------------------------------------------------
//---------------------------   scenery objects  ---------------------------
//--------------------------------------------------------------------------

// angle de la normale au plan
// n<0, cos(Omega), sin(Omega)>
#declare Omega = pi/6;

intersection{
cone { <0, 3, 0>, 3, <0, 0, 0>, 0 texture {Yellow_Pine}}
plane {<0,cos(Omega),sin(Omega)>, 1 texture {Yellow_Pine}}
}

union{
 #declare X   = -5.5; // start X    attention: x != X  use capital letter X
 #declare EndX = 5.5; // end   X
 #while ( X < EndX )
 // Drawing of the "points"< X / f(X) >:    
 // Zeichnen der "Punkte"  ( X / f(X) ):

                       //       Color - Farbe                  //< X, f(X)         ,0>} 
                      
  sphere{ <0,0,0>,0.025 pigment{ color Red  }  translate< 1.414*cos(X),1.732-sin(X),-1+1.732*sin(X)>}

 // next step:
 #declare X = X + 0.002;  // next Nr  <<<-- increase this value if you have not enough RAM
                          //                              or if your computer is too slow!
 #end // --------------- end of loop 
} // end of union

cone { <0, -3, 0>, 3, <0, 0, 0>, 0 texture {Yellow_Pine}}
 
//------------------------------------------------------------------------------------ end

2 - Section parabolique ( parabole_1.pov)
// POV-Ray 3.6 / 3.7 Scene File "parabole_1.pov"
// d'après Friedrich A. Lohmueller
// date: Aug-2011
// email: Friedrich.Lohmueller_at_t-online.de
// http:// www.friedrich.lohmueller.de/
//------------------------------------------------------------------------
// Choose image_size by               Wählen Sie die Bildgröße, indem
// adding to the commandline:         sie in der Kommandozeile einfügen:
//
//                      +h700 +w700
//
//------------------------------------------------------------------------
#version 3.6; // 3.7;
global_settings{assumed_gamma 1.0}
#default{ finish{ ambient 0.1 diffuse 0.9 }}
//------------------------------------------------------------------------
#include "colors.inc"
#include "textures.inc"
#include "stones.inc"
//------------------------------------------------------------------------
#declare Camera_0 = camera { perspective
                             location  < 50, 25,30>
                             look_at   < 0.00, 0.00, 0.00>
                             angle 15
                             right     x*image_width/image_height
                           }
camera{Camera_0}

//Place a light--you can have more than one!
light_source {
  <10,0,10>    //Change this if you want to put the light at a different point
  color White*2        //Multiplying by 2 doubles the brightness
}
background { color rgb <0.5, 0.5, 1> }
//------------------------------ the Axes --------------------------------
//------------------------------------------------------------------------
#macro Axis_( AxisLen, Dark_Texture,Light_Texture)
 union{
    cylinder { <0,-AxisLen-3,0>,<0,AxisLen,0>,0.05
               texture{checker texture{Dark_Texture }
                               texture{Light_Texture}
                       translate<0.1,0,0.1>}
             }
    cone{<0,AxisLen,0>,0.2,<0,AxisLen+0.7,0>,0
          texture{Dark_Texture}
         }
     } // end of union                  
#end // of macro "Axis()"
//------------------------------------------------------------------------
#macro AxisXYZ( AxisLenX, AxisLenY, AxisLenZ, Tex_Dark, Tex_Light)
//--------------------- drawing of 3 Axes --------------------------------
union{
#if (AxisLenX != 0)
 object { Axis_(AxisLenX, Tex_Dark, Tex_Light)   rotate< 0,0,-90>}// x-Axis
 text   { ttf "arial.ttf",  "x",  0.15,  0  texture{Tex_Dark}
          scale 0.5 translate }
#end // of #if
#if (AxisLenY != 0)
 object { Axis_(AxisLenY, Tex_Dark, Tex_Light)   rotate< 0,0,  0>}// y-Axis
 text   { ttf "arial.ttf",  "y",  0.15,  0  texture{Tex_Dark}   
           scale 0.5 translate <-0.55,AxisLenY+0.20,-0.10>}
#end // of #if
#if (AxisLenZ != 0)
 object { Axis_(AxisLenZ, Tex_Dark, Tex_Light)   rotate<90,0,  0>}// z-Axis
 text   { ttf "arial.ttf",  "z",  0.15,  0  texture{Tex_Dark}
               scale 0.5 translate <-0.55,0.1,AxisLenZ+0.10>}
#end // of #if
} // end of union
#end// of macro "AxisXYZ( ... )"
//------------------------------------------------------------------------

#declare Texture_A_Dark  = texture {
                               pigment{color rgb<1,0.35,0>}
                               finish {ambient 0.15 diffuse 0.85 phong 1}
                             }
#declare Texture_A_Light = texture {
                               pigment{color rgb<1,1,1>}
                               finish {ambient 0.15 diffuse 0.85 phong 1}
                             }

object{ AxisXYZ( 6.0, 4.0, 7.0, Texture_A_Dark, Texture_A_Light)} // <<<<<<<<<<<<<<<<< adapt the axes here !!!
//-------------------------------------------------- end of coordinate axes



//--------------------------------------------------------------------------
//---------------------------   scenery objects  ---------------------------
//--------------------------------------------------------------------------


// angle de la normale au plan
// n<0, cos(Omega), sin(Omega)>
#declare Omega = pi/4;
#declare D = 1.3;
intersection{
cone { <0, 3, 0>, 3, <0, 0, 0>, 0 texture {Yellow_Pine}}
plane {<0,cos(Omega),sin(Omega)>, D texture {Yellow_Pine}}
}

union{
 #declare X   = -0.4; // start X    attention: x != X  use capital letter X
 #declare EndX = 3.54; // end   X
 #while ( X < EndX )
 // Drawing of the "points"< X / f(X) >:    
 // Zeichnen der "Punkte"  ( X / f(X) ):

                       //       Color - Farbe                  //< X, f(X)         ,0>} 
                      
  sphere{ <0,0,0>,0.025 pigment{ color Red  }  translate< 1.3*cos(X)/(0.707+0.707*sin(X)),1.3/(0.707+0.707*sin(X)),1.3*sin(X)/(0.707+0.707*sin(X))>}


 // next step:
 #declare X = X + 0.002;  // next Nr  <<<-- increase this value if you have not enough RAM
                          //                              or if your computer is too slow!
 #end // --------------- end of loop 
} // end of union

cone { <0, -3, 0>, 3, <0, 0, 0>, 0 texture {Yellow_Pine}}
 
//------------------------------------------------------------------------------------ end
 

3 - Section hyperbolique (hyperbole_1.pov)
// POV-Ray 3.6 / 3.7 Scene File "hyperbole_1.pov"
// d'après Friedrich A. Lohmueller
// date: Aug-2011
// email: Friedrich.Lohmueller_at_t-online.de
// http:// www.friedrich.lohmueller.de/

#version 3.6; // 3.7;
global_settings{assumed_gamma 1.0}
#default{ finish{ ambient 0.1 diffuse 0.9 }}
//------------------------------------------------------------------------
#include "colors.inc"
#include "textures.inc"
#include "stones.inc"
//------------------------------------------------------------------------
#declare Camera_0 = camera { perspective
                             location  < 50, 25,30>
                             look_at   < 0.00, 0.00, 0.00>
                             angle 15
                             right     x*image_width/image_height
                           }
camera{Camera_0}

//Place a light--you can have more than one!
light_source {
  <10,0,10>    //Change this if you want to put the light at a different point
  color White*2        //Multiplying by 2 doubles the brightness
}
background { color rgb <0.5, 0.5, 1> }
//------------------------------ the Axes --------------------------------
//------------------------------------------------------------------------
#macro Axis_( AxisLen, Dark_Texture,Light_Texture)
 union{
    cylinder { <0,-AxisLen-3,0>,<0,AxisLen,0>,0.05
               texture{checker texture{Dark_Texture }
                               texture{Light_Texture}
                       translate<0.1,0,0.1>}
             }
    cone{<0,AxisLen,0>,0.2,<0,AxisLen+0.7,0>,0
          texture{Dark_Texture}
         }
     } // end of union                  
#end // of macro "Axis()"
//------------------------------------------------------------------------
#macro AxisXYZ( AxisLenX, AxisLenY, AxisLenZ, Tex_Dark, Tex_Light)
//--------------------- drawing of 3 Axes --------------------------------
union{
#if (AxisLenX != 0)
 object { Axis_(AxisLenX, Tex_Dark, Tex_Light)   rotate< 0,0,-90>}// x-Axis
 text   { ttf "arial.ttf",  "x",  0.15,  0  texture{Tex_Dark}
          scale 0.5 translate }
#end // of #if
#if (AxisLenY != 0)
 object { Axis_(AxisLenY, Tex_Dark, Tex_Light)   rotate< 0,0,  0>}// y-Axis
 text   { ttf "arial.ttf",  "y",  0.15,  0  texture{Tex_Dark}   
           scale 0.5 translate <-0.55,AxisLenY+0.20,-0.10>}
#end // of #if
#if (AxisLenZ != 0)
 object { Axis_(AxisLenZ, Tex_Dark, Tex_Light)   rotate<90,0,  0>}// z-Axis
 text   { ttf "arial.ttf",  "z",  0.15,  0  texture{Tex_Dark}
               scale 0.5 translate <-0.55,0.1,AxisLenZ+0.10>}
#end // of #if
} // end of union
#end// of macro "AxisXYZ( ... )"
//------------------------------------------------------------------------

#declare Texture_A_Dark  = texture {
                               pigment{color rgb<1,0.35,0>}
                               finish {ambient 0.15 diffuse 0.85 phong 1}
                             }
#declare Texture_A_Light = texture {
                               pigment{color rgb<1,1,1>}
                               finish {ambient 0.15 diffuse 0.85 phong 1}
                             }

object{ AxisXYZ( 6.0, 4.0, 7.0, Texture_A_Dark, Texture_A_Light)} // <<<<<<<<<<<<<<<<< adapt the axes here !!!
//-------------------------------------------------- end of coordinate axes


//--------------------------------------------------------------------------
//---------------------------   scenery objects  ---------------------------
//--------------------------------------------------------------------------

// angle de la normale au plan
// n<0, cos(Omega), sin(Omega)>
#declare Omega = pi/2;
#declare D = 1;
#declare bicone =  union {
cone { <0, 3, 0>, 3, <0, 0, 0>, 0 texture {Yellow_Pine}} 
cone { <0, -3, 0>, 3, <0, 0, 0>, 0 texture {Yellow_Pine}}
}
intersection{
object {bicone}
plane {<0,cos(Omega),sin(Omega)>, D texture {Yellow_Pine}}
}

union{
 #declare X   = -1.7627; // start X    attention: x != X  use capital letter X
 #declare EndX = 1.76275; // end   X
 #while ( X < EndX )
 // Drawing of the "points"< X / f(X) >:    
 // Zeichnen der "Punkte"  ( X / f(X) ):
                      
  sphere{ <0,0,0>,0.025 pigment{ color Red  }  translate< sinh(X),cosh(X),1>}
  sphere{ <0,0,0>,0.025 pigment{ color Red  }  translate< sinh(X),-cosh(X),1>}

 // next step:
 #declare X = X + 0.002;  // next Nr  <<<-- increase this value if you have not enough RAM
                          //                              or if your computer is too slow!
 #end // --------------- end of loop 
} // end of union

Aucun commentaire:

Enregistrer un commentaire