POV-Ray : Newsgroups : povray.binaries.images : Re: spline macro help need. - explain.jpg (1/1) Server Time
19 Nov 2024 04:25:34 EST (-0500)
  Re: spline macro help need. - explain.jpg (1/1) (Message 1 to 9 of 9)  
From: Mike Williams
Subject: Re: spline macro help need. - explain.jpg (1/1)
Date: 7 Feb 2004 01:14:17
Message: <40248239@news.povray.org>
I can't reproduce the problem you're having at the left side of your chain,
but I can reproduce and fix the weird effect that happens in the middle. I'd
have to see more of your code before I can address the problem on the left.
Are you using some extra options in your create_spline call?


Problem 1: some of the links overlap

A POV cubic_spline can have as many extra points as you feel like. The part
of the spline that you evaluate is up to you.

A Colefax cubic_spline has one control point beyond the spline at each end.
Macros like link_spline start at the second point and stop at the
next-to-last point. If you've more than one control points at one end, then
link_spline will paint links into the control region.

The splinefollow.pov example happens to have two control points beyond the
spline at each end. When you convert it into a Colefax spline you should
delete these points, giving you an array size of 14 instead of 16.


Problem 2: there's a discontinuity in the middle

The macro doesn't link the first link in the spline to the last one
correctly. That's because a link is 1 unit long and the spline is 44.75268
units long. I changed the spline_step_size to make there be exactly 44 links
in the chain. That fixes this particular spline, for other splines you might
need to tweak it a bit to force the number of links to be even.

#declare Step = spline_length(S)/int(spline_length(S));
link_spline (S, spline_step_size(Step)+spline_step_twist(90))


Post a reply to this message


Attachments:
Download 'SPlineChain.jpg' (43 KB)

Preview of image 'SPlineChain.jpg'
SPlineChain.jpg


 

From: Kurts
Subject: Re: spline macro help need. - explain.jpg (1/1)
Date: 7 Feb 2004 03:19:49
Message: <kurtzlepirate-60B295.09194907022004@news.povray.org>
In article <40248239@news.povray.org>,
 "Mike Williams" <nos### [at] econymdemoncouk> wrote:

> I can't reproduce the problem you're having at the left side of your chain,
> but I can reproduce and fix the weird effect that happens in the middle. I'd
> have to see more of your code before I can address the problem on the left.
> Are you using some extra options in your create_spline call?

here is a code :
//  --------------------------------------------------------------------------
#include "colors.inc"
// #include "personal.inc"
#include "math.inc"
#include "transforms.inc"
#include "spline.inc" // Chris Colefax macros



//  --------------------------------------------------------------------------
#declare displayAxis = false;

#declare displaySpline = false;
#declare displaySplinePoints = true;

#declare displayMaillon = false;



//  --------------------------------------------------------------------------
//  --- SCENE ----------------------------------------------------------------
//  --------------------------------------------------------------------------
camera {
  location <2,12-2,-10+2>
  // location p2r(284.036, 50.490, 12.961,false) polar2rectangular personal macro
  look_at  <0,2,3>
  }

sky_sphere {
  pigment {
    planar
    poly_wave 2
     color_map {
      [0.0, color <0.2,0.5,1.0>]
      [1.0, color <0.8,0.9,1.0>]
      }
    }
  }

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

plane { // checkered plane
  y, -1
  pigment {
    checker White, White*0.90
    scale 5
    }
  }

#if (displayAxis) drawAxis (16, 0.07) #end


//  --------------------------------------------------------------------------
// The spline
//  --------------------------------------------------------------------------
//#declare MySpline = spline {
//   cubic_spline
//   -2, <-5, 3, 0>, // control point
//   -1, <-2, 2, 0>, // control point
//   00, < 0, 2, 0>, // start
//   01, < 0, 2, 0>,
//   02, < 5, 3, 0>, // through yellow ring
//   03, < 5, 4, 4>,
//   04, < 0, 5, 5>, // around
//   05, <-2, 4, 9>, // the
//   06, < 2, 3, 9>, // green
//   07, < 0, 2, 5>, // pole
//   08, <-5, 2, 4>,
//   09, <-5, 3, 0>, // through blue ring
//   10, <-2, 2, 0>,
//   11, < 0, 2, 0>, // stop
//   12, < 2, 2, 0>, // control point
//   13, < 5, 3, 0>, // control point
//  }
#declare MySplinePoints = array [16]
#declare MySplinePoints[0] =<-5, 3, 0>;
#declare MySplinePoints[1] =<-2, 2, 0>;
#declare MySplinePoints[2] =< 0, 2, 0>;
#declare MySplinePoints[3] =< 0, 2, 0>;
#declare MySplinePoints[4] =< 5, 3, 0>;
#declare MySplinePoints[5] =< 5, 4, 4>;
#declare MySplinePoints[6] =< 0, 5, 5>;
#declare MySplinePoints[7] =<-2, 4, 9>;
#declare MySplinePoints[8] =< 2, 3, 9>;
#declare MySplinePoints[9] =< 0, 2, 5>;
#declare MySplinePoints[10] =<-5, 2, 4>;
#declare MySplinePoints[11] =<-5, 3, 0>;
#declare MySplinePoints[12] =<-2, 2, 0>;
#declare MySplinePoints[13] =< 0, 2, 0>;
#declare MySplinePoints[14] =< 2, 2, 0>;
#declare MySplinePoints[15] =< 5, 3, 0>;
#declare MySpline = create_spline (MySplinePoints, create_cubic_spline)




//  --------------------------------------------------------------------------
// show the spline
//  --------------------------------------------------------------------------
#if (displaySpline)
  #declare C = 0;
  #declare Cmax= 50;
  union {
    #while (C<=Cmax)
      #declare Value1 = C/Cmax*11;
      #declare Value2 = (C+1)/Cmax*11;
      #declare Point1 = -0.5*y+MySpline(Value1);
      #declare Point2 = -0.5*y+MySpline(Value2);
      #if (displaySplinePoints)
        sphere {Point1, 0.2 pigment { color Red } }
      #else
        sphere {Point1, 0.1 pigment { color Yellow } }
      #end
      cylinder {Point1, Point2, 0.1 pigment { color Yellow } }
      #declare C = C+1;
    #end
    }
#end




//  --------------------------------------------------------------------------
// anneau
//  --------------------------------------------------------------------------
#declare halfTorus = difference {
  torus { 0.5, 0.2 }
  plane { x, 0}
  }
#declare maillon = union {
  object { halfTorus translate 1.00*x }
  object { halfTorus rotate 180*y }
  cylinder { <0.00, 0.00, +0.50> <1.00, 0.00, +0.50> 0.2 }
  cylinder { <0.00, 0.00, -0.50> <1.00, 0.00, -0.50> 0.2 }
  
  translate -0.50*x
  }

#if (displayMaillon) object { maillon pigment { color White } } #end




//  --------------------------------------------------------------------------
// chaine
//  --------------------------------------------------------------------------
#declare link_object = object {
  maillon
   pigment { color White*0.60 }
   finish { reflection 0.2 specular 0.8 metallic}
   }

link_spline (MySpline, spline_step_size(1)+spline_step_twist(90))
//  --------------------------------------------------------------------------


thanksss


Post a reply to this message

From: Mike Williams
Subject: Re: spline macro help need. - explain.jpg (1/1)
Date: 7 Feb 2004 05:58:36
Message: <$SInoHAFSMJAFw0i@econym.demon.co.uk>
Wasn't it Kurts who wrote:
>In article <40248239@news.povray.org>,
> "Mike Williams" <nos### [at] econymdemoncouk> wrote:
>
>> I can't reproduce the problem you're having at the left side of your chain,
>> but I can reproduce and fix the weird effect that happens in the middle. I'd
>> have to see more of your code before I can address the problem on the left.
>> Are you using some extra options in your create_spline call?
>
>here is a code :

On my machine, your code still doesn't exhibit the problem that you had
on the left edge. Are you perhaps using an old version of the spline
macro?

On my machine it looks good if I just make the changes that Steve and I
said earlier:

1. Remove the two spurious points from the MySplinePoints array

2. Change the step size so that you get an even whole number of links

3. Scale your link_object down by "scale 0.625".

The points where the links should touch in your object are at x=0.8 and
x=-0.8 (the links should touch on the inside edge of the half torus) but
link_spline requires the touch points to be at x=0.5 and x=-0.5. So
scale your link by five eighths.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Kurts
Subject: Re: spline macro help need. + progress.jpg 36Ko - in_progress.jpg (1/1)
Date: 7 Feb 2004 12:19:47
Message: <kurtzlepirate-CB1EF2.18193907022004@news.povray.org>
In article <$SIn### [at] econymdemoncouk>,
 Mike Williams <nos### [at] econymdemoncouk> wrote:

> On my machine, your code still doesn't exhibit the problem that you had
> on the left edge. Are you perhaps using an old version of the spline
> macro?
> 
> On my machine it looks good if I just make the changes that Steve and I
> said earlier:
> 
> 1. Remove the two spurious points from the MySplinePoints array
> 
> 2. Change the step size so that you get an even whole number of links
> 
> 3. Scale your link_object down by "scale 0.625".
> 
> The points where the links should touch in your object are at x=0.8 and
> x=-0.8 (the links should touch on the inside edge of the half torus) but
> link_spline requires the touch points to be at x=0.5 and x=-0.5. So
> scale your link by five eighths.


thanks you. i follow yours advices. some progress but still one problem.

//  --------------------------------------------------------------------------
// Persistence Of Vision raytracer version 3.5 sample file.
//  --------------------------------------------------------------------------
#version unofficial MegaPov 1.0;




//  --------------------------------------------------------------------------
#include "colors.inc"
// #include "personal.inc"
#include "math.inc"
#include "transforms.inc"
#include "spline.inc"



//  --------------------------------------------------------------------------
//  --- SCENE ----------------------------------------------------------------
//  --------------------------------------------------------------------------
camera {
  location <2,12-2,-10+2>
  // location p2r(284.036, 50.490, 12.961,false)
  look_at  <0,2,3>
  }

sky_sphere {
  pigment {
    planar
    poly_wave 2
     color_map {
      [0.0, color <0.2,0.5,1.0>]
      [1.0, color <0.8,0.9,1.0>]
      }
    }
  }

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

plane { // checkered plane
  y, -1
  pigment {
    checker White, White*0.90
    scale 5
    }
  }




//  --------------------------------------------------------------------------
// The original spline
//  --------------------------------------------------------------------------
//#declare MySpline = spline {
//   cubic_spline
//   -2, <-5, 3, 0>, // control point
//   -1, <-2, 2, 0>, // control point
//   00, < 0, 2, 0>, // start
//   01, < 0, 2, 0>,
//   02, < 5, 3, 0>, // through yellow ring
//   03, < 5, 4, 4>,
//   04, < 0, 5, 5>, // around
//   05, <-2, 4, 9>, // the
//   06, < 2, 3, 9>, // green
//   07, < 0, 2, 5>, // pole
//   08, <-5, 2, 4>,
//   09, <-5, 3, 0>, // through blue ring
//   10, <-2, 2, 0>,
//   11, < 0, 2, 0>, // stop
//   12, < 2, 2, 0>, // control point
//   13, < 5, 3, 0>, // control point
//  }



//  --------------------------------------------------------------------------
//  --------------------------------------------------------------------------
// 1. remove the two spurious points
//  --------------------------------------------------------------------------
//  --------------------------------------------------------------------------

#declare MySplinePoints = array [14]
  // #declare MySplinePoints[0] =<-5, 3, 0>;
#declare MySplinePoints[0] =<-2, 2, 0>;
#declare MySplinePoints[1] =< 0, 2, 0>;
#declare MySplinePoints[2] =< 0, 2, 0>;
#declare MySplinePoints[3] =< 5, 3, 0>;
#declare MySplinePoints[4] =< 5, 4, 4>;
#declare MySplinePoints[5] =< 0, 5, 5>;
#declare MySplinePoints[6] =<-2, 4, 9>;
#declare MySplinePoints[7] =< 2, 3, 9>;
#declare MySplinePoints[8] =< 0, 2, 5>;
#declare MySplinePoints[9] =<-5, 2, 4>;
#declare MySplinePoints[10] =<-5, 3, 0>;
#declare MySplinePoints[11] =<-2, 2, 0>;
#declare MySplinePoints[12] =< 0, 2, 0>;
#declare MySplinePoints[13] =< 2, 2, 0>;
  // #declare MySplinePoints[15] =< 5, 3, 0>;

#declare MySpline = create_spline (MySplinePoints, create_cubic_spline)




//  --------------------------------------------------------------------------
// link object
//  --------------------------------------------------------------------------
#declare majorRadius = 0.50;
#declare minorRadius = 0.20;
#declare linkLen = 1.00;

#declare halfTorus = difference {
  torus { majorRadius, minorRadius }
  plane { x, 0}
  }
#declare maillon = union {
  object { halfTorus translate linkLen*x }
  object { halfTorus rotate 180*y }
  cylinder { <0.00, 0.00, +majorRadius> <linkLen, 0.00, +majorRadius> 
minorRadius }
  cylinder { <0.00, 0.00, -majorRadius> <linkLen, 0.00, -majorRadius> 
minorRadius }
  
  translate -linkLen*0.50*x
  }

#declare link_object = object {
  maillon
  pigment { color White*0.60 }
  finish { reflection 0.2 specular 0.8 metallic}
  }



//  --------------------------------------------------------------------------
#declare link_objectMax = max_extent(link_object);
#declare link_objectMin = min_extent(link_object);
#debug "\n\n"
#debug concat("\n>> max : x = ",str(link_objectMax.x,6,4)," y = 
",str(link_objectMax.y,6,4)," z = ",str(link_objectMax.z,6,4))
#debug concat("\n>> min : x = ",str(link_objectMin.x,6,4)," y = 
",str(link_objectMin.y,6,4)," z = ",str(link_objectMin.z,6,4))

#declare linkTouch = link_objectMax.x-2*minorRadius;
#debug concat("\n>> linkTouch = ",str(linkTouch,6,4))

#declare scaling = 0.50/linkTouch;
#debug concat("\n>> scaling = ",str(scaling,6,4))
//  --------------------------------------------------------------------------
//  --------------------------------------------------------------------------
// 3. scale your link_object down
//  --------------------------------------------------------------------------
//  --------------------------------------------------------------------------
#set link_object = object { link_object scale scaling }

#declare splineLen = spline_length(MySpline);
#debug concat("\n>> splineLen = ",str(splineLen,8,3))

#declare splineStep = splineLen/int(splineLen);
#debug concat("\n>> splineStep = ",str(splineStep,8,3))

#declare number_of_link = splineLen/splineStep;
#debug concat("\n>> number_of_link = ",str(number_of_link,8,3))


//  --------------------------------------------------------------------------
//  --------------------------------------------------------------------------
// 2. Change the step size so that you get en even whole number of links
//  --------------------------------------------------------------------------
//  --------------------------------------------------------------------------
#set number_of_link = (mod(number_of_link,2)=0 ? number_of_link : 
number_of_link+1);
#debug concat("\n>> modified number_of_link = ",str(number_of_link,8,3)," <- an 
even whole number !")

#set splineStep = splineLen/number_of_link;
#debug concat("\n>> new splineStep = ",str(splineStep,8,3),"\n\n")



link_spline (MySpline, spline_step_size(splineStep)+spline_step_twist(90))
//  --------------------------------------------------------------------------


Post a reply to this message


Attachments:
Download 'in_progress.jpg' (30 KB)

Preview of image 'in_progress.jpg'
in_progress.jpg


 

From: Mike Williams
Subject: Re: spline macro help need. + progress.jpg 36Ko - in_progress.jpg (1/1)
Date: 7 Feb 2004 13:52:18
Message: <ideQLCAcOTJAFwHO@econym.demon.co.uk>
Wasn't it Kurts who wrote:
>thanks you. i follow yours advices. some progress but still one problem.

There's a typo in your spline co-ordinates. 
Cubic splines don't like it if you have repeat control points. 
You typed:

#declare MySplinePoints[1] =< 0, 2, 0>;
#declare MySplinePoints[2] =< 0, 2, 0>;

Instead of

#declare MySplinePoints[1] =< 0, 2, 0>;
#declare MySplinePoints[2] =< 2, 2, 0>;

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Kurts
Subject: Re: spline macro help need. + progress.jpg 36Ko - in_progress.jpg (1/1)
Date: 7 Feb 2004 14:14:41
Message: <kurtzlepirate-6C6C57.20143307022004@news.povray.org>


Post a reply to this message

From: St 
Subject: Re: spline macro help need. + progress.jpg 36Ko - in_progress.jpg (1/1)
Date: 7 Feb 2004 15:29:49
Message: <40254abd$1@news.povray.org>
"Kurts" <kur### [at] yahoofr> wrote in message
news:kurtzlepirate-6C6C57.20143307022004@news.povray.org...
> In article <ide### [at] econymdemoncouk>,

>   it works !!!!!!!

   ....and if you change lines 0, 1, 3, 4,  to;

  #declare MySplinePoints[0] =<-3.845, 3, 0.28>;
  #declare MySplinePoints[1] =< -.12, 2, 0.01>;
  #declare MySplinePoints[3] =< 4.1, 3, 0>;
  #declare MySplinePoints[4] =< 5.01, 4, 3.88>;

    ...gets rid of the problem on the left, (there was still a problem
there), but leaves a *very* small problem in the middle of the nearest
piece of chain. (Probably unnoticeable when scaled down and used in an
image of course).

     That's about the closest I can get.

          ~Steve~


Post a reply to this message

From: Kurts
Subject: Re: spline macro help need + 16Ko image : - difference.jpg (1/1)
Date: 7 Feb 2004 17:31:01
Message: <kurtzlepirate-0EA0A5.23310007022004@news.povray.org>
In article <40254abd$1@news.povray.org>, "St." <dot### [at] dotcom> wrote:

> "Kurts" <kur### [at] yahoofr> wrote in message
> news:kurtzlepirate-6C6C57.20143307022004@news.povray.org...
> > In article <ide### [at] econymdemoncouk>,
> 
> >   it works !!!!!!!
> 
>    ....and if you change lines 0, 1, 3, 4,  to;
> 
>   #declare MySplinePoints[0] =<-3.845, 3, 0.28>;
>   #declare MySplinePoints[1] =< -.12, 2, 0.01>;
>   #declare MySplinePoints[3] =< 4.1, 3, 0>;
>   #declare MySplinePoints[4] =< 5.01, 4, 3.88>;
> 
>     ...gets rid of the problem on the left, (there was still a problem
> there), but leaves a *very* small problem in the middle of the nearest
> piece of chain. (Probably unnoticeable when scaled down and used in an
> image of course).
> 
>      That's about the closest I can get.
> 
>           ~Steve~
> 

i not see any problem on the left side. your 0, 1, 3 et 4 modifications points 
change the spline at the right. here is a composite image with and without this 
points modified.


Post a reply to this message


Attachments:
Download 'difference.jpg' (12 KB)

Preview of image 'difference.jpg'
difference.jpg


 

From: St 
Subject: Re: spline macro help need + 16Ko image : - difference.jpg (1/1)
Date: 7 Feb 2004 18:06:30
Message: <40256f76@news.povray.org>
"Kurts" <kur### [at] yahoofr> wrote in message
news:kurtzlepirate-0EA0A5.23310007022004@news.povray.org...
> In article <40254abd$1@news.povray.org>, "St." <dot### [at] dotcom> wrote:

> i not see any problem on the left side. your 0, 1, 3 et 4
modifications points
> change the spline at the right. here is a composite image with and
without this
> points modified.

   Yes, my apologies. I've obviously got some translation wrong there.
I was working more on sorting the attached problem out after the error
was found.

    Is half a unit going to make a difference to your scene?

      ~Steve~


Post a reply to this message


Attachments:
Download 'problem.jpg' (7 KB)

Preview of image 'problem.jpg'
problem.jpg


 

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