Alternative To A Specific Switch Statement

Jim Hurley jhurley0305 at sbcglobal.net
Fri Mar 15 09:17:50 EDT 2013


Hi Ender,

I don't know how this trig function arose in you application, but you may want to take a look at the atan2 function in Live Code.

It handles all the funny things that happen at the branch cuts in the trig functions beautifully. It dispenses with the need for a switch function.

Jim


> 
> Message: 1
> Date: Thu, 14 Mar 2013 19:42:05 +0200
> From: Ender Nafi Elek?io?lu <endernafi at gmail.com>
> To: List LiveCode <use-livecode at lists.runrev.com>
> Subject: Alternative To A Specific Switch Statement
> Message-ID: <66721958EA974A8480A750047083D257 at gmail.com>
> Content-Type: text/plain; charset="utf-8"
> 
> Hello Dear LiveCode Gurus,  
> 
> 
> 
> Here is a little code snippet:
> 
> __switch
> ____case sin(pAngleInRadians) > 0
> ______put 1 into tX
> ______break
> ____case sin(pAngleInRadians) = 0
> ______put 0 into tX
> ______break
> ____case sin(pAngleInRadians) < 0
> ______put -1 into tX
> ______break
> __end switch
> 
> It's for a complex rotation command.
> Is there a more elegant way to achieve the same result with built-in functions?
> I mean, something like a combination of abs(), max() and/or round()?
> Just an intellectual curiosity :)
> 
> Thanks for any insights...
> 
> 
> Best,
> 
> ~ Ender Nafi
> 





More information about the use-livecode mailing list