Archive for the ‘Physics’ Category

Forward Kinematics in AS3

Monday, April 7th, 2008

A Confession

Kinematics in action
I must confess, firstly, that a week ago I didn’t know what forward kinematics were. Everyone seems to be talking about inverse kinematics lately (”ragdoll” physics), with no love at all for her sister forward kinematics. And really, if such a thing may be said, forward kinematics is the hot sister- I’d take her over inverse anyday.

Here’s the difference: Sometimes its desirable to model movement based on a system of interconnected objects. Your body would be such a system (your hip bone’s connected to your thigh bone, your leg bone’s connected to your calf bone, your calf bone’s connected to your foot bone, etcetera). Inverse kinematics deals with all of this starting from your foot and working inward. This would be ideal for, say, modeling you falling down the stairs or off a building- provided that you were unconscious. The motion that your foot produces during the fall is determines the angle and position of your calf, which then determines those things for your thigh.

Now forward kinematics, on the other hand, goes the other way. The reason you were unconscious in the above example is because any movement started from your body (i.e. flailing in panic as you fell off the building) would be forward kinematics- it starts from your body and moves to the end of the system. Forward kinematics is used to model more mundane things like walking. The thigh is rotated, which determines the position of the calf. The calf is rotated, which in turn determines the position of the foot. Thus, the position of the foot is determined by motion originating at the body, not the reverse.

An Example of Forward Kinematics

Okay, so that’s what forward kinematics is. And here is what it looks like (click the image to see).

AS3 Forward Kinematics

See? He really walks!

A Sponsored Link

(can’t say I wasn’t honest…)

I feel that I should also confess that I got the germ of this little engine from this book:

Foundation Actionscript 3.0 Animation: Making Things Move!

It’s by some guy named Keith Peters who apparently knows his way around the VM2. It’s not a ton of classes- two in his version, three in mine. So if you’ve got $25 and about an hour, give it a shot. And if you buy it from the link above, I get two dollars or something.

Two Reasons to Love Physics

Sunday, February 10th, 2008

He’s 71, teaches at MIT, and he does multiple full dress rehearsals of his lectures before he unleashes them on his unsuspecting pupils. His class costs the school three hundred grand per semester. And he’s definitely the guy that you wished was your physics teacher. But he wasn’t- because if you’re reading my blog, you don’t go to MIT. Ladies and gents, Walter Lewin.

I actually never even took a physics class in high school, but that’s probably because I didn’t associate it with explosions. It’s also because my schedule was already taken up with classes like Intro to Small Arms and Street Slang 101- both of which have served me admirably in my current career. However, now I’m beginning to regret the physics-less education of my youth.

Or rather, I would be regretting my ignorance if not for Alec Cove, who has given the world the gift of the Actionscript Physics Engine (APE). It’s not the only AS3 physics library out there, but in my opinion it’s certainly the simplest to use. It doesn’t seem to have the support of Fisix or the features of Box2D, but if you just want to pick up a physics engine and run with it, I suggest you give APE a try.

Also, if you’re interested, you can download 35 hours of video lectures by this Walter Lewin guy at MIT’s OpenCourseWare.