Program:

Comments:

 

 

(66,32) 20 0 6.28 ARC

Draws the circle.

PICT RCL →LCD

Displays the empty circle.

RCLΣ TOT /

Recalls the statistics data matrix,

 

computes totals, and calculates the

 

proportions.

DUP 100 *

Converts the proportions to

 

percentages.

→ prcnts

Stores the percentage matrix in prcnts.

«

Multiplies the proportion matrix by

2 π →NUM * *

2π, and enters the initial angle (0).

0

 

→ prop angle

Stores the angle matrix in prop and

 

angle in angle.

«

Sets up 1 to m as loop counter range.

prop SIZE OBJ→

 

DROP SWAP

 

FOR n

Begins loop-clause.

(66,32) prop n GET

Puts the center of the circle on the

'angle' STO+

stack, then gets the nth value from

 

the proportion matrix and adds it to

 

angle.

angle COS angle SIN

Computes the endpoint and draws

R→C 20 * OVER +

the line for the nth slice.

LINE

 

PICT RCL

Recalls PICT to the stack.

angle prop n GET

For labeling the slice, computes the

2 / - DUP DUP

midpoint of the arc of the slice.

COS SWAP SIN R→C

 

26 * (66,32) +

 

SWAP

Starts the CASE structure to test

CASE

angle and determine the offset value

 

for the label.

DUP 1.5 ‰

From 0 to 1.5 radians, doesn’t offset

THEN

the label.

DROP

 

END

 

DUP 4.4 ‰

From 1.5 to 4.4 radians, offsets the

THEN

label 15 user units left.

DROP 15 -

 

END

 

5 <

From 4.4 to 5 radians, offsets the

THEN

label 3 units right and 2 units up.

(3,2) +

 

END

 

END

Ends the CASE structure.

 

 

RPL Programming Examples 2-35