Join My Conversation twitter
Join My Conversation Rss

Collision Using Spring Force

Posted by admin | Posted in Animation, Lingo | Posted on 14-10-2011

0

Collision Using Spring Force

When two objects rebound after colliding with each other, it is due to a spring force, even though it may not look like it. When two billiard balls collide, the compression of the ball is limited to a miniscule fraction of its width but it still happens.

Using a spring force requires higher model rates to realistically collide faster, harder objects. The fps display in the demo shows the actual frame rate. The movie itself is set to 999 fps. On a 1.3 GHz P3 it averages about 980 actual fps.

repeat with s = 1 to 4
if s <> me.spritenum then
spOther = sprite(s)

–distance components
distX = (spOther.x) – x
distY = (spOther.y) – y

–pythagorean theorem to get distance
dist = sqrt(power(distX,2) + power(distY,2))

–spring force
xSpring = 0
ySpring = 0
minDist = (sp.width + spOther.width) / 2.0 - 10
if dist < minDist then
springF = (minDist – dist) * .02
xSpring = springF * -(distX/dist)
ySpring = springF * -(distY/dist)
end if

xTotalForce = xTotalForce + xSpring
yTotalForce = yTotalForce + ySpring
end if
end repeat

The algorithm is almost identical to general gravity, so only the repeat loop is shown. Instead of calculating gravity, it calculates spring force. Spring force only acts when the objects are within a certain distance of each other, expressed as dist < minDist.

The magnitude of the spring force is given by minDist – dist. This is the restPosition – position equation from the Spring Forces section. Scaling by .02 puts the force into proportion with other values in the animation. It can be considered the stiffness of the object, the higher it is the stiffer the object.

This demo gives each object a mass, and uses the mass in the
accel = force / mass equation. The behavior of the large object shows how mass affects acceleration. When two objects collide, each experiences the same amount of force, acting in opposite directions. This force translates into a smaller acceleration for more massive objects.

Mass can be set however you’d like. In this demo it is set to the cube of the sprite width, which would roughly correspond to its mass if it was a
3-dimensional sphere.

The type of collision modelled in this demo is for round objects with no friction between them. Friction or non-round shape would cause part of the energy in the collision to go into rotational velocity, making the objects spin.

For comments on the rest of the script, see General Gravity.

Mass

Posted by admin | Posted in Animation, Lingo | Posted on 14-10-2011

0

Mass

Mass is a measure of how much matter an object is made of, and is related to weight. In physics it appears in the equation

acceleration = force / mass

which is one of Newton’s three famous laws. Notice that the larger the mass, the lesser the acceleration given the same force. If you push with the same force on a ’78 Impala and a shopping cart, the cart will accelerate much faster. In the demos so far mass has been left out of the equation:

acceleration = force

which is simply giving mass a value of 1.

In animation, you may want to include mass in the equation so that you could give many objects the same behavior but different masses. For example, it would be useful in making collisions of objects of different sizes look realistic.

When using different masses with gravity, the equation used should be the general gravity equation, not the specialized one given in surface gravity.

Space Viewport 2.0

Posted by admin | Posted in Lingo, Marketing | Posted on 12-10-2011

0

Case Study: Space Viewport 2.0

Related Topics:
Space Viewport
Perspective & Other Depth Cues
Data Structures and Recursion

View controls:
Drag in viewport to pan
Drag on ‘radar’ to pan
Alt-drag in viewport to zoom
Click ‘follow’ to follow ship
Ship controls:
left/right arrows to turn
ctrl to thrust

Space Viewport 2.0source movie

This demo builds on the first version by giving universe elements a depth and rendering with some depth cues, and also storing the universe model in a tree rather than a list.

Depth & Perspective
The field of action is still two dimensional, but adding depth makes the visuals more interesting. It’s pretty simple to do. Each element is given a z coordinate which is used for perspective and for blendlevel (haze) and locz (z-axis blocking).

Notice how the method uniToView() which maps universe to screen coordinates now makes use of the perspective value. First the offset from the camera is found (vec – camVec), then perspective is applied, then zoom and shifting:

on uniToView(vec)
vec = (vec – camVec) * persp
loch = vec.x * zoomLevel + viewRect.left + viewRect.width/2
locv = vec.y * zoomLevel + viewRect.top + viewRect.height/2
return point(loch, locv)
end

Tree Structure for the Model
Instead of being stored in a list, the objects of the universe are now stored as a tree. The universe object is the tree root, and each object’s position is relative to its parent. The circling planets show how the tree structure simplifies the programming—the planet script doesn’t need to take into account how the sun fits into the rest of the scene. For more on using a tree and transforms in animation see 3D World and the other 3D quad demos.

Migrating to a tree structure was made much easier by inheritance. Simply making the treeNode script the ancestor of universeElement gave all the model objects the properties and methods of a tree node.

This demo is a relatively rare example of the use in Lingo of a series of inheritance, where a script’s ancestor itself has an ancestor. For example, ship inherits universeElement which inherits treeNode. Does it make a difference if universeElement and treeNode are reversed in the order? It wouldn’t to the ship script, but there are reasons to arrange it the way it is. Abstractly, according to the “is a” relationship of inheritance, universeElement is a treeNode but treeNode is not a universeElement. Practically, if you wanted a node just for grouping in the model you can now just use a universeElement object (because it inherits from treeNode).

Ruby on Rails 3 Tutorial: Learn Rails by Example (Addison-Wesley Professional Ruby Series)

Posted by admin | Posted in Lingo, Ruby On Rails | Posted on 08-10-2011

0

Overall Rating:
 

Total Customer Reviews: (52)
Seller: Amazon
This is the eBook version of the printed book.“Ruby on Rails™ 3 Tutorial: Learn Rails by Example by Michael Hartl has become a must read for developers learning how to build Rails apps.” —Peter Cooper, Editor of Ruby Inside   Using Rails 3, developers can build web applications of exceptional elegance and power. Although its remarkable cap[Read More]

Ruby on Rails Bible

Posted by admin | Posted in Lingo, Ruby On Rails | Posted on 06-10-2011

0

Overall Rating:
 

Total Customer Reviews: (3)
Seller: Amazon
Thanks to the explosive growth in popularity of the Rails framework, the equally popular Ruby programming language now has a great place to hang its hat. The powerful combination of the two provides the perfect toolset to create Web applications that feature concise code, clean syntax, and easy maintenance. This must-have book is your best guide on[Read More]

Beginning Ruby on Rails (Wrox Beginning Guides)

Posted by admin | Posted in Lingo, Ruby On Rails | Posted on 06-10-2011

0

Overall Rating:
 

Total Customer Reviews: (19)
Seller: Amazon
Ruby on Rails is the revolutionary online programming tool that makes creating functional e-commerce web sites faster and easier than ever. With the intuitive, straightforward nature of Ruby and the development platform provided by Rails, you can put together full-fledged web applications quickly, even if you're new to web programming.You will find[Read More]

RailsSpace: Building a Social Networking Website with Ruby on Rails (Addison-Wesley Professional Ruby Series)

Posted by admin | Posted in Lingo, Ruby On Rails | Posted on 05-10-2011

0

Overall Rating:
 

Total Customer Reviews: (27)
Seller: Amazon
Ruby on Rails is fast displacing PHP, ASP, and J2EE as the development framework of choice for discriminating programmers, thanks to its elegant design and emphasis on practical results. RailsSpace teaches you to build large-scale projects with Rails by developing a real-world application: a social networking website like MySpace, Facebook, or Frie[Read More]

Rails AntiPatterns: Best Practice Ruby on Rails Refactoring (Addison-Wesley Professional Ruby Series)

Posted by admin | Posted in Lingo, Ruby On Rails | Posted on 04-10-2011

0

Overall Rating:
 

Total Customer Reviews: (7)
Seller: Amazon
The Complete Guide to Avoiding and Fixing Common Rails 3 Code and Design Problems As developers worldwide have adopted the powerful Ruby on Rails web framework, many have fallen victim to common mistakes that reduce code quality, performance, reliability, stability, scalability, and maintainability. Rails™ AntiPatterns identifies these widespread[Read More]

Beginning Ruby on Rails E-Commerce: From Novice to Professional

Posted by admin | Posted in Lingo, Ruby On Rails | Posted on 04-10-2011

0

Overall Rating:
 

Total Customer Reviews: (13)
Seller: Amazon
Ruby on Rails is the hottest new open source technology around. It offers developers the opportunity to create fully-featured web applications in double-quick time. Rails and e-commerce are a match made in heaven and Beginning Ruby on Rails E-Commerce is the first book to directly target this market. This book explains to readers, via real-life sc[Read More]

Ruby on Rails For Dummies

Posted by admin | Posted in Lingo, Ruby On Rails | Posted on 03-10-2011

0

Overall Rating:
 

Total Customer Reviews: (15)
Seller: Amazon
Quickly create Web sites with this poweful toolUse this free and easy programming language for e-commerce sites and blogsIf you need to build Web and database applications quickly but you don't dream in computer code, take heart! Ruby on Rails was created for you, and this book will have you up and running in no time. The Ruby scripting language an[Read More]

Ruby on Rails 3 Tutorial LiveLessons Bundle: Learn Rails by Example

Posted by admin | Posted in Lingo, Ruby On Rails | Posted on 03-10-2011

0

Overall Rating:
 

Total Customer Reviews: (0)
Seller: Amazon
Use Michael Hartl’s Acclaimed Video Lessons and Best-Selling Book Side by Side to Master Rails Fast!  LiveLessons™ DVD with 18+ hours of video instruction–a $150 value Michael Hartl’s Ruby on Rails™ 3 Tutorial, the #1 hands-on guide to Rails web programming–a $40 value  A $190 value, this package delivers instant skills, an[Read More]

Head First Rails: A Learner’s Companion to Ruby on Rails

Posted by admin | Posted in Lingo, Ruby On Rails | Posted on 02-10-2011

0

Overall Rating:
 

Total Customer Reviews: (20)
Seller: Amazon
Ready to transport your web applications into the Web 2.0 era? Head First Rails takes your programming -- and productivity -- to the max. You'll learn everything from the fundamentals of Rails scaffolding to building customized interactive web apps using Rails' rich set of tools and the MVC framework. By the time you're finished, you'll have learne[Read More]

Ruby on Rails 3 Tutorial: Learn Rails by Example (Addison-Wesley Professional Ruby Series)

Posted by admin | Posted in Lingo, Ruby On Rails | Posted on 02-10-2011

0

Overall Rating:
 

Total Customer Reviews: (52)
Seller: Amazon
“Ruby on Rails™ 3 Tutorial: Learn Rails by Example by Michael Hartl has become a must read for developers learning how to build Rails apps.” —Peter Cooper, Editor of Ruby Inside   Using Rails 3, developers can build web applications of exceptional elegance and power. Although its remarkable capabilities have made Ruby on Rails one of the w[Read More]

Lingo EuroTalk Electronic Translator

Posted by admin | Posted in Lingo | Posted on 01-10-2011

0

Overall Rating:
 

Total Customer Reviews: (3)
Seller: Amazon
Lingo EuroTalk Electronic Translator. Translates and speaks more than 360,000 words and more than 19,000 travel phrases. The Lingo EuroTalk Traveler displays, translates and speaks words and common travel phrases in English, Spanish, French, Italian and Greek. It features a 4-line digital display with LED backlight, 8 metric conversions, 8 currency[Read More]

Lingo

Posted by admin | Posted in Lingo | Posted on 01-10-2011

0

Overall Rating:
 

Total Customer Reviews: (6)
Seller: Amazon
Brewster Billings is perhaps a little too wrapped up with his computer. He has given it a pet name, Lingo. He has programmed it with the ability to talk to its owner. In fact, Lingo has begun to respond to Brewster's programming skill surprisingly well. Lingo soon makes the jump from polite conversation to elaborate requests for specific televisi[Read More]