mouse within oval filled area
jhurley0305 at sbcglobal.net
Sun Nov 13 01:01:57 EST 2011
Would this help? The script below will draw a polygon that looks like an ellipse with a start and stop angle.
The trouble with the start angle and the arcangle in RR is that they are not polar angles but are related in a complex way:
arcAngle = arctangent( b/a * tangent(polarangle)
And then use a mousewithin handler for the "oval" grc--actually a polygon
put 10 into tStartAngle -- Or whatever
put 250 into tEndAngle -- Or whatever
put 200 into a --Semi major axis
put 100 into b -- Semi minor axis
put 300 into x0 -- The origin
put 250 into y0 -- The origin
put x0,y0 & cr into tPoints
--Construct the points for the ellipse
repeat with i = tStartANgle to tEndANgle
put r(i) into tR
put round ( x0 + r(i) * cos(i*pi/180)), round(y0+r(i) * sin(i*pi/180)) into temp
put temp & cr after tPoints
put x0,y0 after tPoints
--Construct the graphic
if there is no grc "oval" then create grc "oval"
set the style of grc "oval" to "polygon"
set the opaque of grc "oval" to true
set the points of grc "oval" to tPoints
function r tA --Radial distance to the ellipse as afunction of the angle
put (cos(tA*pi/180))^2 / (a*a) + (sin(tA*pi/180))^2 / (b*b) into temp
> Has anyone worked out how to test if the mouseLoc is within the filled area
> of an oval graphic (defined by startAngle and arcAngle)? I was thinking
> polar coordinates, but this assumes a circle and a fixed radius which is not
> necessarily the case. A btter math brain than mine is needed!
> Hugh Senior
More information about the Use-livecode