POV-Ray : Newsgroups : povray.advanced-users : Some math aid required... : Re: Some math aid required... Server Time
28 Jul 2024 20:22:34 EDT (-0400)
  Re: Some math aid required...  
From: Christopher James Huff
Date: 10 Feb 2004 08:59:45
Message: <cjameshuff-9FB9E9.09000610022004@news.povray.org>
In article <4028beda$1@news.povray.org>,
 "Tim Nikias v2.0" <tim.nikias (@) nolights.de> wrote:

> so, I've got the following formula to calculate Bezier-Splines:
> 
> Point_1*pow(1-Mover,3)+
> Point_2*3*pow(1-Mover,2)*Mover-
> Point_3*3*pow(Mover,2)*(1-Mover)+
> Point_4*pow(Mover,3)

> Anyways, I need to calculate the direction/tangent of the spline at any
> given position. I'm somehow stuck, probably because my head is still filled
> with the last exam I just wrote. Any help, or links?

Okay...your function is this, P1..P4 being the spline values, t being 
the spline time parameter:

P1*(1 - t)^3 +
P2*3*(1 - t)^2*t -
P3*3*t^2*(1 - t) +
P4*t^3

The slope of the tangent is simply the derivative, the rate of change at 
the given point. Unless I've screwed up the math somewhere, that would 
be:

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

simplified:

3*(P2 - P1 + (P1 - 2*P2 - P3)*2*t + (P2*3 + P3*3 + P4 - P1)*t^2)

(somebody want to check that?)

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.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

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