POV-Ray : Newsgroups : povray.general : evenly spaced points on splines Server Time
31 Jul 2024 02:29:03 EDT (-0400)
  evenly spaced points on splines (Message 8 to 17 of 17)  
<<< Previous 7 Messages Goto Initial 10 Messages
From: Nicolas George
Subject: Re: evenly spaced points on splines
Date: 15 Apr 2008 15:35:30
Message: <48050382$1@news.povray.org>
"Tim Attwood"  wrote in message <4802861b@news.povray.org>:
>       #local result = result + vlength(V2-V1);

In the particular case of a spline, we know the derivative vector at any
point. I suspect it would be more accurate to use its length rather than the
distance between two consecutive points.


Post a reply to this message

From: Tim Attwood
Subject: Re: evenly spaced points on splines
Date: 17 Apr 2008 05:00:37
Message: <480711b5$1@news.povray.org>
>>       #local result = result + vlength(V2-V1);
>
> In the particular case of a spline, we know the derivative vector at any
> point. I suspect it would be more accurate to use its length rather than 
> the
> distance between two consecutive points.

I don't follow, maybe you could explain that?
I've read through a book on topology a while back and it
seemed very dense to me, isn't a derivative vector a
derivative in respect to a vector field? A vector field
being a mapping from R^n to R^n? I think in this case
a spline is a mapping from R to R^3, doesn't that
rule out some of this sort of math? Remember that
we don't know the type of spline here either.


Post a reply to this message

From: Jan Dvorak
Subject: Re: evenly spaced points on splines
Date: 17 Apr 2008 09:29:33
Message: <480750bd$1@news.povray.org>
Tim Attwood napsal(a):
>>>       #local result = result + vlength(V2-V1);
>> In the particular case of a spline, we know the derivative vector at any
>> point. I suspect it would be more accurate to use its length rather than 
>> the
>> distance between two consecutive points.
> 
> I don't follow, maybe you could explain that?
> I've read through a book on topology a while back and it
> seemed very dense to me, isn't a derivative vector a
> derivative in respect to a vector field? A vector field
> being a mapping from R^n to R^n? I think in this case
> a spline is a mapping from R to R^3, doesn't that
> rule out some of this sort of math? Remember that
> we don't know the type of spline here either. 
> 
> 
A derivative is always with respect to a scalar and any vector is 
differentiable. An operator over R^n -> R^n is a divergence (nabla dot).
R^3 -> R^3 has a rotation (nabla cross) aditionally.
R^n -> R (a scalar field) has a gradient (nabla; vector of derivations 
along axes).


Post a reply to this message

From: Nicolas George
Subject: Re: evenly spaced points on splines
Date: 17 Apr 2008 13:27:54
Message: <4807889a@news.povray.org>
"Tim Attwood"  wrote in message <480711b5$1@news.povray.org>:
> I've read through a book on topology a while back and it
> seemed very dense to me, isn't a derivative vector a
> derivative in respect to a vector field? A vector field
> being a mapping from R^n to R^n?

I think you are confusing some notions. If you have something from R^n to
R^p. First, on the image, R^p is just a bunch of of R put together, and any
sort derivation will act independently on each component. Therefore we can
assume that p = 1.

If you have R^n -> R, you can speak of partial derivatives, or more
generally of the derivative in a particular direction; or you can speak of
differential forms, which puts everything together. The differential form is
the thingie that gives you the derivative in a particular direction knowing
the direction; the partial derivatives are the values of the differential
form for the base vectors.

<troll>
Curl, divergence and similar operators are just properties of the
differential form defined by physicists and engineers who do not understand
differential forms.
</troll>

But all this is somewhat advanced calculus. In France at least, it is only
taught to science students in college or similar level.

But in the n = 1 case, everything is much simpler: there is only one partial
derivative, which is thus no longer partial. The derivative of a function is
just the slope of the tangent to the curve. And if the function represents
the position of a point on an axis, then the derivative is the speed of the
point.

(For the record, still in France, this is taught to high school in
penultimate year to most students.)

If you have several dimensions for the image, as I said, each dimension
operates independently. That gives you the coordinates of a vector, called
the derivative vector.

If you see your function as a parametric arc, then the derivative vector is
a direction vector of the tangent to the arc (except at singular points, of
course).

If your function is the trajectory of an object, then the derivative vector
is its speed.


Now, for any sane definition, the length of a smooth curve given as a
parametric arc is the integral of the length of the derivative vector.

To approximate the length of a curve, you can approximate it by a polygonal
line, and compute the length of that line. That was the proposed solution.

But if you happen to know the exact derivative vector at any point, then I
suspect that using it instead will be more accurate.

>				      Remember that
> we don't know the type of spline here either. 

The term spline commonly refers to piecewise polynomial curves, and
especially with degree 3 (which allow to 4 control points: the start, the
end, and the derivative vectors for both).

The derivative of a polynomial is pretty easy to compute.


Post a reply to this message

From: Tim Attwood
Subject: Re: evenly spaced points on splines
Date: 17 Apr 2008 23:27:49
Message: <48081535$1@news.povray.org>
> I think you are confusing some notions. If you have something from R^n to
> R^p. First, on the image, R^p is just a bunch of of R put together, and 
> any
> sort derivation will act independently on each component. Therefore we can
> assume that p = 1.

Yeah I'm confused a bit. It's been a long time since calculus classes.

> If you have R^n -> R, you can speak of partial derivatives, or more
> generally of the derivative in a particular direction; or you can speak of
> differential forms, which puts everything together. The differential form 
> is
> the thingie that gives you the derivative in a particular direction 
> knowing
> the direction; the partial derivatives are the values of the differential
> form for the base vectors.

Since we don't know the equations that would go along with a POV
spline (it can be one of four spline types), and we don't know the
direction or velocity at any point on the spline, I think this means that
we can't do a direct math solution to this as a POV macro that takes a
POV spline as a parameter. I could be wrong though.

> <troll>
> Curl, divergence and similar operators are just properties of the
> differential form defined by physicists and engineers who do not 
> understand
> differential forms.
> </troll>

Mathematicians can tell you how things should work,
engineers can tell you how things really do work.

> But all this is somewhat advanced calculus. In France at least, it is only
> taught to science students in college or similar level.

Yeah, topology feels like graduate level math.

> But in the n = 1 case, everything is much simpler: there is only one 
> partial
> derivative, which is thus no longer partial. The derivative of a function 
> is
> just the slope of the tangent to the curve. And if the function represents
> the position of a point on an axis, then the derivative is the speed of 
> the
> point.
>
> (For the record, still in France, this is taught to high school in
> penultimate year to most students.)

That's the same way in the USA, except that sometimes it's first
year college if they didn't get it in high school.

> If you have several dimensions for the image, as I said, each dimension
> operates independently. That gives you the coordinates of a vector, called
> the derivative vector.
>
> If you see your function as a parametric arc, then the derivative vector 
> is
> a direction vector of the tangent to the arc (except at singular points, 
> of
> course).
>
> If your function is the trajectory of an object, then the derivative 
> vector
> is its speed.

You would need to sample the POV spline at multiple points to estimate
the slope or speed, even if you are treating it parametrically.

> Now, for any sane definition, the length of a smooth curve given as a
> parametric arc is the integral of the length of the derivative vector.

POV splines aren't always smooth though.

> To approximate the length of a curve, you can approximate it by a 
> polygonal
> line, and compute the length of that line. That was the proposed solution.

Right, digging out my old calculus book, this is the first solution for 
length
of a curve.

> But if you happen to know the exact derivative vector at any point, then I
> suspect that using it instead will be more accurate.
>> Remember that we don't know the type of spline here either.

Yeah it can be a definite integral, if you know the derivative
which we don't really. (That's the next page in the book.)

> The term spline commonly refers to piecewise polynomial curves, and
> especially with degree 3 (which allow to 4 control points: the start, the
> end, and the derivative vectors for both).

Sure, but I meant a POV spline.

> The derivative of a polynomial is pretty easy to compute.

Sure, but you can't do that for a POV spline easily.

You could do circle fitting with three points, but on sharp corners
that would be worse instead of better. You might do OK with some
sort of hybrid that can reject sharp corners and go back to linear
fitting, not sure if that would be better by much though, the current
macro seems accurate enough to me.


Post a reply to this message

From: Nicolas George
Subject: Re: evenly spaced points on splines
Date: 18 Apr 2008 08:20:39
Message: <48089217@news.povray.org>
"Tim Attwood"  wrote in message <48081535$1@news.povray.org>:
> Sure, but I meant a POV spline.

Well, a POV spline is one of linear_spline, quadratic_spline, cubic_spline
or natural_spline, which are all piecewise polynomials with degree up to
three. Computing its derivative is theoretically trivial.

In practice, I expect that the SDL does not provide enough introspection to
do it on any spline. That would be nice if the function was readily
available. And anyway, if the spline parameters are known in the source,
then it can be done without POV's help.


Post a reply to this message

From: Christian Froeschlin
Subject: Re: evenly spaced points on splines
Date: 19 Apr 2008 09:23:03
Message: <4809f237$1@news.povray.org>
>><troll>
>>Curl, divergence and similar operators are just properties of the
>>differential form defined by physicists and engineers who do not 
>>understand
>>differential forms.
>></troll>
> 
> Mathematicians can tell you how things should work,
> engineers can tell you how things really do work.
> 
>>But all this is somewhat advanced calculus. In France at least, it is only
>>taught to science students in college or similar level.
> 
> Yeah, topology feels like graduate level math.

Trolling++: This is advanced calculus and differential geometry.
Topology is much more beautiful, you get it after abstracting
those things away which could be related to actual numbers ;)


Post a reply to this message

From: Jan Dvorak
Subject: Re: evenly spaced points on splines
Date: 19 Apr 2008 10:38:41
Message: <480a03f1$1@news.povray.org>
Christian Froeschlin napsal(a):
>>> <troll>
>>> Curl, divergence and similar operators are just properties of the
>>> differential form defined by physicists and engineers who do not 
>>> understand
>>> differential forms.
>>> </troll>
>>
>> Mathematicians can tell you how things should work,
>> engineers can tell you how things really do work.
>>
>>> But all this is somewhat advanced calculus. In France at least, it is 
>>> only
>>> taught to science students in college or similar level.
>>
>> Yeah, topology feels like graduate level math.
> 
> Trolling++: This is advanced calculus and differential geometry.
> Topology is much more beautiful, you get it after abstracting
> those things away which could be related to actual numbers ;)
do you mean things like genus or number of dimensions?

-- 
You know you've been raytracing too long when...
you ever saw a beautiful scenery and regretted not to take your 6" 
reflective ball and a digital camera, thinking "this would have been a 
perfect light probe"
-Johnny D


Post a reply to this message

From: Christian Froeschlin
Subject: Re: evenly spaced points on splines
Date: 19 Apr 2008 11:36:48
Message: <480a1190$1@news.povray.org>
>>> Yeah, topology feels like graduate level math.
>>
>> Trolling++: This is advanced calculus and differential geometry.
>> Topology is much more beautiful, you get it after abstracting
>> those things away which could be related to actual numbers ;)
> 
> do you mean things like genus or number of dimensions?

More like functions operating on R^n so you have actual numerical
coordinates to work with when you start applying the stuff to the
problem of point distances. Topology would more or less say that
all subspaces of R^n with the same finite number m of points are
identical(*), without worrying about coordinates or distances ;)

(*) homeomorphic, the topological notion of "identical": there
     exists a bijective mapping, continuous in both directions.


Post a reply to this message

From: Jim Charter
Subject: Re: evenly spaced points on splines
Date: 22 May 2008 20:24:28
Message: <48360ebc@news.povray.org>
stevenvh wrote:


this a quick and dirty macro I use:

#macro SmoothSpline( Spline, Grain )
//regularizes the spline definition so
//the distance along the spline will be
//more proportional to the clock value

//first measure the input spline
         #local TL=0;
         #local Ptr=1;#while(Ptr<=Grain)
                 #local TL=
                         TL+vlength( Spline(Ptr/Grain)
                         -Spline((Ptr-1)/Grain) );
         #local Ptr=Ptr+1;#end

//now redefine the spline
         #local L=0;
         spline { 

                 natural_spline
                 0 Spline(0)
                 #local Ptr=1;#while(Ptr<=Grain)
                         #local L=
                         L+vlength( Spline(Ptr/Grain)
                         -Spline((Ptr-1)/Grain) );

                         L/TL Spline(Ptr/Grain)
                 #local Ptr=Ptr+1;#end
         }

#end


Post a reply to this message

<<< Previous 7 Messages Goto Initial 10 Messages

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