|
|
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
|
|
|
|
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
|
|