Angle scripting help

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

Angle scripting help

Postby Shamus » Mon Jun 07, 2010 4:30 pm

I am making an arm that you give it a set of coordinates (eg. [3,2]) and it will move to that spot. It will use the coordinates to set it's arm's length and angle. I already made the arm length script (I used the distance formula to find the distance between the end of the arm and the center of the arm's rotation) but I don't know how to get the angle of the arm.

I have In my scene variables:

Scene.my.armlength - arm's length
Scene.my.targetarmlength - the length I want the arm to be
Scene.my.handpos - end of arm's position
Scene.my.center - center of the arm's rotation
Scene.my.armmotor - speed the motors that change the arms length are going at
Scene.my.anglemotor - speed the motor that changes the angle of the motor is moving at
Scene.my.angle - arms angle (I need. To find a way to get the angle)

If someone could tell me a way to find the angle of the arm using these variables, I would appreciate it.
User avatar
Shamus
 
Posts: 13
Joined: Sat Sep 05, 2009 5:23 pm

Re: Angle scripting help

Postby Rideg » Mon Jun 07, 2010 5:07 pm

1. Make a box.
2. Make a laser/spinning box
3. (e)=>{scene.my.angle = e.normal} = The angle in normal.
4. (e)=>{scene.my.angle = math.atan(e.normal(1) / (e.normal(0) + 1)) * 2} = the angle in radians.

Hope this was what you were looking for ;)
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Angle scripting help

Postby Shamus » Wed Jun 09, 2010 7:21 pm

Thank you so much! Now I can make the ultimate robotic arm. I'm going to make it sort out boxes according to color (eg. Move the red box to the red platform, blue to Blue, take the yellow off of the green etc.) it's already been done, but I want to try it myself.
User avatar
Shamus
 
Posts: 13
Joined: Sat Sep 05, 2009 5:23 pm

Re: Angle scripting help

Postby Rideg » Wed Jun 09, 2010 8:07 pm

That's great! Hope I can see it when your done. Good luck :thumbup:
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Angle scripting help

Postby KarateBrot » Thu Jun 17, 2010 7:55 am

The normal is no angle. It is a unit vector that's pointing orthogonally away from the objects surface.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Angle scripting help

Postby Rideg » Thu Jun 17, 2010 11:48 am

but I just made it an angle ;)
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Angle scripting help

Postby barrti » Mon Sep 19, 2011 11:23 am

I'm new at this so please bear with me. I've had a good look around but not much the wiser I'm afraid!

I am trying to create a flexible horizontal beam sitting on 2 supports, one on the extreme left and one on the extreme right.

The beam will take up a curved shape when weights are placed on top of it.

I want to create the beam out of a series of rectangular boxes that are joined together by hinges that have a torque.

As the beam bends downwards, the hinged boxes will no longer be in a straight line-ie the beam will be curved.

As each hinged box rotates relative to the box on either side, I want to measure the angular misalignment between each box and usethis to control the hinge torque. eg if the misalignment is 5 degrees, the torque will be 10 Nm. If the misalignment is 10 degrees, the torque will be 20 Nm.

This will in effect create a rotary spring in each hinge and I will have a flexible beam which will approximate a real flexible beam.

I had hoped that there would be a spring built into the hinge but being able to control the hinge torque will be enough.

I started using linear springs attached to the boxes but realized that I will not get a rotary spring that has a linear torque vs angle relationship.

Can anyone point me in the right direction? Any help would be greatly appreciated.

Thanks
barrti
 
Posts: 3
Joined: Fri May 28, 2010 10:34 am

Re: Angle scripting help

Postby Kilinich » Mon Sep 19, 2011 1:57 pm

in algodoo 1.9+ you don't need motors and lasers for that - bending feature for axles solve it.
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: Angle scripting help

Postby barrti » Mon Sep 19, 2011 5:52 pm

Kilinich,

thanks for your comments.

I've searched high and low but i still don't understand much I'm afraid.

I now know, thanks to u and others that the hinge can be directed to rotate towards the bendtarget angle which can be specified in radians.

What i don't know is how to specify that angle. How can I direct the hinge attached to one box, to rotate towards the centre of another box?

I suppose that in the script menu, you enter bend target = {script.my.*************} ????

Regards
barrti
 
Posts: 3
Joined: Fri May 28, 2010 10:34 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 12 guests