Activities/Physics: Difference between revisions
Tag: visualeditor-switched |
|||
| (8 intermediate revisions by 2 users not shown) | |||
| Line 24: | Line 24: | ||
|+ | |+ | ||
|valign="top"|[[Image:physics_pen.png|thumb|none|280px|Example illustrating the pen tool attached to the end of a pendulum.]] | |valign="top"|[[Image:physics_pen.png|thumb|none|280px|Example illustrating the pen tool attached to the end of a pendulum.]] | ||
|valign="top"|[[Image:physics-tracing.png|thumb|none|280px|Tracing multiple objects]] | |||
|+ | |||
|valign="top"|[[File:TAGearTA.png|thumb|none|280px|A simple gear and motor generated in Turtle Art]] | |||
|valign="top"|[[File:TAGear.png|thumb|none|280px|rendered in Physics]] | |||
|+ | |||
|valign="top"|[[File:Chain.png|thumb|none|280px|a chain generated in Turtle Art]] | |||
|} | |} | ||
== Ideas to try == | == Ideas to try == | ||
*Build a catapult to simulate Angry Birds | |||
*Build a machine that sorts different sized balls in to two buckets, large and small, with no ball jams. | *Build a machine that sorts different sized balls in to two buckets, large and small, with no ball jams. | ||
*A cyclic mechanism for lifting balls from the bottom of the screen to the top, again and again. | *A cyclic mechanism for lifting balls from the bottom of the screen to the top, again and again. | ||
| Line 92: | Line 99: | ||
|'''Hints and tips''': Single clicking (no drag) with the circle, triangle or box tool, will add a default sized shape. Once you have used a shape tool, it remembers the last shape you made with it, a single click will add a clone of that last shape. | |'''Hints and tips''': Single clicking (no drag) with the circle, triangle or box tool, will add a default sized shape. Once you have used a shape tool, it remembers the last shape you made with it, a single click will add a clone of that last shape. | ||
|} | |} | ||
== Did you know? == | |||
There is a Plugin for [[Activities/TurtleArt|Turtle Blocks]] that lets you create projects for the Physics Activity: | |||
[[File:Physics pallette.jpg]] | |||
Use these blocks to create objects that are added to the bodylist and jointlist of a Box2d database used by the Physics Activity. Objects are positioned by the turtle x,y and colored based on the current pen attributes. From left to right: | |||
* density: set the object density (0 is light; 1 is heavy) | |||
* friction: set the object friction (0 is slippery; 1 is sticky) | |||
* bounciness: set the object restitution (0 is rigid; 1 is bouncy) | |||
* start polygon: use the current turtle x,y position to specify the first vertex of a polygon | |||
* add point: use the current turtle x,y position to add a vertex to a polygon | |||
* end polygon: use the current turtle x,y position to specify the last vertex of a polygon | |||
* end filled polygon: use the current turtle x,y position to specify the last vertex of a ''filled'' polygon | |||
: '''Note:''' The polygon must be 'normal', e.g., no crossed lines; no holes. Since Box2d does not support concave polygons, all polygons are converted to triangles (triangulation). (In Turtle Blocks, these triangles are shown by slight variations in color.) | |||
* triangle: add a triangle object at the current turtle x,y position | |||
* circle: add a circle object at the current turtle x,y position | |||
* rectangle: add a rectangle object at the current turtle x,y position | |||
* gear: add a gear object at the current turtle x,y position with the number of teeth as the argument | |||
* gear radius: returns the radius of a gear with the number of teeth as the argument (useful for positioning gears) | |||
* motor: add a motor at the current turtle x,y position (attached to the object at this position) | |||
* pin: add a pin at the current turtle x,y position (attached to the object at this position) to prevent movement | |||
* pen: add a pen at the current turtle x,y position (attached to the object at this position) to trace motion | |||
* joint: add a joint between the object at the current turtle x,y position and the object at x, y | |||
* save as Physics project: save the current bodylist and jointlist as a Physics project in the Journal | |||
'''Note:''' The current model is cleared whenever the Erase button is pressed or a Clean block is run. | |||
===== Examples ===== | |||
'''For Turtle Blocks versions 107 - 183''' | |||
[[File:TAgear.ta]] [[File:Gear.physics]] | |||
'''For Turtle Blocks verisons 184 - ''' | |||
[http://people.sugarlabs.org/walter/physics-plugin.tar.gz] | |||
'''Chain''' | |||
Turtle Blocks project file: [http://people.sugarlabs.org/walter/chain.tb] | |||
===Downloads=== | |||
[[File:Physics-plugin.tar.gz]] Physics plugin | |||
[https://github.com/sugarlabs/physics git repository on GitHub] | |||
= Development = | = Development = | ||
[[Image:PhysicsElements.png|160px|right]] | [[Image:PhysicsElements.png|160px|right]] | ||
There are quite a few code layers to contend with. A regular Python Activity acts as a Sugar wrapper to Physics which is written using | There are quite a few code layers to contend with. A regular Python Activity acts as a Sugar wrapper to Physics which is written using SugarGames which itself wraps Pygame, Physics then uses Elements as a wrapper for Box2D. | ||
==Video== | ==Video== | ||
| Line 214: | Line 264: | ||
* [http://activities.sugarlabs.org/en-US/sugar/addon/4193 Activity bundle] | * [http://activities.sugarlabs.org/en-US/sugar/addon/4193 Activity bundle] | ||
* [ | * [https://github.com/sugarlabs/physics/ GIT repository] | ||
* [http://download.sugarlabs.org/sources/honey/Physics/ Source tarball] | * [http://download.sugarlabs.org/sources/honey/Physics/ Source tarball] | ||