Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trig Calculation....
Message
From
17/12/2003 10:03:09
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00859407
Message ID:
00859885
Views:
24
Hi again,

Back from the game of squash (I lost). I have double checked my scribbles and they look OK, so...

Assuming I understood your requirements correctly, the code below should do it. It returns a negative distance from centre for angles greater than 180 which from one viewpoint is correct.

Is this what you wanted?

Alan
=MESSAGEBOX(GetDims(90,1))

FUNCTION GetDims
PARAMETERS lnAngle, lnRadius

    * Improve default accuracy
    lnOldDecimals = SET('Decimals')
    SET DECIMALS TO 10

    * Convert degrees to radians
    lnRadAngle    = lnAngle*(2*3.14159265358979) / 360
	
    lnChordLength = 2 * lnRadius * SIN(lnRadAngle / 2)
    lnArcHeight   = lnRadius * (1 - COS(lnRadAngle / 2))
    lnDist2Centre = lnRadius * COS(lnRadAngle / 2)
	
    * Allow for angles > 180
    IF lnAngle > 180
        lcRectDims    = 'The dimensions are '+ALLTRIM(STR(2 * lnRadius, 10, 5))+;
                                       ' by '+ALLTRIM(STR(lnArcHeight, 10, 5)) +;
                                       ' at '+ALLTRIM(STR(lnDist2Centre, 10, 5))
    ELSE
        lcRectDims    = 'The dimensions are '+ALLTRIM(STR(lnChordLength, 10, 5))+;
                                       ' by '+ALLTRIM(STR(lnArcHeight, 10, 5)) +;
                                       ' at '+ALLTRIM(STR(lnDist2Centre, 10, 5))
    ENDIF
	
    * Restore old SETs
    SET DECIMALS TO (lnOldDecimals)
	
RETURN lcRectDims
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform