POV-Ray : Newsgroups : povray.newusers : help with arc 2... : help with arc 2... Server Time
5 Jul 2024 04:25:25 EDT (-0400)
  help with arc 2...  
From: Jack
Date: 2 Aug 2010 05:10:01
Message: <web.4c568a80aee0494f7f6843480@news.povray.org>
Alain <azerty [at] qwertyorg> wrote:

> > Alain wrote:

> >>> Hi All,
> >>>
> >>> I'm new to POV-Ray and I'm trying to create a "bent cylinder" or a thick arc
> >>> that passes through 5 points. I think that a quadratic spline might do it, but
> >>> I'm not sure exactly how to go about it... The five points I would like it to go
> >>> through are the following and I would like are:
> > [snip]
> >>
> >> You can use the sphere_sweep primitive. Try the b_spline and
> >> cubic_spline. Be warned that those splines uses the first and last
> >> points as control points and that the actual ubject don't reatch those.
> >>
> > [snip]
> >
> > I just wrote something similar and found a sphere_sweep with a cubic_spline
> > works well by making the first point equal to the second, and the next-to-last
> > equal to the last.  In my case I was only connecting (for example) two corner
> > points c1 and c2 through a side point s5 in two dimensions.  The radius of the
> > "bent cylinder" is r.
> >
[snip]
>
> Up until the 2 last 3.7 betas, the sphere_sweep had some bugs causing
> all sort of artefacts.
> Also, if you have a control point coincident with an end point, it can
> missbehave. It can work some times, and have some strange effects at others.
>
>
>
> Alain


Thanks for your help!

I've got it working now to some extent based on the splinefollow example, I can
get the cylinder to start at one point (purple top), trace through the others in
order but not have it end at the point I would like (purple bottom). It seems to
go through no matter what I do...! Could it be a problem with the while? the
file is pasted below.

Thanks in advance,

Jack

#include "math.inc"
#include "transforms.inc"


camera {
location < 0.0, 0.0, 90.204815 >
right -4/3*x
angle 45.000000
look_at < 0, 0, 0 >
}


light_source {< 1,2,-2>*1000, color 1.0}
light_source {<-1,2, 1>*1000, color 0.7 shadowless}



#declare MySpline1 =
spline {
   cubic_spline

      -2, <15.646700,9.031800,1.374400>,
         -1, <15.646700,9.031800,1.374400>,

    00, <15.646700,9.031800,1.374400>,
   01, < 18.688101,13.562600,7.479900>,
   02, < 11.847900,16.089001,11.043700>,
   03, < 6.218900,10.321700,9.172700>,
   04, < 7.635600,8.793100,1.258800>,
   05, <13.243600,4.132500,4.822600>,
   06, < 15.646700,9.031800,10.928100>,

     12, <15.646700,9.031800,10.928100>,
   13, < 15.646700,9.031800,10.928100>,

}


// The yellow wire that shows the spline path.
union {
   #declare C = 0;
   #declare Cmax= 500;
   #while (C<=Cmax)
      #declare Value1 = C/Cmax*11;
      #declare Value2 = (C+1)/Cmax*11;
      #declare Point1 = -0.5*y+MySpline1(Value1);
      #declare Point2 = -0.5*y+MySpline1(Value2);
      sphere {Point1, 0.4}
      cylinder {Point1, Point2, 0.4}
      #declare C = C+1;
   #end
   pigment {color <1,1,0>}
   matrix < 0.440493, -0.865077, 0.240017,
         -0.873508, -0.474711, -0.107857,
         0.207243, -0.162147, -0.964758,
         0, 0, 0 >
translate< 0.541643, 18.311583, 3.783246 >

}




object {
#declare _WLVP_line_width = 0.02;
#declare _WLVP_dot_size   = 0.03;
#declare _WLVP_text_depth = 0.0;
#declare _WLVP_text_scale = 0.3;
#declare _WLVP_finish = finish { reflection 0.15 brilliance 6 diffuse 0.90
ambient 0.15 phong 0.5 phong_size 10 metallic specular 0.0 }
union {
//purple top
sphere {
<0,0,0>, 1.000000
translate <15.646700,9.031800,1.374400>
pigment { rgbt <0.501961,0.000000,0.501961,0.000000> }
finish { _WLVP_finish }
}
//red 5
sphere {
<0,0,0>, 0.500000
translate <13.243600,4.132500,4.822600>
pigment { rgbt <1.000000,0.000000,0.000000,0.000000> }
finish { _WLVP_finish }
}
//red 4
sphere {
<0,0,0>, 0.600000
translate <7.635600,8.793100,1.258800>
pigment { rgbt <1.000000,0.000000,0.000000,0.000000> }
finish { _WLVP_finish }
}

//red 3
sphere {
<0,0,0>, 0.700000
translate <6.218900,10.321700,9.172700>
pigment { rgbt <1.000000,0.000000,0.000000,0.000000> }
finish { _WLVP_finish }
}

//red 2
sphere {
<0,0,0>, 0.800000
translate <11.847900,16.089001,11.043700>
pigment { rgbt <1.000000,0.000000,0.000000,0.000000> }
finish { _WLVP_finish }
}
//red 1
sphere {
<0,0,0>, 0.900000
translate <18.688101,13.562600,7.479900>
pigment { rgbt <1.000000,0.000000,0.000000,0.000000> }
finish { _WLVP_finish }
}
//purple bottom
sphere {
<0,0,0>, 0.400000
translate <15.646700,9.031800,10.928100>
pigment { rgbt <0.501961,0.000000,0.501961,0.000000> }
finish { _WLVP_finish }
}
matrix < 0.440493, -0.865077, 0.240017,
         -0.873508, -0.474711, -0.107857,
         0.207243, -0.162147, -0.964758,
         0, 0, 0 >
translate< 0.541643, 18.311583, 3.783246 >

}}


Post a reply to this message

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