POV-Ray : Newsgroups : povray.general : pipe_spline and color : Re: pipe_spline and color Server Time
12 Jun 2024 04:15:47 EDT (-0400)
  Re: pipe_spline and color  
From: Alex
Date: 28 Nov 2015 17:20:01
Message: <web.565a27fbe2db23c8f6cc3ced0@news.povray.org>
Hi Alain

Thanks for the solution you sketched. In principle, I am not afraid of extensive
trigonometry. However, this will mean that I am doing something that is very
simple in standard splines in a very elaborate way. My spline will indeed curve
substantially and, what's more, I will repeat the spline in a number of
geometries. If I follow your advice, I'll need to make it good enough to work in
general cases.

I was hoping that the spline package offers a one-line way to do this, and that
I simply missed the syntax. For instance, there is a spline clock term in the
package ("sClock"), but when I try utlilyzing it in the pigment definition, the
term is not accepted. Can it be that I have not understood how term has to be
defined?

Best regards,
Alex


Alain <kua### [at] videotronca> wrote:

> > Hi everyone,
> >
> > Is anybody experienced with Chris Colefax' spline package? I am trying to
> > generate a spline that changes its width and color along the spline position in
> > a controlled manner. The spline will be much longer that thick, so using spheres
> > seems like a bad option. Using "spline.mcr" and reading the tutorial I found
> > that I can create a spline using tubes (which is much more efficient that
> > spheres in my case) with the following syntax:
> >
> > #declare my_spline = create_spline (
> >                               array[4] {start_position,  // 1st point
> >                                         start_position + start_direction,
> >                                         end_position - end_direction,
> >                                         end_position},   // 2rnd point
> >                                         create_bezier_spline)
> >
> > #macro spline_radius_function () sClock #end
> > union { pipe_spline (my_spline, spline_radius (1)) pigment {rgb <1, 0, 0>} }
> >
> > ....with arbitrary parameters 'start_position', 'start_direction',
> > 'end_position', and 'end_direction'. This gives me the right shape but a uniform
> > color. I have been trying to vary the color (linearly) along the spline by
> > multiplying the rgb value with 'sClock' or similar, but this is not accepted in
> > the syntax. Anybody done this before or knows a solution?
> >
> > Many thanks in advance,
> > Alex
> >
> >
>
> You can use a gradient pattern. The only trick is orienting and scalling
> it properly.
> For the direction, you use the difference between the start and end points.
> For the scalling, you use the distance between those points.
> That way, the zero entry of the colour_map will be at one point and the
> one at the other.
> It can look like this:
> gradient{
>  abs(start_position-end_position)// direction vector
>  colour_map{[0 rgb<1,0.5,0>][1 rgb<0,0,1>]}
>  scale vlength(start_point-end_point)//make it fit
> }
>
> If your spline have an important curvature, it becomes more difficult.
> You'll need to find the approximate center of the curve and the covered
> angle. Then, using the radial pattern, use frequency and to adjust the
> colour_map to the angle of the curve, then translate the pattern to the
> center point.
> This will involve a fair amount of trigonometry.
>
>
> Alain


Post a reply to this message

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