|
![](/i/fill.gif) |
In article <40291025$1@news.povray.org>,
"Tim Nikias v2.0" <tim.nikias (@) nolights.de> wrote:
> > simplified:
> >
> > 3*(P2 - P1 + (P1 - 2*P2 - P3)*2*t + (P2*3 + P3*3 + P4 - P1)*t^2)
>
> Simplified? ;-)
A simplified version of:
P1*3*(1 - t)^2*(-1) + P2*3*(2*(1 - t)*(-1)*t + (1 - t)^2) - P3*3*(2*t*(1
- t) - t^2) + P4*3*t^2
> Uhm... Well, Sascha's approach worked quite well (now I just have to get it
> work with more than one segment, but that's not the difficult part). To be
> honest, I didn't really understand where you went with the derivative. Was a
> long time ago that I had algebra in school, so I can't check if it's correct
> or not, and since it looked so complicated, I took a first go with Sascha's
> formula.
Well, as far as I can tell, the second method Sascha gave is identical
to the one I gave, though expressed a bit differently. I'm not sure
what's going on with the first method...but I think it's mathematically
equivalent, just a shortcut. I'm going to have to look at it further...
> Still, enlighten me about this part:
>
> > The tangent line at point p would be:
> > x*f'(p) - p*f'(p) + f(p)
> > where f() is the spline function, and f'() is its derivative.
>
> So, instead of using t, you want me to put a point into a function? What's
> x? I got a little confused here and am not really sure what you were trying
> to tell me. Thanks for the effort though!
Instead of using t for what?
You asked for a tangent line to a spline segment and gave an equation
for that segment. f() is that equation, f'() is the derivative I gave.
The equation I gave is the equation for a line tangent to the spline at
t == p, with x being the horizontal axis. x*f'(p) - p*f'(p) + f(p) gives
a line tangent to f() at f(p).
To find a line tangent to a curve at a given point, you need to know the
slope of the curve at that point. The slope is just the rate of change,
the first derivative of the function. x*f'(p) is a line through (0, 0)
parallel to the tangent line. Subtract p*f'(p) so it equals 0 at (p, 0),
under the desired point, and add f(p) to bring it up to the curve at
that point. The final equation would be:
x*f'(p) - p*f'(p) + f(p) == (x - p)*f'(p) + f(p) ==
(x - p)*3*(P2 - P1 + (P1 - 2*P2 - P3)*2*p + (P2*3 + P3*3 + P4 -
P1)*p^2)) + P1*(1 - p)^3 + P2*3*(1 - p)^2*p - P3*3*p^2*(1 - p) + P4*p^3
Where p is the point along the spline where you want the tangent line.
The result of this equation is the height at x of the line tangent to
the spline at p.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tag povray org>
http://tag.povray.org/
Post a reply to this message
|
![](/i/fill.gif) |