How does this mouse-following scene work?

Discuss scenes and videos made with Algodoo.

How does this mouse-following scene work?

Postby Xray » Mon Jul 09, 2012 7:11 am

I downloaded this
Rating: rated 6.2
Filesize: 9.9 kB
Comments: 7
Ratings: 4
download
which is a simple (but hard for me to understand) scene which uses very little thyme script. When I first looked at it, my assumption was that the script simply commanded the motor (hinge) to rotate based on the position of the mouse pointer. But that's not how it works! I dug into this scene peice-by-peice in an attempt to reverse engineer it, and I'm close to going crazy trying to figure out how it was done. So someone please save my sanity by explaining how it rotates without activating a motor. I was going to contact the author "Raydeg" but I was not able to make contact with him/her through the personal messaging system.

Thanks!
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: How does this mouse-following scene work?

Postby jon_joy_1999 » Sun Sep 30, 2012 11:50 pm

my psychic powers tell me it goes something like

(e)=>{e.geom.materialVelocity = -(2 * (e.normal(1) * (app.mousepos(0) - e.pos(0)) - e.normal(0) * (app.mousepos(1) - e.pos(1))) / (((app.mousepos(0) - e.pos(0)) ^ 2 + (app.mousepos(1) - e.pos(1)) ^ 2) ^ 0.5))}
Image
BSrac = BoincStats recent average credit
I'd rather be network computing.
jon_joy_1999
 
Posts: 233
Joined: Fri Dec 09, 2011 12:51 am


Return to Scenes

Who is online

Users browsing this forum: No registered users and 5 guests

cron