POV-Ray : Newsgroups : povray.advanced-users : Optimized curves Server Time
30 Jul 2024 08:29:31 EDT (-0400)
  Optimized curves (Message 1 to 6 of 6)  
From: Rune
Subject: Optimized curves
Date: 22 Dec 1999 15:20:01
Message: <38613271@news.povray.org>
I'm trying to figure out a way to optimize curves.
A curve of spheres positioned by a spline formula will be more bended some
places than others and the distance between the spheres won't be the same.

I need the spheres to be positioned so that there's a specified distance
between them and so that the bending is also evenly distributed.

See the small image in povray.binaries.images for a example of what I mean.

I tried to start out with a spline and then add forces to the spheres from
there but I couldn't figure out the core formulas needed.

Any idea how I should make the forces?
Or maybe there's an other way than using forces?

Greetings,

Rune

---
Updated December 10: http://rsj.mobilixnet.dk
Containing 3D images, stereograms, tutorials,
The POV Desktop Theme, 350+ raytracing jokes,
miscellaneous other things, and a lot of fun!


Post a reply to this message

From: Peter Popov
Subject: Re: Optimized curves
Date: 22 Dec 1999 17:18:03
Message: <+ExhOFEDFyM3FejoAuJk+atxdb+m@4ax.com>
On Wed, 22 Dec 1999 20:27:07 +0100, "Rune" <run### [at] inamecom>
wrote:

>I'm trying to figure out a way to optimize curves.
>A curve of spheres positioned by a spline formula will be more bended some
>places than others and the distance between the spheres won't be the same.
>
>I need the spheres to be positioned so that there's a specified distance
>between them and so that the bending is also evenly distributed.

Some time Chris Colefax mentioned this problem as being on his to-do
list. I don't know if he has made a macro with such functionality
publicly available, but he would probably be the right guy to ask for
help in this quest.

He he he™, you got the ball now, Chris :)


Peter Popov
pet### [at] usanet
ICQ: 15002700


Post a reply to this message

From: Bjoern Jaeger
Subject: Re: Optimized curves
Date: 22 Dec 1999 18:53:56
Message: <38616494@news.povray.org>
Hi

>I need the spheres to be positioned so that there's a specified distance
>between them and so that the bending is also evenly distributed.

I had the same problem when I made the tracks for my LEGO-excavator. To
distribute the tracklinks I wrote some macros.
The first macro worked much like a spline-function. It took a "time" value
0<=t<1 and returned a position along the desired path. My function didn't
use splines but consisted of several segments (straights and
circle-segments).
Another macro was used to get positions along the path with the desired
distances. It took a timevalue (which defined the old position) and the
desired distance to estimate the new timevalue with a certain precision.
This was done by a kind of binary search.
The last macro was just a loop that positioned the links by calling the
second macro repeatedly.

I don't know if this description was of much help. My solution is cetainly
quite parse-time-consuming :)

Good luck

                  Bjoern


Post a reply to this message

From: Mark Wagner
Subject: Re: Optimized curves
Date: 22 Dec 1999 23:59:42
Message: <3861ac3e@news.povray.org>
Rune wrote in message <38613271@news.povray.org>...
>I'm trying to figure out a way to optimize curves.
>A curve of spheres positioned by a spline formula will be more bended some
>places than others and the distance between the spheres won't be the same.
>
>I need the spheres to be positioned so that there's a specified distance
>between them and so that the bending is also evenly distributed.


I needed something like this for a flythrough of the Grand Canyon I'm
working on.  Here's the solution I came up with that uses the SuperPatch
splines.  Note that since the spline is a cubic curve, but this code assumes
that it is linear, the spacing is not perfectly even, but it is very close
under most circumstances.  I hope this helps.

Mark

////////////////////////////////////////////////////////////////////////////
/////

 #declare NumPoints = 16;
 #declare SplineData = array[NumPoints]
 { <.6,1,-.1>,        <.54,1,-.6>,    <.5,.35,-.9>,  <.6,.35,-1.25>,
<.6,.35,-1.65>,
   <.2,.35,-1.90>,
<-.2,.35,-1.67>,<-.8,.35,-1.60>,<-1.2,.35,-1.4>,<-1.4,.35,-1.15>,
   <-1.625,.35,-.825>,<-2,.35,-.45>,
<-2.6,.35,-.55>,<-2.9,.35,-.75>,<-3.3,.35,-.9>,
   <-4.7,.35,-1.35>
 } /* Replace the values in SplineData with the positions of the control
points in your spline */
  /* Remember to update the value of NumPoints */

/* This determines the spacing of the control points */
#declare TotalDist = 0;
#declare counter = 1;
#declare Dist = array[NumPoints]
#declare Dist[0] = 0;
#while(counter < NumPoints)
 #declare temp = SplineData[counter]; /* Current control point */
 #declare temp2 = SplineData[counter-1]; /* Previous control point */
 #declare dist = vlength(temp-temp2);
 #declare TotalDist = TotalDist + dist;
 #declare Dist[counter] = TotalDist;
  #declare counter = counter + 1;
#end /* You may need to #undef temp and temp2 */

#declare path = spline{
 cubic_spline

 #declare counter = 0;
 #while(counter < NumPoints)
  Dist[counter]/TotalDist, SplineData[counter] /* If you want the spline to
be spaced out over an interval other than 0 to 1, modify this line by
multiplying Dist/TotalDist by some constant */
  #declare counter = counter + 1;
 #end
}


Post a reply to this message

From: Chris Colefax
Subject: Re: Optimized curves
Date: 23 Dec 1999 11:58:22
Message: <386254ae@news.povray.org>
Rune <run### [at] inamecom> wrote:
> I'm trying to figure out a way to optimize curves.
> A curve of spheres positioned by a spline formula will be more bended some
> places than others and the distance between the spheres won't be the same.
>
> I need the spheres to be positioned so that there's a specified distance
> between them and so that the bending is also evenly distributed.
>
> See the small image in povray.binaries.images for a example of what I
mean.
>
> I tried to start out with a spline and then add forces to the spheres from
> there but I couldn't figure out the core formulas needed.
>
> Any idea how I should make the forces?
> Or maybe there's an other way than using forces?

As Peter mentioned I have been working on a spline macro that allows you to
space objects evenly along the curve length, and I actually posted an
example of such in binaries.animations some months ago.  The macros work by
sampling the spline's distance along its length and then reverse
interpolating to get the desired point(s).

The macros use cubic spline functions and one of the features I've included
is an optional tension value you can specify to adjust the
tightness/looseness of the curve.  However, the nature of the cubic function
does not allow you to produce anything like the second example you've
posted.

It might be possible to create more circular curves like you've shown by
changing the blending functions of your splines (so you're not using cubic
functions).  I believe NURBS allow the creation of circular arcs, and I did
actually fiddle around with some POV macros for creating NURBS curves (*not*
surfaces!), although they struck me as being quite complicated to design and
code.

Otherwise if it's circular arcs you want then something similar to Ron
Parker's TorSpline.inc should do the trick - but you can only specify one
tangent at the beginning of the curve.  I have a macro for this as well
(somewhere...), letting you link objects around the arcs specified by a list
of points.


Post a reply to this message

From: Chromax
Subject: Re: Optimized curves
Date: 3 Jan 2000 13:47:57
Message: <3870F071.8FF21310@mail.com>
Rune wrote:
> 
> I need the spheres to be positioned so that there's a specified distance
> between them and so that the bending is also evenly distributed.

Here is a a description for LSpline3.
Download from http://home.pacbell.net/tylereng/macros.zip.
----------------------------------------------------------

  lspline3.inc  v1.0

  Linear natural cubic spline macro for POV-Ray 3.1
  
  point=LSpline3(points[],t)
  
  Interpolates any number of points given in an array by a
  natural cubic spline where the parameter t ranges from 0
  to 1 pointing linearily along the length of the spline.
  This means that for example in an animation point
  LSpline3(points,clock) moves at constant velocity.
     
  First call creates the spline and returns the length in the
  .x component of the vector. Subsequent calls return points
  as specified by t.
  
  Any number of splines can be created. Calling LSpline3()
  with a different point set creates a new spline.

--------------------------------------------------------------

_______
Chromax


Post a reply to this message

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