|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
yoyodunno <nomail@nomail> wrote:
> Is there something I can do to make the distance values constant over each time
> value in the spline so that the animation has constant speed, which will also
> let me make multiple carts.
Distributing points at even distances on a spline is a non-trivial problem
because of how a spline is calculated. I don't know if there exists a
closed form expression for this (in other words, a single non-recursive
formula which can be used to calculate a point at a given length from the
beginning of the spline without resorting to an iterative approximation),
but the most common approach to this is to approach the problem iteratively.
In other words, when you want a point on the spline which is at a distance
x from the beginning of the spline, you sample points on the spline,
approximate their distance from the beginning, and then use something
like binary partitioning to get a point arbitrarily close to the actual point
you are searching.
IIRC Colefax's spline macro utility had such a functionality built-in
(but it's not related to the splines in POV-Ray 3.6).
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp <war### [at] tagpovrayorg> wrote:
> but the most common approach to this is to approach the problem iteratively.
> In other words, when you want a point on the spline which is at a distance
> x from the beginning of the spline, you sample points on the spline,
> approximate their distance from the beginning, and then use something
> like binary partitioning to get a point arbitrarily close to the actual point
> you are searching.
>
> IIRC Colefax's spline macro utility had such a functionality built-in
> (but it's not related to the splines in POV-Ray 3.6).
>
> --
> - Warp
How do I sample points along the spline? Is there some command to get a point on
the spline or something? Also I have no idea what binary partitioning is, but
I'll look it up.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"yoyodunno" <nomail@nomail> wrote:
> Warp <war### [at] tagpovrayorg> wrote:
>
> > but the most common approach to this is to approach the problem iteratively.
> > In other words, when you want a point on the spline which is at a distance
> > x from the beginning of the spline, you sample points on the spline,
> > approximate their distance from the beginning, and then use something
> > like binary partitioning to get a point arbitrarily close to the actual point
> > you are searching.
> >
> > IIRC Colefax's spline macro utility had such a functionality built-in
> > (but it's not related to the splines in POV-Ray 3.6).
> >
> > --
> > - Warp
>
> How do I sample points along the spline? Is there some command to get a point on
> the spline or something? Also I have no idea what binary partitioning is, but
> I'll look it up.
The spline macro that Warp mentioned above can now be found here:
http://povrayinclude.wytraven.com/spline/index.html
--
Tor Olav
http://subcube.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Ok so I tried sampling points along the spline like this:
#declare curve_Vectors=0;
//try to average curve length with averaging vectors
#declare curve_loop=2;
#while(curve_loop<11)
#declare
curve_Vectors=curve_Vectors+vlength(spline_A(Nr+(stepValue*curve_loop))-spline_A(Nr+(stepValue*(curve_loop-1))));
#declare curve_loop=curve_loop+1;
#end
#declare curve_Average=curve_Vectors/9; //try to get average length of 9
subdivisions
#declare CumulativeDistance=CumulativeDistance+curve_Average;
object{tracks Spline_Trans(spline_A,CumulativeDistance,y,.1,.8)}
So it does give slightly better spaced tracks, I made that while loop to try and
average more vectors along the spline and it also helped slightly. But still not
that much better than originally.
Is there anything else to give a better approximation of the curve distance? And
yeah that colefax macro didn't work for what I have since I'm using a natural
spline, and also the Spline_Trans macro.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 12/9/2010 12:55 PM, Warp wrote:
> yoyodunno<nomail@nomail> wrote:
>> Is there something I can do to make the distance values constant over each time
>> value in the spline so that the animation has constant speed, which will also
>> let me make multiple carts.
>
> Distributing points at even distances on a spline is a non-trivial problem
> because of how a spline is calculated. I don't know if there exists a
> closed form expression for this (in other words, a single non-recursive
> formula which can be used to calculate a point at a given length from the
> beginning of the spline without resorting to an iterative approximation)...
About a decade ago I looked into something like this. Measuring the
length of a section of spline involves the integral of the length of the
differential of the... Uh, it's complicated. Even for a quadratic
spline the integral is hairy enough, and I suppose for a cubic spline
it's downright ugly. The iterative solution is much neater and simpler
to understand.
Regards,
John
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
John VanSickle <evi### [at] hotmailcom> wrote:
>
> About a decade ago I looked into something like this. Measuring the
> length of a section of spline involves the integral of the length of the
> differential of the... Uh, it's complicated. Even for a quadratic
> spline the integral is hairy enough, and I suppose for a cubic spline
> it's downright ugly. The iterative solution is much neater and simpler
> to understand.
>
> Regards,
> John
Yeah, arc length in calculus, I was thinking about that! But, I've decided it's
too involved for me right now lol. So instead, I worked on getting the time
values so that the distances are almost uniform on the spline, I have it pretty
close so that now I should be able to have multiple roller cars without looking
too weird scrunching up or stretching out in the animation. Now time to add the
ferris wheel!
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"yoyodunno" <nomail@nomail> wrote:
> Ok so I tried sampling points along the spline like this:
>
> #declare curve_Vectors=0;
> //try to average curve length with averaging vectors
> #declare curve_loop=2;
> #while(curve_loop<11)
> #declare
>
curve_Vectors=curve_Vectors+vlength(spline_A(Nr+(stepValue*curve_loop))-spline_A(Nr+(stepValue*(curve_loop-1))));
> #declare curve_loop=curve_loop+1;
> #end
> #declare curve_Average=curve_Vectors/9; //try to get average length of 9
> subdivisions
> #declare CumulativeDistance=CumulativeDistance+curve_Average;
>
> object{tracks Spline_Trans(spline_A,CumulativeDistance,y,.1,.8)}
>
> So it does give slightly better spaced tracks, I made that while loop to try and
> average more vectors along the spline and it also helped slightly. But still not
> that much better than originally.
>
> Is there anything else to give a better approximation of the curve distance? And
> yeah that colefax macro didn't work for what I have since I'm using a natural
> spline, and also the Spline_Trans macro.
See my recent posts to povray.binaries.images and povray.text.scene-files
--
Tor Olav
http://subcube.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Tor Olav Kristensen saw fit to write:
> See my recent posts to povray.binaries.images and povray.text.scene-files
Have you tried creating a new spline that is already arc-length-
parametrized? Something like what's described here:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.87.9080&rep=rep1&type=pdf
This seems a different method, but less appropriate for POV-Ray splines:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.84.1389&rep=rep1&type=pdf
--
light_source{9+9*x,1}camera{orthographic look_at(1-y)/4angle 30location
9/4-z*4}light_source{-9*z,1}union{box{.9-z.1+x clipped_by{plane{2+y-4*x
0}}}box{z-y-.1.1+z}box{-.1.1+x}box{.1z-.1}pigment{rgb<.8.2,1>}}//Jellby
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 2010-12-11 15:45, John VanSickle wrote:
> About a decade ago I looked into something like this. Measuring the
> length of a section of spline involves the integral of the length of the
> differential of the... Uh, it's complicated. Even for a quadratic spline
> the integral is hairy enough, and I suppose for a cubic spline it's
> downright ugly. The iterative solution is much neater and simpler to
> understand.
>
> Regards,
> John
I've been using splines to control the path of a piece of chain, which
requires that the specified length segments follow the arc. I recognized
that you can do this 3 ways:
1) Define the start point, path, end point, and let it add as many
segments as is needed to follow.
2) Define the start point, path, and number of segments, and guess where
it ends up.
3) Define the start point, end point, and number of segments, and use
some sort of approximation to make the path.
Of these, #3 is computationally expensive and doesn't really give what
you're looking for anyway, and #1 and #2 requires the computations that
this thread is about, which are hard. So I came up with:
4) Define start point, derivative of the path, and number of segments.
This approach is computationally trivial and with some tweaking will
give you almost exactly what you're looking for. I made the macro
calculate the distance between each segment of the chain (variable
length per unit for the heck of it), then it takes the derivative path
function as a parameter. Each step it finds the direction to move by
normalizing the spline entry at that index, increments the "current
position" variable, rotates the segment to fit the direction and then
translates to the new position. Yes, it's a numerical integrator, but if
you're placing things along the path you're doing most of that
computation already, so it's almost no more work. It has an added bonus
of working with any spline type you want.
So for example, you give a spline of:
#declare pathfunction = spline{
linear spline
0, <1,0,0>
20, <0,1,0>
}
you'll get a chain that starts going in +x and bends to be going +y by
the end of the 20 unit chain, i.e. a quarter circle (a real circle needs
natural_spline, but you get the idea). You have to fiddle with it to get
the right look and figure out where it ends, but that's not too hard.
The follower code:
#local dx = /*distance between centers of chain links*/
#local i = 0;
#local currentposition=<0,0,0>;
union{
#while (i < Length)
#local currentdirection=vnormalize(PathFunction(i+0.5));
#local currentposition=currentposition+dx*currentdirection;
object{ /* chain segment */
Reorient_Trans(x,currentdirection)
translate currentposition}
#local i = i + 1;
#end
}
Example render:
http://fc07.deviantart.net/fs22/i/2009/249/4/c/Full_Persian_Fun__CGI__by_cshake.png
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Jellby <me### [at] privacynet> wrote:
> Tor Olav Kristensen saw fit to write:
>
> > See my recent posts to povray.binaries.images and povray.text.scene-files
>
> Have you tried creating a new spline that is already arc-length-
> parametrized? Something like what's described here:
> http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.87.9080&rep=rep1&type=pdf
>
> This seems a different method, but less appropriate for POV-Ray splines:
> http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.84.1389&rep=rep1&type=pdf
Those are interesting articles, so thank you for the links.
I'll have to try out this later when I get some more spare time.
In the meantime it is possible to do something similar with the code I posted.
The code below shows one way to do this:
--
Tor Olav
http://subcube.com
#declare FnX_ = function(t_) { FnX(InverseSplineFn(t_)) };
#declare FnY_ = function(t_) { FnY(InverseSplineFn(t_)) };
#declare FnZ_ = function(t_) { FnZ(InverseSplineFn(t_)) };
#declare T_FnX_ = function(t_) { T_FnX(InverseSplineFn(t_)) };
#declare T_FnY_ = function(t_) { T_FnY(InverseSplineFn(t_)) };
#declare T_FnZ_ = function(t_) { T_FnZ(InverseSplineFn(t_)) };
#declare B_FnX_ = function(t_) { B_FnX(InverseSplineFn(t_)) };
#declare B_FnY_ = function(t_) { B_FnY(InverseSplineFn(t_)) };
#declare B_FnZ_ = function(t_) { B_FnZ(InverseSplineFn(t_)) };
#declare N_FnX_ = function(t_) { N_FnX(InverseSplineFn(t_)) };
#declare N_FnY_ = function(t_) { N_FnY(InverseSplineFn(t_)) };
#declare N_FnZ_ = function(t_) { N_FnZ(InverseSplineFn(t_)) };
#declare Intervals = 400;
#declare Knots = Intervals + 1;
#declare I = 0;
#while (I < Knots)
#declare T = Start + I/Intervals*Span;
object {
SmallArrows
matrix <
T_FnX_(T), T_FnY_(T), T_FnZ_(T),
B_FnX_(T), B_FnY_(T), B_FnZ_(T),
N_FnX_(T), N_FnY_(T), N_FnZ_(T),
FnX_(T), FnY_(T), FnZ_(T)
>
}
#declare I = I + 1;
#end // while
--
Tor Olav
http://subcube.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|