Pie Chart Algorithms?
Alex Tweedly
alex at tweedly.net
Wed Mar 1 17:32:24 EST 2006
Sivakatirswami wrote:
> Now my next challenge is to get a list of points on the circumference
> of any circle. I checked the mailing lists and can't find the
> algorithm or sample script that would do this. If anyone has the
> "professional" algorithm to do this please do post it... /H's chart
> stack is protected...
>
Not professional, but maybe "interested amateur" :-)
(this returns floating point numbers - remember to convert to integers
before using as points of a polygon or similar)
on mouseUp
put getPoints(100,100,10) after msg
end mouseUp
function getPoints xc, yc, rad
-- returns a list of points on the circumference of a circle
-- centered at xc,yc with radius rad
repeat with i = 0 to 90
put xc+ rad*sinInDegrees(i), yc+rad*cosInDegrees(i) & CR after tResult
end repeat
return tResult
end getPoints
function cosInDegrees angleInDegrees
return cos(angleInDegrees * pi / 180)
end cosInDegrees
function sinInDegrees angleInDegrees
return sin(angleInDegrees * pi / 180)
end sinInDegrees
>
> And a related issue: move grc "ball" to the points of grc "oval"
> doesn't do anything... oval's don't have any points (?) doesn't make
> sense to me: any line object on a screen is a series of pixels... how
> can it not have points?
>
Polygons are defined by a set of points
Ovals are defined by a centre and radius (or radii)
When either of them is drawn, some pixels are coloured in; in the case
of a polygon, far more pixels will be coloured in than are in "the
points" of the poly.
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.1.1/270 - Release Date: 27/02/2006
More information about the use-livecode
mailing list