realbasic-nug
[Top] [All Lists]

Re: Need help from a math specialist!

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Need help from a math specialist!
From: Ryan Dary <nug at ryandary dot com>
Date: Sun, 30 Sep 2007 13:52:33 -0700
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <33cbfa100709282137k5fca4610x81292edf97eb37d2 at mail dot gmail dot com>

Lars Jensen wrote:
>> Okay, I think I've narrowed it down.  Let's say that I have a Bezier
>> curve in point data.  Is there a mathematical way to determine what the
>> Y would be given an X coordinate?
> 
> Yes. But why complicate your life with Beziers when a simple trig
> function will do the job?
> 

For now, I may use the advice of skipping the Beziers if that proves to 
be too difficult, but ultimately I'd like precise control over the curve 
so that I can really customize the animation.  In any animation program 
I've used, 2D or 3D, they all provide a curve editor which I imagine is 
a Bezier curve.  I just wanted to be able to provide such an editor 
someday in the future.

> If you want to move something from position p = [0,P] over time t =
> [0,T], easing in and easing out, start with a cosine function. It has
> a nice S-curve going from 0 to pi/2. You just need to flip the S-curve
> vertically, move it so that it starts at the origin, and scale it in
> position and time so that p(T) = P:
> 
>   p = cos(t)                                      <- runs from p =
> [1,-1] over t = [0,pi/2]
>   p = -cos(t)                                     <- flipped
> vertically, now runs from p = [-1,1] over t = [0,pi/2]
>   p = 1-cos(t)                                   <- moved up to start
> at origin, now runs from p = [0,2] vertically over t = [0,pi/2]
>   p = P * (1-cos(t)) / 2                       <- scaled to fit P, now
> runs from p = [0,P] vertically over t = [0,pi/2]
>   p = P * (1-cos( (t/T) * pi/2 )) / 2       <- scaled to fit T, now
> runs from p = [0,P] over t = [0,T]
> 
> There's your formula. The next step would be to generalize it for p =
> [P1,P2] and t = [T1,T2].
> 
> lj
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>