Something wrong with my geometry

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10220
Joined: Fri Feb 19, 2010 10:17 am

Something wrong with my geometry

Post by richmond62 » Thu Jun 04, 2015 12:14 pm

I have a stack with a 'turtle' and buttons to set the angle (currently only offering 90, 180,270 and 0 degrees) of travel, a field to input the distance of travel and a button "FORWARD" to get the
turtle to travel.
SnappingTurtle.png
However, something seems wrong with my Pythagoras.

See script inside "FORWARD" button to see how I've gone wrong.
rat.livecode.zip
(2.59 KiB) Downloaded 168 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10394
Joined: Wed May 06, 2009 2:28 pm

Re: Something wrong with my geometry

Post by dunbarx » Thu Jun 04, 2015 2:30 pm

Hi.

Fun stuff. I only glanced at your code, but I think you should rechoose the browse tool at the end of your handler.

Oh, and it is important to know that the trig functions in LC work only in radians, not degrees. This could be important :D

If you are more comfortable in degrees, can you write a function to translate, transparently, so that you never have to think about it again?

Craig Newman

SparkOut
Posts: 2961
Joined: Sun Sep 23, 2007 4:58 pm

Re: Something wrong with my geometry

Post by SparkOut » Thu Jun 04, 2015 2:48 pm

Radians, not degrees!

Code: Select all

put DD * pi / 180 into tRadians
   put cos(tRadians) into tCos
   put tCos * FW into RITE
   put sin(tRadians) into tSin
   put tSin * FW into DOON
Aha, Craig answered while I was tapping. And yes, make it a functions.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10220
Joined: Fri Feb 19, 2010 10:17 am

Re: Something wrong with my geometry

Post by richmond62 » Thu Jun 04, 2015 7:09 pm

Ah! Radians! Says he pretending he's happy and wonder-struck by that, but, instead, feeling a "right Wally" for not working that out.

Of course, awkward sods [what, me? surely not?] would ask why, if "set the angle" works in degree, sine and cosine only works with radians?

So, now I've got to pop an algorithm in "there" to convert degrees into radians - that sucks a bit . . .

Post Reply