Utilising angular velocity of an object to make a tachometer

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

Utilising angular velocity of an object to make a tachometer

Postby royalblue » Sun Jan 24, 2010 8:56 am

Is there any way i can use script to extract the angular velocity of the wheel of a car to display said speed or convert it into a different unit, such as km/h or such? I know the numbers are there, in information, but i don't know how I would turn them into a variable that i can display on a box. Does anyone have any ideas?
royalblue
 
Posts: 14
Joined: Mon Aug 31, 2009 9:22 pm

Re: Utilising angular velocity of an object to make a tachometer

Postby KarateBrot » Sun Jan 24, 2010 9:51 am

Yes. Basically it's very easy. Angular velocity is Δα/Δt. So you just have to measure the angle of a geometry and simulation time at two different times and that's it.

For example you have a geometry and put a laser on it that's colliding with a little rectangle that's fixed to the geometry. The laser code is:
Code: Select all
(e)=>
{
scene.my.angle2 = math.acos(e.normal(0));
e.normal(1) < 0 ? {scene.my.angle2 = 2*math.pi - scene.my.angle2} : {};
scene.my.angvel = (scene.my.angle2 - scene.my.angle1) / (sim.time - scene.my.time1)
scene.my.angle1 = math.acos(e.normal(0));
e.normal(1) < 0 ? {scene.my.angle1 = 2*math.pi - scene.my.angle1} : {};
scene.my.time1 = sim.time;
}

There could be mistakes somewhere. I just typed in the code very quickly.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Utilising angular velocity of an object to make a tachometer

Postby royalblue » Sun Jan 24, 2010 10:49 pm

I mean, the program already calculates the speed of the object, why is there no way to just take that number and put it somewhere else
royalblue
 
Posts: 14
Joined: Mon Aug 31, 2009 9:22 pm

Re: Utilising angular velocity of an object to make a tachometer

Postby KarateBrot » Mon Jan 25, 2010 12:14 am

hmm yeah that's a good question. but thyme is very simple. maybe it gets expanded in future updates.
But there's a little trick so you can access nearly everything
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest