POV-Ray : Newsgroups : povray.general : How to get spline tangent Server Time
15 Oct 2026 05:11:56 EDT (-0400)
  How to get spline tangent (Message 1 to 17 of 17)  
From: Disnel
Subject: How to get spline tangent
Date: 21 Feb 2002 05:04:57
Message: <3C74C67A.3010207@itam.cas.cz>
Hello,

   is it possible to get tangent of spline for my use in scene?
   (In MegaPOV (my perfered now, because I'am heavily using PVM),
   or POV 3.5)

Thanks

Disnel


Post a reply to this message

From: Grey Knight
Subject: Re: How to get spline tangent
Date: 21 Feb 2002 05:54:22
Message: <3C74D1D3.35DE926B@namtar.qub.ac.uk>
To get the tangent at some point A on your spline, get the value of the
spline at A and some other point B which is very close to A. The values
you get we call spline(A) & spline(B).
The vector T=spline(B)-spline(A) gives the direction at the point A if B
is very close to A on the spline (check vlength(T) to find out how close
they are)
Don't forget to translate your object to spline(A) after aligning it
along T, since T is only a direction.

-- 
signature{
  "Grey Knight" contact{ email "gre### [at] yahoocom" }
  site_of_week{ url "http://digilander.iol.it/jrgpov" }
}


Post a reply to this message

From: Grey Knight
Subject: Re: How to get spline tangent
Date: 21 Feb 2002 08:20:27
Message: <3C74F40E.47318ADA@namtar.qub.ac.uk>
Actually, since splines are nice and smooth (after all, that's what
they're there for!), if you make sure vlength(T) is very small (say
1e-10 for example), then this method should give you a very good
approximation to the tangent; easily good enough for any purpose I can
think of anyway.

Disnel wrote:
> Thanks, but this is not exact way. My ask was, if there is any hidden 
> way how to get thi vector from POV ;-). But is must be sufficient..
> Regards
> Disnel

-- 
signature{
  "Grey Knight" contact{ email "gre### [at] yahoocom" }
  site_of_week{ url "http://digilander.iol.it/jrgpov" }
}


Post a reply to this message

From: Warp
Subject: Re: How to get spline tangent
Date: 21 Feb 2002 09:35:23
Message: <3c7505ab@news.povray.org>
Grey Knight <s16### [at] namtarqubacuk> wrote:
: Actually, since splines are nice and smooth (after all, that's what
: they're there for!), if you make sure vlength(T) is very small (say
: 1e-10 for example), then this method should give you a very good
: approximation to the tangent; easily good enough for any purpose I can
: think of anyway.

  Beware of possible floating point inaccuracies with such small numbers.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Warp
Subject: Re: How to get spline tangent
Date: 21 Feb 2002 09:35:55
Message: <3c7505cb@news.povray.org>
Of course the more mathematically oriented people would like an exact
result instead of just an approximation... :)

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Warp
Subject: Re: How to get spline tangent
Date: 21 Feb 2002 09:39:54
Message: <3c7506ba@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
:   Of course the more mathematically oriented people would like an exact
: result instead of just an approximation... :)

  By the way, I think that this gives a better approximation:

  Suppose that we want to calculate the tangent of the spline at the
time value T.
  Take a small value, which we will call Epsilon (could be for example
10e-5 or something similar).
  The approximated tangent will be:

  TangentVector = Spline(T+Epsilon)-Spline(T-Epsilon)

  This given a better approximation because the resulting vector will be
closer to the true tangent, and could even be exactly the tangent.
'Spline(T+Epsilon)-Spline(T)', however, can never be exactly the tangent.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Disnel
Subject: Re: How to get spline tangent
Date: 21 Feb 2002 12:23:07
Message: <3C752D2A.9030503@itam.cas.cz>
Thank to all, you are right and I think, that it will be sufficient.

But I wanted to ask if there is some way to get exact tangent (another 
than reimplementing POV spline in POV language, of course ;-) The answer 
is probably not.

Regards

Disnel


Post a reply to this message

From: Grey Knight
Subject: Re: How to get spline tangent
Date: 21 Feb 2002 13:37:58
Message: <3C753E7B.A78CC2@namtar.qub.ac.uk>
I'm gonna reply to all your posts in one go, since you were carrying on
such a little conversation with yourself ;)

Warp wrote:
> Beware of possible floating point inaccuracies with such small numbers.
This is why your method is better (because the tangential vector is
longer :. less scope for FPI)

Warp wrote:
>   Of course the more mathematically oriented people would like an exact
> result instead of just an approximation... :)
Well, the only limit on the accuracy is that imposed by the system
itself (specifically FPI as you pointed out), so a more accurate
solution would probably have no further benefit anyway?

Warp wrote:
>   By the way, I think that this gives a better approximation:
Yeah, it does.

>   Suppose that we want to calculate the tangent of the spline at the
> time value T.
Which we do. ;P

>   Take a small value, which we will call Epsilon (could be for example
> 10e-5 or something similar).
> My constants.inc has EPSILON=1e-7, but of course it doesn't matter so long as it's
small.
> 
>   This given a better approximation because the resulting vector will be
> closer to the true tangent, and could even be exactly the tangent.
> 'Spline(T+Epsilon)-Spline(T)', however, can never be exactly the tangent.
Yeah, this method *is* better. I think the only reason I thought of the
other one was because the pure mathematical definition of the tangent
comes from that (with EPSILON -> 0), which makes the maths easier.
Of course, we can't use EPSILON=0 here, so obviously your method works
better.

-- 
signature{
  "Grey Knight" contact{ email "gre### [at] yahoocom" }
  site_of_week{ url "http://digilander.iol.it/jrgpov" }
}


Post a reply to this message

From: Grey Knight
Subject: Re: How to get spline tangent
Date: 21 Feb 2002 13:40:00
Message: <3C753EF5.5D86488B@namtar.qub.ac.uk>
Disnel wrote:
> ...
> But I wanted to ask if there is some way to get exact tangent
> ...

But this method returns values about as close to the exact tangent as
you could probably get in a computer anyway, so FAPP it *is* exact.

-- 
signature{
  "Grey Knight" contact{ email "gre### [at] yahoocom" }
  site_of_week{ url "http://digilander.iol.it/jrgpov" }
}


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: How to get spline tangent
Date: 21 Feb 2002 18:32:08
Message: <3C7582F0.903B5AB1@hotmail.com>
Grey Knight wrote:
>...
> so FAPP it *is* exact.

I guess you mean: For All Practical POV Purposes  ;)


Tor Olav


Post a reply to this message

From: Grey Knight
Subject: Re: How to get spline tangent
Date: 22 Feb 2002 05:01:02
Message: <3C7616D3.E8780A40@namtar.qub.ac.uk>
Tor Olav Kristensen wrote:
> 
> Grey Knight wrote:
> >...
> > so FAPP it *is* exact.
> I guess you mean: For All Practical POV Purposes  ;)
> Tor Olav

What other type of purpose is there? ;)

-- 
signature{
  "Grey Knight" contact{ email "gre### [at] yahoocom" }
  site_of_week{ url "http://digilander.iol.it/jrgpov" }
}


Post a reply to this message

From:
Subject: Re: How to get spline tangent
Date: 22 Feb 2002 05:08:12
Message: <gv5c7u0a3ai9m7sjsfrf8ks9p51o8qv0sn@4ax.com>
On Fri, 22 Feb 2002 10:00:51 +0000, Grey Knight <s16### [at] namtarqubacuk>
wrote:
> > I guess you mean: For All Practical POV Purposes  ;)
>
> What other type of purpose is there? ;)

Of course Scientifical/Theoretical POV Purposes ;)

ABX


Post a reply to this message

From: Josh English
Subject: Re: How to get spline tangent
Date: 22 Feb 2002 15:25:58
Message: <3C76A953.114C3838@spiritone.com>
I tried this with my bezier curve include file. Of course you just need
to find the derivitave of the spline function, it should give you the
tangent direction. Of course this is a lot harder than it sounds. I've
wasted half a ream calculating the derivitave of a bezier function.

Josh English
eng### [at] spiritonecom
http://www.spiritone.com/~english

Disnel wrote:
> 
> Thank to all, you are right and I think, that it will be sufficient.
> 
> But I wanted to ask if there is some way to get exact tangent (another
> than reimplementing POV spline in POV language, of course ;-) The answer
> is probably not.
> 
> Regards
> 
> Disnel


Post a reply to this message

From: Gleb
Subject: Re: How to get spline tangent
Date: 24 Feb 2002 14:18:29
Message: <3c793c85$1@news.povray.org>
POV is powerful enough for getting all the piecewise polynomial coefficients
from declared spline. For cubic spline we can calculate four points on every
time interval, get all four coefficients from this 4x4 linear system and
then get exact tangent function for every time interval. These coefficients
can be used outside POV.

Of course, this will be approximation too, because of limited accuracy. The
best way is just to find out these figures directly from original set of
points, but it seems that in this case we need to solve linear systems of
higher order, than 4(still possible with SDL, however).







"Disnel" <dis### [at] itamcascz> wrote in message
news:3C7### [at] itamcascz...
>
> Thank to all, you are right and I think, that it will be sufficient.
>
> But I wanted to ask if there is some way to get exact tangent (another
> than reimplementing POV spline in POV language, of course ;-) The answer
> is probably not.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: How to get spline tangent
Date: 24 Feb 2002 18:29:39
Message: <3C7976C9.AD9DA3D8@hotmail.com>
Gleb wrote:
>...
> Of course, this will be approximation too, because of limited accuracy. The
> best way is just to find out these figures directly from original set of
> points, but it seems that in this case we need to solve linear systems of
> higher order, than 4(still possible with SDL, however).
>...

I have some (slow) POV macros that will solve
linear systems with N equations and N unknowns.


Tor Olav


Post a reply to this message

From: Gleb
Subject: Re: How to get spline tangent
Date: 25 Feb 2002 07:44:36
Message: <3c7a31b4@news.povray.org>
"Tor Olav Kristensen" <tor### [at] hotmailcom> wrote in message
news:3C7976C9.AD9DA3D8@hotmail.com...
>
> I have some (slow) POV macros that will solve
> linear systems with N equations and N unknowns.
>

In this particular case speed is not so important,
because all calculations should be done only once for given spline.

Gleb


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: How to get spline tangent
Date: 25 Feb 2002 19:52:27
Message: <3C7ADBB9.942767EE@hotmail.com>
Gleb wrote:
> 
> "Tor Olav Kristensen" <tor### [at] hotmailcom> wrote in message
> news:3C7976C9.AD9DA3D8@hotmail.com...
> >
> > I have some (slow) POV macros that will solve
> > linear systems with N equations and N unknowns.
> >
> 
> In this particular case speed is not so important,
> because all calculations should be done only once for given spline.

Ok then -

If there's anyone that is working out these
tangent functions, just tell me if you want
me to post some of my matrix macros.


Tor Olav


Post a reply to this message

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