POV-Ray : Newsgroups : povray.advanced-users : Equal spacing along curve Server Time
30 Jul 2024 08:27:26 EDT (-0400)
  Equal spacing along curve (Message 1 to 9 of 9)  
From: Sigmund Kyrre Aas
Subject: Equal spacing along curve
Date: 13 Feb 2000 14:00:25
Message: <38A6FE38.8DC6092E@stud.ntnu.no>
I'm trying to get equally spaced points on a parametric curve, but my
brain is just dumping core.

I have something similar to:

%ant=100;
#while (i<ant)
 %t=i/ant*x0;		// t running from 0 to x0
 %f=<t, Y(t), Z(t)>;	// f(t=0 -> x0) has arc lengt S
 sphere {f, .1}
 %i=i+1;
#end

Now, df/dt would be the "speed" of the points along the curve, but how
do I use it to get the desired effect?

sig.


Post a reply to this message

From: Peter Popov
Subject: Re: Equal spacing along curve
Date: 13 Feb 2000 15:19:20
Message: <EBCnOOIXNgxACCw8Pj01YyuclJBg@4ax.com>
On Sun, 13 Feb 2000 19:55:52 +0100, Sigmund Kyrre Aas
<as### [at] studntnuno> wrote:

>I'm trying to get equally spaced points on a parametric curve, but my
>brain is just dumping core.

 There was a thread in this forum called "Adding forces to points on
curves" started by Rune on Dec 27. Some of the replies there dig into
your problem.

>Now, df/dt would be the "speed" of the points along the curve, but how
>do I use it to get the desired effect?

Calculate the length l of the curve by integration. Divide it in n
equal pieces of length l/n. The first piece starts at t=0 and ends at
t1, where t1 is such that the integral of f(t)/dt from t to t1 equals
l/n. I think this is translateable to mathese but my brain is too
dumping core at the moment :)

>sig.


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


Post a reply to this message

From: Thomas Willhalm
Subject: Re: Equal spacing along curve
Date: 14 Feb 2000 07:45:38
Message: <qqmael4vtot.fsf@schlatt.fmi.uni-konstanz.de>
Sigmund Kyrre Aas <as### [at] studntnuno> writes:
>  %f=<t, Y(t), Z(t)>;	// f(t=0 -> x0) has arc lengt S
> 
> Now, df/dt would be the "speed" of the points along the curve, but how
> do I use it to get the desired effect?

As Peter already pointed out, you need to integrate your function f. So
give us f and we'll see what we can do about it.

Thomas

-- 
http://thomas.willhalm.de/ (includes pgp key)


Post a reply to this message

From: Sigmund Kyrre Aas
Subject: Re: Equal spacing along curve
Date: 14 Feb 2000 19:29:07
Message: <38A89DE0.F9841C16@stud.ntnu.no>
Peter Popov wrote:
>  There was a thread in this forum called "Adding forces to points on
> curves" started by Rune on Dec 27. Some of the replies there dig into
> your problem.

Thanks for the tip. I've read the posts about getting equally spaced 
points on a spline but haven't had the time to dig into the macros.

> t1, where t1 is such that the integral of f(t)/dt from t to t1 equals

I agree if you mean:
integral of sqrt(X'(t)^2 + Y'(t)^2 + Z'(t)^2) from 0 to t1 equals l/n.

.. and the next would be from t1 to t2 right?
But I can't solve this equation analytically. 

As I see it I can 
a) produce splines in pov using LSpline3
b) produce splines in Matlab
c) solve the 13 equations above numerically in Matlab

-- think I'll start with a) even though I'm a spline virgin.

sig.


Post a reply to this message

From: Sigmund Kyrre Aas
Subject: Re: Equal spacing along curve
Date: 14 Feb 2000 19:29:47
Message: <38A89E08.A6B8DCC7@stud.ntnu.no>
Thomas Willhalm wrote:
> As Peter already pointed out, you need to integrate your function f. So
> give us f and we'll see what we can do about it.

My function is rather hard to integrate, but easy to differentiate. 
That's why I wanted to use dfdt: It contains information of how far
apart the points are so it should be possible..

For now I have created a very crude numerical integration routine.
Since the function behaves so badly at t=x0, I guess I'll be better
off making a spline.

%S=4.168;  //curve length from summing the "arc"s below
%d=S/13;
%W=2.5; 
%R=3;
%b0=R/sqrt(2);
%x0=R*cos(W/2/R);
%y0=R*sin(W/2/R);

#macro p(T) (y0-b0)/x0*T+b0 #end
#macro Z(T) sqrt( sqr(R)-sqr(T)-sqr(p(T)) ) #end

%splitt=.04;
%lengde=.39;
%arc=0;
%eigth=union{
    %i=0;
    %ant=104;
    #while (i<ant) 
        %X=i/ant*x0;
        %Xn=(i+1)/ant*x0;
        cylinder {<X, p(X), Z(X)> , <Xn,p(Xn),Z(Xn)>, splitt pigment {colour  rgb .5}}
        %arc=arc+vlength(<X, p(X), Z(X)> - <Xn,p(Xn),Z(Xn)>);
        #if (arc>d)
	    object {Thing_to_place_on_curve}
            %arc=0;
        #end
        %i=i+1;
    #end
}


Post a reply to this message

From:
Subject: Re: Equal spacing along curve
Date: 15 Feb 2000 09:21:08
Message: <k8e900mfsx5.fsf@jeeves.stud.ntnu.no>
Sigmund Kyrre Aas <as### [at] studntnuno> writes:

>         %arc=arc+vlength(<X, p(X), Z(X)> - <Xn,p(Xn),Z(Xn)>);
>         #if (arc>d)
> 	    object {Thing_to_place_on_curve}
>             %arc=0;
>         #end

Ok, a better one would be:

	object { Thing translate (arc-d)*vnormalize(dfdt) }

This is actually good enough for my purpose, but I still have
problems.. As the name "eigth" implies this is only one eigth of the whole
function, the rest beeing symmetrical, so this curve has to behave at the
endpoints.

btw I have to put aside all hobbies for a while, cause I'm lagging
terribly behind at school. :-/ But please, keep those good suggestions
pouring in and I'll look at it when I'm more on top of things here..

-- 
Sigmund Kyrre Aas


Post a reply to this message

From: Chris Colefax
Subject: Re: Equal spacing along curve
Date: 16 Feb 2000 17:50:30
Message: <38ab29b6@news.povray.org>
Sigmund Kyrre Aas <as### [at] studntnuno> wrote:
> I agree if you mean:
> integral of sqrt(X'(t)^2 + Y'(t)^2 + Z'(t)^2) from 0 to t1 equals l/n.
>
> .. and the next would be from t1 to t2 right?
> But I can't solve this equation analytically.
>
> As I see it I can
> a) produce splines in pov using LSpline3
> b) produce splines in Matlab
> c) solve the 13 equations above numerically in Matlab
>
> -- think I'll start with a) even though I'm a spline virgin.

I had the same problem when creating my own Spline macro system: it creates
multi-segment cubic interpolating splines, and there is no known way of
integrating the spline function.  My solution, both for calculating the
length of the spline and finding evenly spaced intervals along it, was to
first sample the spline segment's length (L) at equal values of the control
parameter (t), and then reverse interpolate to get equal length intervals.

I've optimised the macros to precalculate all possible coefficients from the
original point data, and I've added a cache-file feature, so the performance
is (to me, at least) quite acceptable.  If you would like a preview copy
feel free to email me for details.


Post a reply to this message

From: Rune
Subject: Re: Equal spacing along curve
Date: 20 Feb 2000 09:06:05
Message: <38aff4cd@news.povray.org>
"Sigmund Kyrre Aas" <as### [at] studntnuno> wrote:
> I'm trying to get equally spaced points on
> a parametric curve, but my brain is just
> dumping core.

I'm not sure exactly what you want, but if
you want to distribute points evenly along a
spline segment, then you might want to have
a look at my Inverse Kinematic Neck Include
File. It calculates a spline with the right
length, distribute points evenly or
exponentially along it, calculates forward,
up, and right vectors with support of
twisting, and you can along objects along
the spline in almost any way you want to.

However, it only handles one spline segment
at a time. With some manual work you can use
it for multiple spline segments, but if you
want a more automatized(?) solution you might
want to wait for Chris Colefax's Spline macro
system, which I think do many of the same
things plus much more.

Greetings,

Rune

---
Updated January 24: 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: Sigmund Kyrre Aas
Subject: Re: Equal spacing along curve
Date: 20 Feb 2000 17:33:41
Message: <38B06BD0.8661E406@stud.ntnu.no>
Rune wrote:
> I'm not sure exactly what you want, but if
..

I've posted an image in p.b.i. When I used the function to create a spline, the
stitches were distributed evenly - because the curve has constant curvature I
guess.

..
> want to wait for Chris Colefax's Spline macro
> system, which I think do many of the same
> things plus much more.

His spline macro has, in addition to "inverse kinematics" (is that a good
name?) features, some very promising macros to create splines and control their
appearance.

mvh. sig.


Post a reply to this message

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