POV-Ray : Newsgroups : povray.general : show a line in 3D ? : Re: show a line in 3D ? Server Time
3 Aug 2024 00:27:17 EDT (-0400)
  Re: show a line in 3D ?  
From: Harold
Date: 16 Jun 2004 15:09:42
Message: <40d09af6@news.povray.org>
Another approach is to use a sphere_sweep. If it is a straight
line then you only need to define the begin and end points.

Here is a POV script to make a line chart. It uses sphere_sweep
to draw lines between points to illustrate changes in the number of
children placed in foster homes (real data). Not elegant POV script
but it works.

Harold

//=========BEGIN POV===============================
//--- POV Ray Line Chart Scene File --- 


global_settings { assumed_gamma 2.2 }
#include "colors.inc"
#include "textures.inc"
#include "shapes.inc"


// ---------- Lights, Camera, Action -----------

//  Single camera
#declare Camx=-0.1;

 camera {location <Camx, 0.6, -3> look_at <Camx,0.6,0> angle 40}

 light_source { < 10,10,-40> color rgb <1,1,1> }
 light_source { <-30,20,-40> color rgb <0.75,0.75,0.75> }
 light_source { <0.5,10,-12> color rgb <0.55,0.55,0.55> }


background {Black}

// Un-comment the following lines to check parameter values,
//   put the name of the parameter after Str(
//text {ttf  "crystal.ttf",  str(l1P1,8,4), 2, 0 translate <-1,1,-2>
texture{White_Marble}}
//text {ttf  "crystal.ttf",  str(l1P2,8,4), 2, 0 translate <-1,0,-2>
texture{White_Marble}}
//text {ttf  "crystal.ttf",  str(l1P3,8,4), 2, 0 translate <-1,-1,-2>
texture{White_Marble}}

//#declare VertScale =  0.03658 ;

// Line for Butte County out of home placements
sphere_sweep {linear_spline 16,
          <-.8, 1.0337, 0>, .01
          <-.7, 1.0155, 0>, .01
          <-.6, 1.0074, 0>, .01
          <-.5, 1.0398, 0>, .01
          <-.4, 1.0196, 0>, .01
          <-.3, 1.0115, 0>, .01
          <-.2, 1.058 , 0>, .01
          <-.1, 1.058 , 0>, .01
          < .0, 1.0721, 0>, .01
          < .1, 1.0742, 0>, .01
          < .2, 1.0984, 0>, .01
          < .3, 1.1065, 0>, .01
          < .4, 1.0863, 0>, .01
          < .5, 1.0519, 0>, .01
          < .6, 1.0438, 0>, .01
          < .7, 1.0641, 0>, .01
       texture {PinkAlabaster}
    }

// Spheres to mark monthly data points
sphere {  <-.8, 1.0337, 0>, .02 texture {PinkAlabaster}}
sphere {  <-.7, 1.0155, 0>, .02 texture {PinkAlabaster}}
sphere {  <-.6, 1.0074, 0>, .02 texture {PinkAlabaster}}
sphere {  <-.5, 1.0398, 0>, .02 texture {PinkAlabaster}}
sphere {  <-.4, 1.0196, 0>, .02 texture {PinkAlabaster}}
sphere {  <-.3, 1.0115, 0>, .02 texture {PinkAlabaster}}
sphere {  <-.2, 1.058 , 0>, .02 texture {PinkAlabaster}}
sphere {  <-.1, 1.058 , 0>, .02 texture {PinkAlabaster}}
sphere {  < .0, 1.0721, 0>, .02 texture {PinkAlabaster}}
sphere {  < .1, 1.0742, 0>, .02 texture {PinkAlabaster}}
sphere {  < .2, 1.0984, 0>, .02 texture {PinkAlabaster}}
sphere {  < .3, 1.1065, 0>, .02 texture {PinkAlabaster}}
sphere {  < .4, 1.0863, 0>, .02 texture {PinkAlabaster}}
sphere {  < .5, 1.0519, 0>, .02 texture {PinkAlabaster}}
sphere {  < .6, 1.0438, 0>, .02 texture {PinkAlabaster}}
sphere {  < .7, 1.0641, 0>, .02 texture {PinkAlabaster}}

// Line for California out-of-home placements
sphere_sweep {linear_spline 16,
          <-.8, 0.5581, 0>, .01
          <-.7, 0.5568, 0>, .01
          <-.6, 0.5586, 0>, .01
          <-.5, 0.5595, 0>, .01
          <-.4, 0.5585, 0>, .01
          <-.3, 0.5549, 0>, .01
          <-.2, 0.5537, 0>, .01
          <-.1, 0.5540, 0>, .01
          <  0, 0.5534, 0>, .01
          < .1, 0.5576, 0>, .01
          < .2, 0.5531, 0>, .01
          < .3, 0.5503, 0>, .01
          < .4, 0.5519, 0>, .01
          < .5, 0.5493, 0>, .01
          < .6, 0.5518, 0>, .01
          < .7, 0.5499, 0>, .01
       texture {Blue_Agate}
    }

 // boxes to mark monthly data points
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate <-.8, 0.5581,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate <-.7, 0.5568,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate <-.6, 0.5586,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate <-.5, 0.5595,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate <-.4, 0.5585,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate <-.3, 0.5549,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate <-.2, 0.5537,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate <-.1, 0.5540,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate <  0, 0.5534,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate < .1, 0.5576,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate < .2, 0.5531,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate < .3, 0.5503,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate < .4, 0.5519,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate < .5, 0.5493,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate < .6, 0.5518,
0> texture {Blue_Agate}}
box { <-1, -1, -1>, <1, 1, 1> scale 0.02 rotate y*45 translate < .7, 0.5499,
0> texture {Blue_Agate}}


// Vertical scale labels
 text {ttf "times.ttf","1.2", 0.5, 0 scale 0.05 texture {PinkAlabaster}
             translate <-0.9 , 1.2 , 0 >}
 text {ttf "times.ttf","1.1", 0.5, 0 scale 0.05 texture {PinkAlabaster}
             translate <-0.9 , 1.1 , 0 >}
 text {ttf "times.ttf","1.0", 0.5, 0 scale 0.05 texture {PinkAlabaster}
             translate <-0.9 , 1.0 , 0 >}
 text {ttf "times.ttf","0.9", 0.5, 0 scale 0.05 texture {PinkAlabaster}
             translate <-0.9 , 0.9 , 0 >}
 text {ttf "times.ttf","0.8", 0.5, 0 scale 0.05 texture {PinkAlabaster}
             translate <-0.9 , 0.8 , 0 >}
 text {ttf "times.ttf","0.7", 0.5, 0 scale 0.05 texture {PinkAlabaster}
             translate <-0.9 , 0.7 , 0 >}
 text {ttf "times.ttf","0.6", 0.5, 0 scale 0.05 texture {PinkAlabaster}
             translate <-0.9 , 0.6 , 0 >}
 text {ttf "times.ttf","0.5", 0.5, 0 scale 0.05 texture {PinkAlabaster}
             translate <-0.9 , 0.5 , 0 >}
 text {ttf "times.ttf","0.4", 0.5, 0 scale 0.05 texture {PinkAlabaster}
             translate <-0.9 , 0.4 , 0 >}
 text {ttf "times.ttf","0.3", 0.5, 0 scale 0.05 texture {PinkAlabaster}
             translate <-0.9 , 0.3 , 0 >}
 text {ttf "times.ttf","0.2", 0.5, 0 scale 0.05 texture {PinkAlabaster}
             translate <-0.9 , 0.2 , 0 >}
 text {ttf "times.ttf","0.1", 0.5, 0 scale 0.05 texture {PinkAlabaster}
             translate <-0.9 , 0.1 , 0 >}
 text {ttf "times.ttf","0.0", 0.5, 0 scale 0.05 texture {PinkAlabaster}
             translate <-0.9 , 0.0 , 0 >}

// Vertical scale lines
sphere_sweep {linear_spline 2, <-.81, 1.2, 0>, .002 < .71, 1.2, 0>, .002
texture {Blue_Agate}}
sphere_sweep {linear_spline 2, <-.81, 1.1, 0>, .002 < .71, 1.1, 0>, .002
texture {Blue_Agate}}
sphere_sweep {linear_spline 2, <-.81, 1.0, 0>, .002 < .71, 1.0, 0>, .002
texture {Blue_Agate}}
sphere_sweep {linear_spline 2, <-.81, 0.0, 0>, .002 < .71, 0.0, 0>, .002
texture {Blue_Agate}}
sphere_sweep {linear_spline 2, <-.81, 0.9, 0>, .002 < .71, 0.9, 0>, .002
texture {Blue_Agate}}
sphere_sweep {linear_spline 2, <-.81, 0.8, 0>, .002 < .71, 0.8, 0>, .002
texture {Blue_Agate}}
sphere_sweep {linear_spline 2, <-.81, 0.7, 0>, .002 < .71, 0.7, 0>, .002
texture {Blue_Agate}}
sphere_sweep {linear_spline 2, <-.81, 0.6, 0>, .002 < .71, 0.6, 0>, .002
texture {Blue_Agate}}
sphere_sweep {linear_spline 2, <-.81, 0.5, 0>, .002 < .71, 0.5, 0>, .002
texture {Blue_Agate}}
sphere_sweep {linear_spline 2, <-.81, 0.4, 0>, .002 < .71, 0.4, 0>, .002
texture {Blue_Agate}}
sphere_sweep {linear_spline 2, <-.81, 0.3, 0>, .002 < .71, 0.3, 0>, .002
texture {Blue_Agate}}
sphere_sweep {linear_spline 2, <-.81, 0.2, 0>, .002 < .71, 0.2, 0>, .002
texture {Blue_Agate}}
sphere_sweep {linear_spline 2, <-.81, 0.1, 0>, .002 < .71, 0.1, 0>, .002
texture {Blue_Agate}}
sphere_sweep {linear_spline 2, <-.81, 0.0, 0>, .002 < .71, 0.0, 0>, .002
texture {Blue_Agate}}

// Month labels ( x axis labels )
text {ttf "times.ttf","Jul-01", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate <-0.8-0.03 , -0.05 , 0 >}
text {ttf "times.ttf","Aug-01", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate <-0.7-0.04 , -0.05 , 0 >}
text {ttf "times.ttf","Sep-01", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate <-0.6-0.04 , -0.05 , 0 >}
text {ttf "times.ttf","Oct-01", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate <-0.5-0.04 , -0.05 , 0 >}
text {ttf "times.ttf","Nov-01", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate <-0.4-0.04 , -0.05 , 0 >}
text {ttf "times.ttf","Dec-01", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate <-0.3-0.04 , -0.05 , 0 >}
text {ttf "times.ttf","Jan-02", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate <-0.2-0.03 , -0.05 , 0 >}
text {ttf "times.ttf","Feb-02", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate <-0.1-0.04 , -0.05 , 0 >}
text {ttf "times.ttf","Mar-02", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate < 0.0-0.04 , -0.05 , 0 >}
text {ttf "times.ttf","Apr-02", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate < 0.1-0.04 , -0.05 , 0 >}
text {ttf "times.ttf","May-02", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate < 0.2-0.04 , -0.05 , 0 >}
text {ttf "times.ttf","Jun-02", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate < 0.3-0.03 , -0.05 , 0 >}
text {ttf "times.ttf","Jul-02", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate < 0.4-0.03 , -0.05 , 0 >}
text {ttf "times.ttf","Aug-02", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate < 0.5-0.04 , -0.05 , 0 >}
text {ttf "times.ttf","Sep-02", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate < 0.6-0.04 , -0.05 , 0 >}
text {ttf "times.ttf","Oct-02", 0.5, 0 scale 0.03 texture {PinkAlabaster}
             translate < 0.7-0.04 , -0.05 , 0 >}

// X axis tick marks
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate <-0.8 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate <-0.7 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate <-0.6 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate <-0.5 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate <-0.4 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate <-0.3 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate <-0.2 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate <-0.1 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate < 0.0 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate < 0.1 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate < 0.2 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate < 0.3 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate < 0.4 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate < 0.5 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate < 0.6 , 0, 0 >}
cylinder { <0, 0, 0>, <0, 0.01, 0>, 0.002 texture {Blue_Agate}
             translate < 0.7 , 0, 0 >}
//linder { <0, 0, 0>, <0.007, 0, 0>, 0.002 texture {Blue_Agate}
//           translate < 0.8 , 0.005 , 0 >}






// Declare titles and labels
#declare MainTitle = text {ttf "times.ttf", "Out of Home Placements",
     1, 0  scale 0.10 texture {pigment{color rgb <1.9,1.2,0.15>}}}
#declare SubTitle  = text {ttf "times.ttf", "Butte County and California",
     1, 0 scale 0.06 texture {pigment{color rgb <1.2,1.1,0.05>}}}
#declare footnote  = text {ttf "timesi.ttf",
      "Source: California Department of Social Services, Research and
Development Division",
     1, 0 scale 0.025 texture {PinkAlabaster}}
#declare YLabel  = text {ttf "times.ttf", "Percent of Youth Population",
     1, 0 scale 0.045 texture {PinkAlabaster}}
#declare XLabel  = text {ttf "times.ttf", "",
     2, 0 scale 0.20 texture {PinkAlabaster}}
#declare ZLabel  = text {ttf "times.ttf", "",
     2, 0 scale 0.08 texture {PinkAlabaster}}

//==== Place text in the scene ====
 object {MainTitle translate -x*max_extent(MainTitle).x/2 translate <   0,
1.35, 0.2  > rotate x*-1}
 object {SubTitle  translate -x*max_extent(SubTitle ).x/2 translate <   0,
1.27, 0.23 > rotate x*-1}
 object {footnote  translate -x*max_extent(footnote ).x/2 translate
<-0.6,-0.10, 0.0  > rotate y*0}
 object {XLabel    translate -x*max_extent(XLabel   ).x/2 translate < 2.2, 0
,  0   > rotate y*10}
 object {YLabel    translate -x*max_extent(YLabel   ).x/2  rotate <-8,0,90>
translate < -0.95, 0.6,  0   >}
 object {ZLabel    translate -x*max_extent(ZLabel   ).x/2 translate <
0,-1.47,-4.5 > rotate x*5}




"Slime" <fak### [at] emailaddress> wrote in message
news:40cfdd60@news.povray.org...
> > Yes ..... But, if you could give the exactly source code of the
function,
> i
> > just have to run, it would help me to start ;o) Thanks you
>
> Well, the cylinder that I described is:
>
> cylinder {
> <-100,-100,-100>, // starting point
> <100,100,100>, // ending point
> 0.1 // radius
>
> pigment {rgb 1} // white
> }
>
> You'll also need a light source and a camera.
>
> If this is new to you, then I strongly suggest you read the tutorials that
> come with POV-Ray. Start by clicking on the button in POV-Ray that says
> "Scene", which will bring you to the help files.
>
>  - Slime
>  [ http://www.slimeland.com/ ]
>
>


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.