This post originated from an RSS feed registered with Java Buzz
by News Manager.
Original Post: How to Go from Point A to Point B
Feed Title: Java Today
Feed URL: http://weblogs.java.net/blog/editors/index.rdf
Feed Description: Java Today on java.net
You'd think it would be easy to go from point A to point B. And in a virtual world, it is -- especially if you don't care about having your animations look realistic. In our lead Java Today story, Animations 101 - from point A to point B, Kirill Grouchnikov takes out pencil and notebook to demonstrate the mathematical complexity that lies behind getting from here to there in the real world.
Kirill starts out with the basics:
In a perfect world (imagine a deserted highway), moving from point A to point B is just following the straight line.
So, in an animation, you would simply have the object start moving from point A with a given step size per second, and stop moving when it reaches point B. Kirill analyzes this technique as follows:
While this seems quite straightforward (and i have seen quite a few presentations that use linear animations), this falls apart once you translate the traveled distance to velocity:
This is hardly the way things move in the real world (be they man-made, inanimate or animate).
If Kirill's point isn't clear, consider a car on that deserted highway, at rest at point A. You want to drive it to point B. Does the car instantaneously lurch into motion at 65 miles per hour (~105 km/hr)? It would be very unfortunate for the passengers in the car if that actually happened, since it would mean that acceleration had momentarily approached infinity (only the car seat cushion's compression preventing that) -- quite possibly resulting in the passengers not being alive for the remainder of the journey to point B (consider being thrown at 105 km/hr into a rigidly stationary car seat -- no matter how soft the cushions, you're not coming out of that intact).
Is this what really happens when we travel somewhere? Of course not. In reality, the gas pedal is pressed, and the car's velocity increases (either quickly or slowly, depending on the engine and the driver) to a cruising rate. The trip proceeds at approximately the same crusing rate for most of the trip. Then, as point B is approached, the brake pedal is pressed, and the car slows down until it comes to a stop just as it reaches point B.
So, how can animations present movement in a more realistic manner? By applying mathematical formulas relating to velocity and acceleration that better replicate the actual physical world. Kirill's post covers all of this, and more: he goes into the situation where you don't stop at point B, you just go past it; the sitation where you "sprint to the finish"; the situation where you tire at the end of the trip and start slowing down (likely losing the Olympic gold).
If you've been making animations that apply the straightforward "now it's in motion, now it's not" technique, and you'd like to improve your product, Kirill Grouchnikov's Animations 101 - from point A to point B is an excellent starting point for your studies.
Movement is all around us in the physical world. We take it for granted since we see it from the moment we’re born. Today, i’m going to talk about a seemingly mundane act of moving from one given point to another given point. I would imagine that if you’re reading this, you most probably enjoyed your math lessons in middle school, so the following drawing should be familiar...
What a nice surprise! I wanted to see my Devoxx talk on Parleys and entered my name in the search field to find out that the guys at the University of Würzburg have uploaded footage they took during our Training there almost two years ago. Here you can see me talking German...
Do you know EnumSet? No? Then you should take the time to look at this sample code. EnumSet allows writing of really eloquent Java source code. Run the following code and watch its result printed on the screen. Then check the below source code to find out how it works. The source code particulary makes use of (at least) the following features introduced in Java 5...
Happy New Year! Java EE 6, GlassFish v3, and NetBeans 6.8 were released last month. Are you interested in learning how this awesome combination of technologies and products make your life simpler ? Do you want to brush up your skill set and learn to write Java EE 6 code using NetBeans 6.8 and GlassFish v3 ? Would you like to learn tips & techniques from the experts in GlassFish community ? Do you want to start 2010 with a complete immersion in Java EE 6 & GlassFish v3 ? ...
You might be wondering where I've been the past few months. JavaFX and Java Store work has definitely heated up, which has taken up the bulk of my time. I've also been working on Project Maitai, a tool for reactive visual artwork, as well as traveling to Sweden to speak at OreDev. Now that the Oracle acquisition has received approval (or at least been approved to receive approval), I'm hoping that things will move ahead quickly and we can all get back to writing great software...
A few weeks ago, Ed Burns posted a link to a blog on the JSF expert group mailing list, commenting “A nice one, but it doesn't mention JSF 2”. Ever the curmudgeon, I pointed out that it wasn't so nice that the blog's sample code used the JSF API in beans when it wasn't necessary—as does in fact a lot of sample code, even in the official Sun tutorials. Ed's response: “Cay, a blog comment by such an eminent citizen as yourself would certainly be noticed.” So, here is the curmudgeonly eminence's advice on how to stay away from the JSF API...
In the Forums, kmilo9999 has problems with libraries path: "Dear all: On this days im trying to use some new jars into my webapp with glassfish 2.1 (like hibernate search and others), but sometimes (actually, right now) glassfish just dont get the libraries path and sends the ClassNotFoundException. I put the jars into the project library, adding the jars into the classpath, into the glassfish lib folder and domain folder, but it keeps sending this exception..."
Felipe Gaucho asks [webtier] how to render based on authorization role ?: "how do I control certain visual elements to appear on the screen only if the user logged in has certain privileges ?? a sample project would be nice..."
rapiz asks How to write hebrew in TextField...: "Should i "addInputMode" to textfield? if so, how should i write the hashtable? with what key codes and values? If not what is the procedure \ method to do this? ..."
Registered users can submit event listings for the java.net Events Page using our events submission form. All submissions go through an editorial review before being posted to the site.
Archives and Subscriptions: This blog is delivered weekdays as the Java Today RSS feed. Also, once this page is no longer featured as the front page of java.net it will be archived along with other past issues in the java.net Archive.