how to get info

About advanced scenes, and the Thyme scripting language used in Algodoo.

how to get info

Postby scorp200 » Sun Apr 18, 2010 8:09 am

how to get info from an object like its Energy?
so it can be added to a variable
scorp200
 
Posts: 12
Joined: Fri Sep 25, 2009 5:15 am

Re: how to get info

Postby Kilinich » Sun Apr 18, 2010 8:13 am

There is no easy way to do it. But it's possible for circles/boxes via app.step/undo trick.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: how to get info

Postby scorp200 » Sun Apr 18, 2010 8:14 am

um what? :D
scorp200
 
Posts: 12
Joined: Fri Sep 25, 2009 5:15 am

Re: how to get info

Postby Mystery » Sun Apr 18, 2010 10:26 am

He's talking about Method X
viewtopic.php?f=13&t=545

Simply using Method X you can't get the energy but with some math you can.
(Can some of the Physic junkies help me out here.) You can find the Dimensions with Method X
Code: Select all
e.other.size := [0.0, 0.0]; App.step; App.undo

or for circles
Code: Select all
e.other.radius := 0; App.step ;App.undo

and Density with collide.

For Squares to find the area simply
Code: Select all
scene.my.area = (e.other.size(0) * e.other.size(1))

For circles (I may be very wrong here)
Code: Select all
scene.my.area = (e.other.radius^2 * 3.14159265) * 2


then times the area by the density to get the mass
Code: Select all
scene.my.mass = scene.my.area * e.other.density


Then you can get the Velocity with Method X
Then it is a matter of using the mass and the velocity to find out the kinetic energy which is totally unknown to me and i'm hoping one of our many Physics gurus can help.

With some help from rara I've made the final code
Code: Select all
scene.my.Kenergy = ((scene.my.mass * e.other.vel(0) + e.other.vel(1)) ^ 2) / 2


So all together now :)
The magic code to get energy from an object.
Variables needed (Put this into the console)
Code: Select all
Scene.my.mass := 0;
scene.my.kenergy := 0


Code: Select all
     e.other.vel := [0.0, 0.0];
    e.other.size := [0.0, 0.0];
    App.step;
    App.undo;
    scene.my.mass = (e.other.size(0) * e.other.size(1)) * e.other.density;
    scene.my.Kenergy = ((scene.my.mass * e.other.vel(0) + e.other.vel(1)) ^ 2) / 2

:? Unfortunately the code for energy doesn't work an unexplained error in my code or a bug in algodoo is causing it to be a bit weird.
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 9 guests

cron