Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbie: easing in and out of motion

0 views
Skip to first unread message

h

unread,
May 21, 2005, 4:51:08 PM5/21/05
to
Hi,

Not sure if this is the right NG but here goes:

I'm programming stuff in Flash, using an actionscript function, called each
frame (1/50th second), to calculate the new positions of my objects. As an
example of the sort of thing I'm talking about, I've stuck a quick movie up
here --> http://howiem.com/motion_question/(requires flash 7, sorry)

I have a quick and cheesy way of achieving an ease out of a move but I'm a
bit tired of it and want to spruce it up a bit. Currently I calculate an
object's new position by doing:

[pseudo]
currentX = currentX + ( ( targetX - currentX ) / 5 )
myBlock._x = currentX

... and repeating for Y, every frame. Whenever I want an object to move, I
just change its targetX, and the code above repeatedly moves the block a
fifth of the way to its new target. It's nicer than a constant-speed move,
but not much. What I'd really like is a way of having the move ease up to
speed and back down again as it approaches its target.

I've tried using a sine wave to control the speed, but though it allowed me
to ease into and out of the motions I struggled to find a way to change the
shape of the curve. I'd like to be able to limit the speed, for example.

Are there any algorithms already created for this sort of thing? Google
doesn't seem to be liking my terms, and I've spent too long already trying
to finetune this part of my knowledge.

Any suggestions / pointers appreciated.

Thanks,

h


h

unread,
May 21, 2005, 4:52:34 PM5/21/05
to
Sorry, should have been http://howiem.com/motion_question/ .

h


Jerzy Karczmarczuk

unread,
May 21, 2005, 6:08:11 PM5/21/05
to
"h" wrote
> I'm programming stuff in Flash, using an actionscript function, called each
> frame (1/50th second), to calculate the new positions of my objects.

> I have a quick and cheesy way of achieving an ease out of a move but I'm a

> bit tired of it and want to spruce it up a bit. Currently I calculate an
> object's new position by doing:
>
> [pseudo]
> currentX = currentX + ( ( targetX - currentX ) / 5 )
> myBlock._x = currentX
>
> ... and repeating for Y, every frame. Whenever I want an object to move, I
> just change its targetX, and the code above repeatedly moves the block a
> fifth of the way to its new target. It's nicer than a constant-speed move,
> but not much. What I'd really like is a way of having the move ease up to
> speed and back down again as it approaches its target.
>
> I've tried using a sine wave to control the speed, but though it allowed me
> to ease into and out of the motions I struggled to find a way to change the
> shape of the curve. I'd like to be able to limit the speed, for example.
>
> Are there any algorithms already created for this sort of thing?

Usually one uses various splines, Hermite approximation, etc., it *is*
an establish domain. You will find a lot of information in tutorials
devoted to animation, e.g. the discussion of IPO curves for Blender.

You may start with simple Hermite, a cubic curve p(t) such that
p(0)=p0 and p(1)=p1. Its [vectorial] representation with the aid
of Bernstein polynomials (which are there to render your life easier,
not more difficult) is

p(t) = a*(1-t)^3 + 3b(1-t)^2*t + 3c(1-t)*t^2 + d*t^3.

You see immediately that a=p0 and d=p1. They are points in 2D or 3D.
Compute the speed, the derivative:

p'(t) = 3{-a(1-t)^2 + b[-2(1-t)*t + (1-t)^2] + c[-t^2+2(1-t)*t] + d*t^2

and if you wish that it starts and ends smoothly : p'(0)=p'(1)=0,
then

b=a; c=d

and that's it. No more free parameters. If you want to control your
curve better, then either use a higher order Bézier, which is not
so good, or split your interval in two or more sub-intervals.

Say, split in two. The first starts with speed zero, but the object
arrives with a speed you wish; you will have to solve the equations
for the parameters from the form above. The same for the second
segment, where the object starts with previous speed (continuity),
and slows down to zero.

Not enough? Then more subdivisions, and more data you must provide in
order to fix the params.

Jerzy Karczmarczuk


--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

Mike D Sutton

unread,
May 22, 2005, 6:10:17 AM5/22/05
to

Basically what you're after there is cosine interpolation, effectively using Linear interpolation but with a cosine
function to determine position. Linear interpolation looks something like this:

Value = ((B - A) * P) + A

Where A and B are your start and end positions respectively in whichever axis you're moving, and P is the position
within that line between 0 and 1. If you plug that into your actionscript then you should see that the block moves from
one position to the other at a constant speed over the duration of the animation.
By pushing P through a Cosine function it simply changes the position within the 'line' at any time with the effect of
acceleration and deceleration (or in flash terms easing in and easing out but at the same time unlike flash's tweens
which support only one of the other on a single movement.)
The cosine position can be worked out using something like this:

CP = 1 - ((cos(P * Pi) + 1) * 0.5)

Alternatively if you already have a Linear function then you can simply reverse the two input positions and avoid the 1-
at the start:

***
Linear(A, B, P) { Result = ((B - A) * P) + A }
Cosine(A, B, P) { Result = Linear(B, A, (cos(P * Pi) + 1) * 0.5) }
***

By using different parts of the Cosine curve you can also simulate just acceleration or deceleration on their own, you
can also combine Cosine and Linear functions to effectively 'flatten out' the curve towards linear momentum.
Whilst this may not be technically correct it should be enough for you to accomplish what you're after.
Hope this helps,

Mike


Just d' FAQs

unread,
May 22, 2005, 6:51:55 AM5/22/05
to
On Sat, 21 May 2005 20:51:08 GMT, "h" <h@@at@@howiem.com> wrote:
>Not sure if this is the right NG but here goes:
>
>I'm programming stuff in Flash, using an actionscript function, called each
>frame (1/50th second), to calculate the new positions of my objects. As an
>example of the sort of thing I'm talking about, I've stuck a quick movie up
>here --> http://howiem.com/motion_question/(requires flash 7, sorry)

We're probably not the best newsgroup. A better choice might be

<news:alt.macromedia.flash>

A quick search of the Web turns up many hits for Flash ease-in and
ease-out, including the fact that MX has a slider for it.

The typical computer graphics methods may not be available; but SVG,
an open W3C standard, does have a timeline control, albeit one that's
a pain to implement.

Suppose position is a function of time. To control timing easily, add
a layer of indirection. That is, make x a function of s, and make s a
function of time t. Then use whatever warp your heart desires. (Yes,
let's do the time warp again.)

Ease, whether in or out, is achieved by any warp function with a zero
derivative at the desired end. We also insist that it be monotonic
increasing from 0 to 1. That still leaves a wide variety of choices.

Surely the most popular is a cubic, like a Hermite basis function. For
example, the Bezier curve defined by 0, 0, 1, 1 has both ease-in and
ease-out. As a polynomial, it's 3(1-t)t^2 + t^3, or 3t^2 - 2t^3. Since
its first derivative is 6t-6t^2, at t=0 both the value and derivative
are 0, and at t=1 the value is 1 and the derivative is again 0.

A skilled animator with a trained eye might want even more smoothness
than a cubic can provide. For example, a quintic (degree 5) might be
used to make not only the velocity, but also the acceleration, zero.
In Bezier form, this is controls 0, 0, 0, 1, 1, 1 for in-and-out ease.

h

unread,
May 24, 2005, 12:52:26 PM5/24/05
to
"Jerzy Karczmarczuk" <kar...@info.unicaen.fr> wrote ...

>> Are there any algorithms already created for this sort of thing?
>
> Usually one uses various splines, Hermite approximation, etc., it *is*
> an establish domain. You will find a lot of information in tutorials
> devoted to animation, e.g. the discussion of IPO curves for Blender.
>
> You may start with simple Hermite, a cubic curve p(t) such that
> p(0)=p0 and p(1)=p1. Its [vectorial] representation with the aid
> of Bernstein polynomials (which are there to render your life easier,
> not more difficult) is
>
> p(t) = a*(1-t)^3 + 3b(1-t)^2*t + 3c(1-t)*t^2 + d*t^3.
>
> You see immediately that a=p0 and d=p1. They are points in 2D or 3D.


(the noise you hear is me trying to remove the years of junk sitting on top
of my maths knowledge, I couldn't see anything immediately and even now it's
foggy :)


> Compute the speed, the derivative:
>
> p'(t) = 3{-a(1-t)^2 + b[-2(1-t)*t + (1-t)^2] + c[-t^2+2(1-t)*t] + d*t^2


My apologies - my maths is *really* rusty - but I'm a little lost here; I'm
not sure how to interpret the square brackets, plus I'm not clear on where
the implied end-brace is. Is this correct:

p'(t) = 3(-a(1-t)^2) + b(-2(1-t)*t + (1-t)^2) + c(-t^2+2(1-t)*t) +
d*t^2 ?

Having said that I don't actually need to calculate p'(t) as p(t) is
sufficient for my needs.


> and if you wish that it starts and ends smoothly : p'(0)=p'(1)=0,
> then
>
> b=a; c=d
>
> and that's it. No more free parameters.


Thank you Jerzy, I will investigate and experiment with this - you've given
me some clear directions to look in. I can see this is going to be many more
lines of code (and much more optimisation necessary) than my nice simple

repeat each frame {
currentX = currentX + ( (targetcurrentX - currentX)/divider )
}

!

Many thanks,

h
--


Jerzy Karczmarczuk

unread,
May 24, 2005, 1:59:58 PM5/24/05
to
"h" (what is your place in the establishment where "M" and "Q" help
"B" to save the world?) comments my dense suggestions concerning
the interpolation curve with smooth starting and ending

> > You may start with simple Hermite, a cubic curve p(t) such that
> > p(0)=p0 and p(1)=p1. Its [vectorial] representation with the aid

> > of Bernstein polynomials ... is
> >
> > p(t) = a*(1-t)^3 + 3b(1-t)^2*t + 3c(1-t)*t^2 + d*t^3. (###)
> >
> > ...=> t a=p0 and d=p1. ...

> (the noise you hear is me trying to remove the years of junk sitting on top
> of my maths knowledge, I couldn't see anything immediately and even now it's
> foggy :)

Well, I AM sorry, I tried to be as compact as possible, which often
leads to a communication disaster... What I wanted to say is that
typically one searches for a *vector* p(t), such that it is a
simple polynomial in t, assuming that t varies between 0 and 1. In
general you might write thus

p(t) = k + l*t + m*t^2 + n*t^3,

where (k,l,m,n) are constant coefficients, vectors in the same space as
p(t). Till now OK?

Your constraints: p(0)=p0, p(1)=p1, and the constraints on speed, lead
immediately to a system of equations which is ugly, all the coeffs.
are combined.

So I proposed the representation known as Hermite/Bézier.

PLEASE LOOK-UP on the Web the keywords: Hermite interpolation, Bézier
interpolation, Bézier curves, etc. Splitting/rearranging the terms,
without changing anything gives you (###) above, with another set
of constant coeffs, easier to put in correspondence with the
requirements that p(0)p0; p(1)=p1, p'(0)=p'(1)=0.

Here a=k; ... -a + 3b - 3c + d = n.

> My apologies - my maths is *really* rusty - but I'm a little lost here; I'm
> not sure how to interpret the square brackets, plus I'm not clear on where
> the implied end-brace is. Is this correct:

... not exactly, see below.

> Having said that I don't actually need to calculate p'(t) as p(t) is
> sufficient for my needs.

You NEED the equation for p' to fix the coefficients. The formula is

p'(t) =
3(-a(1-t)^2 + b(-2(1-t)*t + (1-t)^2) + c(-t^2+2(1-t)*t) + d*t^2)

The brackets, and braces are equivalent to parens. I wanted more
legibility, and I forgot to close the opening brace... But it is just
the derivative of (###).

> > and if you wish that it starts and ends smoothly : p'(0)=p'(1)=0,
> > then
> >
> > b=a; c=d
> >
> > and that's it. No more free parameters.

So, if you now change "p" into current "x" you will get what you wish,
more or less:

for each t between 0 and 1 (ev. parametrized by the frame number)
x = x0*(1-t)^2*(1 + 2t) + x1*(3 - 2t)*t^2

and that's it. Of course you can represent it differently, for example
compute incrementally Dx = x(t+Dt) - x(t), etc., but this is another
class.

Bon courage.

h

unread,
May 24, 2005, 2:05:55 PM5/24/05
to
"Mike D Sutton" <ED...@mvps.org> wrote in message
news:42905a86$0$22628$da0f...@news.zen.co.uk...

> Basically what you're after there is cosine interpolation, effectively
> using Linear interpolation but with a cosine
> function to determine position. <snip>

> ***
> Linear(A, B, P) { Result = ((B - A) * P) + A }
> Cosine(A, B, P) { Result = Linear(B, A, (cos(P * Pi) + 1) * 0.5) }
> ***
>
> By using different parts of the Cosine curve you can also simulate just
> acceleration or deceleration on their own, you
> can also combine Cosine and Linear functions to effectively 'flatten out'
> the curve towards linear momentum.

I can see how you could just average the Cosine and Linear functions if you
want to flatten the curve, but what if you want to do the opposite, making
the acceleration smoother at the ends of the motion?

Thanks Mike, this is a nice ease with minimum code but it's about where I
got to last time; I found it very hard to slow the start and end of the
motion without it breaking (missing target, erratic movement etc).

Your email prompted me to re-write my animation code to pass the
interpolation job to a function f(t) where t goes from 0 to 1 - much more
elegant than my hotchpotch methods.

Thanks again,

h
--


h

unread,
May 24, 2005, 2:31:00 PM5/24/05
to
"Just d' FAQs" <nobod...@mac.com> wrote in message
news:3bn091d65cj7u2621...@4ax.com...

> On Sat, 21 May 2005 20:51:08 GMT, "h" <h@@at@@howiem.com> wrote:
>>Not sure if this is the right NG but here goes:
>>
>>I'm programming stuff in Flash, using an actionscript function, called
>>each
>>frame (1/50th second), to calculate the new positions of my objects. As an
>>example of the sort of thing I'm talking about, I've stuck a quick movie
>>up
>>here --> http://howiem.com/motion_question/(requires flash 7, sorry)
>
> We're probably not the best newsgroup. A better choice might be
>
> <news:alt.macromedia.flash>
>
> A quick search of the Web turns up many hits for Flash ease-in and
> ease-out, including the fact that MX has a slider for it.

Unfortunately Flash development sits across two camps - creating animations
by using keyframes on a timeline (where Flash's Ease slider comes into play)
or creating animations programmatically, using ActionScript (similar to C++)
to alter your objects' coordinates over time. I'm stuggling with the code
side :)

> Suppose position is a function of time. To control timing easily, add
> a layer of indirection. That is, make x a function of s, and make s a
> function of time t. Then use whatever warp your heart desires. (Yes,
> let's do the time warp again.)

I've just learnt this from Mr Sutton's kind response in this very thread -
it does make it so much easier to play with different methods.

> Ease, whether in or out, is achieved by any warp function with a zero
> derivative at the desired end. We also insist that it be monotonic
> increasing from 0 to 1. That still leaves a wide variety of choices.
>
> Surely the most popular is a cubic, like a Hermite basis function. For
> example, the Bezier curve defined by 0, 0, 1, 1 has both ease-in and
> ease-out. As a polynomial, it's 3(1-t)t^2 + t^3, or 3t^2 - 2t^3. Since
> its first derivative is 6t-6t^2, at t=0 both the value and derivative
> are 0, and at t=1 the value is 1 and the derivative is again 0.

f(t) = 3t^2 - 2t^3 was very easy to try out, and looks similar in motion to
the cosine approach, possibly a little smoother.

> A skilled animator with a trained eye might want even more smoothness
> than a cubic can provide. For example, a quintic (degree 5) might be
> used to make not only the velocity, but also the acceleration, zero.
> In Bezier form, this is controls 0, 0, 0, 1, 1, 1 for in-and-out ease.

I've looked up quintic functions but am bewildered by the number of
different equations thrown at me - can you give me this curve in f(t) =
form?

Many thanks for the explanations,

h
--


Just d' FAQs

unread,
May 24, 2005, 5:28:20 PM5/24/05
to
On Tue, 24 May 2005 18:31:00 GMT, "h" <h@@at@@howiem.com> wrote:
>> A skilled animator with a trained eye might want even more smoothness
>> than a cubic can provide. For example, a quintic (degree 5) might be
>> used to make not only the velocity, but also the acceleration, zero.
>> In Bezier form, this is controls 0, 0, 0, 1, 1, 1 for in-and-out ease.
>
>I've looked up quintic functions but am bewildered by the number of
>different equations thrown at me - can you give me this curve in f(t) =
>form?

Even if you are determined to write your own Flash code, the Web is
full of examples and dedicated newsgroups.

But we'll take this opportunity to review polynomials and Bezier form
for all the readers who can use it.

Warning! This is a *very* long answer to a very short question. Skip
to the end if the theory is of no interest.


POLYNOMIALS
We begin with a set of numbers, often real numbers in applications,
but complex numbers for the serious mathematician. Our main demand is
that the numbers form an algebraic "ring", which means that we can
add, subtract, and multiply, that we have 0 and 1 (identities for
addition and multiplication), and that multiplication distributes over
addition. Notice that we do *not* expect division, so we are happy to
work with rational numbers and even mere integers. We'll see a more
intriguing possibility shortly.

Now we throw in an indeterminate, x being the popular choice. So where
before we had, say, 1+1=2, now we have x+x=2x, and x^3 (which does not
reduce), and so on. If our numbers were reals, R, we would denote the
new beasts R[x], for real polynomials in x. It makes no difference if
we call the indeterminant x or u or whatever; the results look alike.

The intriguing fact is that R[u] is itself a ring. That means we can
use real polynomials in x as our "numbers", and build a bigger ring
using y as indeterminate, R[u][v]. And so on. It matters little that
we introduce u then v; the ring R[u][v] is behaviorally identical to
the ring R[v][u]. We say they are "isomorphic", and introduce a ring
to blur the difference, R[u,v].

When we look at a specific polynomial, such as 5-2u+8u^3, we find a
finite number of "terms", each having our indeterminant x raised to
some power. The highest power is called the "degree"; in this example
the degree is 3. (For polynomials in multiple indeterminates, we can
have a different degree in each, and we also have total degree, which
is the highest sum of powers in a term.) The polynomial u^2 clearly
has degree 2, but often we find it convenient to say "polynomials of
degree 3" when we really want to include lower degrees like this as
well. (Properly we should say maximum degree.) Notice that addition
and subtraction cannot raise the degree of a polynomial, but they can
lower it.


POLYNOMIAL FUNCTIONS
We have defined polynomials as a kind of pumped up number, but that's
not the way we most often use them. We use them as functions, where we
send a number in and get a number out. For that, we define evaluation.

Consider 5-2u+8u^3. If we substitute a number, such as 3, for u, this
collapses to basic arithmetic, giving 5-2*3+8*3^3, or the number 215.
This is what we mean by "evaluation", here at 3. And this allows us to
view any polynomial as a function.


POLYNOMIAL VECTORS
Actually this should be titled "polynomial modules", but nevermind. We
noted that if we limit the degree, we get a closed system by excluding
multiplication. That's more drastic that we need, because we can allow
our base numbers to multiply a polynomial without raising its degree.

This should start to sound eerily familiar. We have objects we can sum
and scale; that's vectors! At least, it is if the numbers form a field
(allowing division, with commutative multiplication); otherwise the
correct term is not "vector space" but "module". It's a minor quibble
for our purposes.

Isn't mathematics fun? Once your head stops spinning? ;-)

So, we can look at real polynomials of (maximum) degree 2 as vectors.
The similarity is striking once we study a little.

7 + 2u - u^2 3 - u + 5u^2
(7, 2, -1 ) (3, -1, 5 )

Summing these two polynomials is exactly the same as summing the two
vectors written beneath them. So is scaling.

Nor are we limited to degree 2. If we use polynomials of (maximum)
degree n, we get a vector space of dimension n+1.


POLYNOMIAL BASIS
In dealing with vectors, we are accustomed to working with a basis, a
minimal list of vectors that we can scale and sum to create all other
vectors. Our standard 3D basis is the unit vectors in the positive x,
y, and z directions.

(1,0,0) (0,1,0) (0,0,1)

The analogous basis for polynomials is the monomial basis, extended as
far as we need. For degree 3, this would be as follows.

1 u u^2 u^3


BERNSTEIN-BEZIER BASIS
This family is not so obvious, but it certainly is useful! We'll just
list the bases for smaller degrees, then give the general rule.

degree 0: 1
degree 1: (1-u) u
degree 2: (1-u)^2 2(1-u)u u^2
degree 3: (1-u)^3 3(1-u)^2 u 3(1-u)u^2 u^3
degree 4: (1-u)^4 4(1-u)^3 u 6(1-u)^2 u^2 4(1-u)u^3 u^4

The pattern should be apparent, except for the numbers in front. These
are simple, too; they're just combinatoric. Consider the 6 we see in
the middle of the degree 4 list, multiplying the term ending in u^2.
It is the number of different sets of 2 items we can choose from a set
of 4 items, the "binomial coefficient" 4?2.

<http://en.wikipedia.org/wiki/Binomial_coefficient>

Using n?k = n!/((n-k)! k!), we can now define the basis polynomial for
degree n at the k-th position in the list.

BB(n,k)[u] = n?k (1-u)^(n-k) u^k

For example, the degree 5 coefficients are 1, 5, 10, 10, 5, 1.

This family of bases has many lovely properties. For example, the sum
of the polynomials for a given degree is always 1.

degree 2: (1-u)^2 + 2(1-u)u + u^2 = 1

This is pivotal for their role in computer graphics.


BEZIER CURVES
A weighted sum of points, where the weights themselves sum to 1, is an
"affine combination". The important thing for us here is that it has a
well-defined geometric meaning, unlike combinations with unconstrained
weights. Affine combinations are to points as linear combinations are
to vectors.

And now it all comes together. Pick any four points, in a plane or in
3D space; call them P0, P1, P2, P3. Weight Pk by BB(4,k)[u], and sum.
For any value of u we have an affine comination, and thus a point. We
have thus defined a curve, mapping real values u to points along the
curve. Restricting u to the unit interval [0..1], this is, in fact, a
cubic Bezier curve, with the Pk as its control points.

The choice of degree and of dimension is whatever we like. A degree 2
curve would need only 3 points and associated basis polynomials. And
we can even define a 1D "curve" confined to the real line.


REAL EASE
The controls given for the ease time warp were 0, 0, 0, 1, 1, 1. This
is a degree 5 function on the real line. In other words, it is really
just a degree 5 polynomial function, which we can now make explicit
using the Bernstein-Bezier basis polynomials. Using t instead of u as
our indeterminate, and calling the time-warp function s, we have:

s(t) = 0 * (1-t)^5
+ 0 * 5(1-t)^4 t
+ 0 * 10(1-t)^3 t^2
+ 1 * 10(1-t)^2 t^3
+ 1 * 5(1-t) t^4
+ 1 * t^5

= 10 t^3 - 15 t^4 + 6 t^5


HORNER'S RULE
For both speed and floating point accuracy, the preferred way to get
the value of a polynomial is to use Horner's rule. In this case, that
means we rewrite our polynomial in nested form, as

s(t) = ((6 t - 15) t + 10) t^3

Bob

unread,
May 25, 2005, 10:52:09 AM5/25/05
to
Your explanation brought tears to my eyes. "The sum of the
[Bernstein-Bezier] polynomials for a given degree is always 1", was
especially touching.

Just d' FAQs

unread,
May 25, 2005, 3:56:52 PM5/25/05
to

Well thanks. Your kind words have helped me fulfill a lifelong dream.
I always suspected technical writing could achieve real pathos! ;-)

<http://dictionary.reference.com/search?q=pathos>

But do you think the explanation was long enough? :-)

Bob

unread,
May 25, 2005, 5:11:53 PM5/25/05
to
I was only half joking about the pathos. Your explanation of Bezier
form WAS a moving experience for me. After I'd posted, it occurred to
me you might think I was being sarcastic. I assure you, it was meant
as praise. As for the length, well ... even great writers can use an
editor. Seriously, you covered a lot of ground succinctly. Thanks!

Kalle Rutanen

unread,
May 25, 2005, 6:56:05 PM5/25/05
to
> BB(n,k)[u] = n?k (1-u)^(n-k) u^k
>
> For example, the degree 5 coefficients are 1, 5, 10, 10, 5, 1.
>
> This family of bases has many lovely properties. For example, the sum
> of the polynomials for a given degree is always 1.
>
> degree 2: (1-u)^2 + 2(1-u)u + u^2 = 1

In general, this can be seen nicely from the binomial theorem:

(x + a)^n = sum[k=0..n](n?k * x^(n-k) * a^k)

Using it:

1 = 1^n = (1 - u + u)^n = ((1 - u) + u)^n = sum[k=0..n](n?k (1-u)^(n-k) u^k)
= sum[k=0..n](BB(n,k)[u])

Just, you are doing great work.


Just d' FAQs

unread,
May 25, 2005, 11:00:52 PM5/25/05
to
On Thu, 26 May 2005 01:56:05 +0300, "Kalle Rutanen"
<kalle_...@nospam.hotmail.com> wrote:
>> This family of bases has many lovely properties. For example, the sum
>> of the polynomials for a given degree is always 1.
>>
>> degree 2: (1-u)^2 + 2(1-u)u + u^2 = 1
>
>In general, this can be seen nicely from the binomial theorem:
>
>(x + a)^n = sum[k=0..n](n?k * x^(n-k) * a^k)
>
>Using it:
>
>1 = 1^n = (1 - u + u)^n = ((1 - u) + u)^n = sum[k=0..n](n?k (1-u)^(n-k) u^k)
>= sum[k=0..n](BB(n,k)[u])

Good point. And it relates back to the combinatorial nature of the n?k
coefficients. To prove the binomial theorem, expanding (a+b)^n, we use
all possible combinations of a's and b's. Each term will have the same
sum of exponents, say (n-k) a's and k b's.

Consider (a+b)^5, as follows.

(a+b) (a+b) (a+b) (a+b) (a+b)

^ ^ | ^ ^

The marks indicate one way to get a term with 4 a's and 1 b. It is
easy to see we have 5 ways altogether. Thus the coefficient of a^4 b
will be 5. Similarly, one way to get a^3 b^2 is as follows.

(a+b) (a+b) (a+b) (a+b) (a+b)

| ^ | ^ ^

Altogether, we will have 10 possibilities. We can choose the first b
from 5 sources, and for each of those we can choose a second b from 4
sources. That's 5*4, or 5*4*3*2*1 / 3*2*1 = 5!/3!, variations -- but
not unique variations. For example, the example shown could be source
1 and then source 3, or source 3 and then source 1. We have to divide
by the number of ways we can shuffle 2 items. We have 2 options for
the first item and 1 for the second, which is 2*1, or 2!. Thus the
total is (5!/3!)/2! = 10, and the general formula is now easy to see.

n?k = (n!/(n-k)!)/k!
= n! / ((n-k)! k!)

For triangular Bezier patches we encounter a further generalization,
"trinomial" coefficients, ?<a,b,c> = (a+b+c)! / (a! b! c!). Loop and
DeRose went further to define S-patches, which need ?I, where I is a
"multi-index". A multi-index is a list of integers to be used both as
exponents, and to generate the required "multinomial" coefficients.
The reasoning for the combinatorics is much the same as the binomial
case. (We still use triangular patches regularly, but S-patches never
caught on; Loop and DeRose went the way of subdivision surfaces.)

<http://research.microsoft.com/~cloop/>
<http://www.mathaware.org/mam/00/master/people/geri/>
<http://www.multires.caltech.edu/teaching/courses/subdivision/>
<http://www.subdivision.org/subdivision/links.jsp>
<http://www.pixar.com/shorts/gg/behind.html>

h

unread,
May 26, 2005, 3:01:12 PM5/26/05
to
"Jerzy Karczmarczuk" <kar...@info.unicaen.fr> wrote in message
news:11a4dc3636c0ecda9b1...@mygate.mailgate.org...
<printed'n'snipped>
>
> Bon courage.
>
> Jerzy Karczmarczuk

Thanks, Jerzy, hope I didn't come across as rude - I've lurked here for long
enough to know I was probably going to end up out of my depth, but I wasn't
expecting the water to rise so fast :) It's starting to make sense now
though I can see I've got a lot of reading ahead, thanks for the
explanations and pointers.

best regards,

h
--


h

unread,
May 26, 2005, 3:08:56 PM5/26/05
to
"Just d' FAQs" <nobod...@mac.com> wrote in message
news:c8u691pac50lncf3q...@4ax.com...
<snip>

> s(t) = ((6 t - 15) t + 10) t^3

Thank you - it looks super smooth, and fits my application perfectly.

Thanks to you and Mr Karczmarczuk I have a lot of reading ahead of me - many
thanks for the detailed explanations - I look forward to investigating
Bezier curves particularly, as I've used them for so long but only ever
understood them on a point-n-click basis.

Very best regards

h
--

0 new messages