Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A Christmas puzzle
Message
 
À
24/12/2003 10:59:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00861878
Message ID:
00861962
Vues:
22
I think you may be doing too much work with that code. If I understand the question correctly, then all that's need is a polygon that contains the part of the 'donut' between angle 1 and angle 2, and no other part of the donut. The poly doesn't need to match the shape of the arcs.

I'm assuming that the procedure is going to be to XOR the large circle with the small circle to get the donut region, and then AND that result with the polygon. So the shape of the polygon outside the donut area doesn't matter.
CLEAR
PrintCoords(30,60,10)
PrintCoords(45,150,10)
PrintCoords(300,80,10)
PrintCoords(180,240,10)

* params are the starting and ending angle in degrees,
* and the radius of the larger circle.
* this code assumes that the distance from angle1 to angle2 is not more than 180 deg.
FUNCTION PrintCoords( tnAngle1, tnAngle2, tnRadius )

DIMENSION aCoords[6,2]
LOCAL nPoints
nPoints = 4

aCoords[1,1] = 0
aCoords[1,2] = 0
aCoords[2,1] = COS(DTOR(tnAngle1)) * tnRadius
aCoords[2,2] = -SIN(DTOR(tnAngle1)) * tnRadius
aCoords[3,1] = IIF( tnAngle1 >= 90 AND tnAngle1 < 270, -tnRadius, tnRadius )
aCoords[3,2] = IIF( tnAngle1 < 180, -tnRadius, tnRadius )

IF INT(tnAngle1/90) # INT(tnAngle2/90)
	nPoints = 5
	aCoords[4,1] = IIF( tnAngle1 < 180, -tnRadius, tnRadius )
	aCoords[4,2] = IIF( tnAngle1 >= 270 OR tnAngle1 < 90, -tnRadius, tnRadius )
	IF ( INT(tnAngle1/90) + 1 ) % 4 # INT(tnAngle2/90)
		nPoints = 6
		aCoords[5,1] = IIF( tnAngle1 >= 90 AND tnAngle1 < 270, tnRadius, -tnRadius )
		aCoords[5,2] = IIF( tnAngle1 < 180, tnRadius, -tnRadius )
	ENDIF
ENDIF

aCoords[nPoints,1] = COS(DTOR(tnAngle2)) * tnRadius
aCoords[nPoints,2] = -SIN(DTOR(tnAngle2)) * tnRadius

FOR ii = 1 TO nPoints
	? "(" + TRANSFORM(aCoords[ii,1]) + "," + TRANSFORM(aCoords[ii,2]) + ")"
ENDFOR
? ""

ENDFUNC
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform