Need help with velocity calculation

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

Need help with velocity calculation

Postby PlanckBanck » Thu Sep 09, 2010 11:30 pm

maybe this`ll be karatebrots work again (that lil`mathsfreak ;P) but I just can`t get this scrpt to work

Code: Select all
vel := [(50 * sin(atan((app.mousepos(0)) - (e.pos(0)) / (app.mousepos(1) - e.pos(1))))), (50 * cos(atan((app.mousepos(0)) - (e.pos(0)) / (app.mousepos(1) - e.pos(1)))))]


I want the spawned object to have a velocity of 50m/s^2 while pointing at the cursor.
I used the arctan to calculate the angle of the vector pointing at the cursor first, then calculating the x and y velocities for tat angle.

well, that`s it! thanks up front!
Greetings
PlanckBanck
The world is a gas-station, where you`re allowed to smoke. -Friedrich Dürrenmatt

I forgot 2/3 of my scripting knowledge T.T
User avatar
PlanckBanck
 
Posts: 48
Joined: Sun Nov 22, 2009 5:35 pm
Location: In the Bottoms of Berlin

Re: Need help with velocity calculation

Postby RA2lover » Tue Sep 21, 2010 7:35 pm

there's no redirection for the proper trigonometric function for arctangents, unlike sin and cos.

the config.cfg file used to have 2 lines to redirect the functions

sin = {math.sin}
cos = {math.cos}

hovewer, it doesn't have for atan. this means you'll need to use math.atan instead of atan.
Jrv wrote:
TC42 wrote:Quite honestly, I didn't think anyone on 4chan has that good a use of grammar, spelling, usage, mechanics, ect.
But I've never been there, so I may be wrong.


GTFO newfgt
User avatar
RA2lover
 
Posts: 607
Joined: Mon Aug 31, 2009 8:43 pm
Location: Brazil


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 5 guests