From: tinywanda@aol.com (TinyWanda)
Newsgroups: comp.sys.hp48
Subject: Fixed (?) Ellipserizer (!)
Lines: 604
Message-ID: <1998071705552800.BAA22454@ladder01.news.aol.com>
NNTP-Posting-Host: ladder01.news.aol.com
X-Admin: news@aol.com
Date: 17 Jul 1998 05:55:28 GMT
Organization: AOL http://www.aol.com
Xref: republic.btigate.com comp.sys.hp48:13434

Introduction To This New Ellipserizer:

i suppose, just as much as anyone, i was astonished when i learned that someone
was actually attempting to use one of my programs...!!!

i was less astonished when this person eeped me, informing me that they
couldn't get it to work...!!! (?)

besides leaving out one of the sub-routines---
the major problem seemed to be that they had mischieviously set their flags to
some other settings than what they were supposed to be...!

this new version has been suplimented with all the sub-routines that it
actually needs, along with updated verisons of Bep & an entirely new program
that tells you how far apart two circles are, which may help a previous program
return more semi-reliable results...?

there are also some other improvements, better error handling & friendlier
Input structures.

and, and---and i've taken the time to figure out (?) which flags are supposed
to be set at which positions, so i included all these annoying details into the
program.
( the original settings are restored when the program terminates )

i am highly confident (96%) that this will actually work on any g or gx.

( ??? )

                                                    ---   tw

----------------------------------------------------o
Ellipserizer
----------------------------------------------------o

48 Translation by TinyWanda          July '98 version
   To Contact TinyWanda Via The BabyNous Cult:
   Eep me @: babynous@linknet.kitsap.lib.wa.us 

Original Theory by The Ancient Babylonians (???)
Original Theory Name: The Approximate Eight Centered Ellipse

The net Effect is to Approximate an Ellipse with Eight Arcs.

Ellipserizer provides the Centers and Radii 
of 3 Arcs for a Single Quadrant.

---------------------------------o
The Directory; ELLPz consists of 12 objects plus PPAR.

Ellps     Collects Datum, Solves for Ellipse, 
          Then Draws Illustration.
Bep       Makes one of 5 Bepping Sounds.
Cpict     Moves the Display View to the Center of PICT.
Dots      Draws little Dots onto PICT.
Focus     Finds the Focus of Two Rays.
Ray       Draws a Ray on PICT.
R->p      Rectangular to Polar.
P->r      Polar to Rectangular.
Tags      Attaches list of Tags to Stack Objects.
0-><-0    Finds the Point(s) where Two Circles Intersect.
O.?.O     How far Apart are Two Circles?
./.       Finds the Mirrored Point across a Ray.
.1to1     Modifies PPAR so that the Pixels are Square.
PPAR      Plot PARamenters
---------------------------------o


----------------------------------------------------o
How To Do It (!)
----------------------------------------------------o
Name:             Ellps
CheckSum:       # 790Bh
Size:           1449.00

Ellps provides the User with a Choose prompt to select one of three formats for
the initial Entering of the Known Variables;
  Width & Height of the Ellipse
  The positive Focii & Width of the Ellipse
  or 
  The Positive Focii & Height of the Ellipse.
After choosing the appropriate format for your Ellipse,
Enter the two known variables into the Inform prompt that's provided,
And the Width & Height of PICT for the Accompanying Illustration!

Ellps will them make all the necessary calculations and draw a quadrant on PICT
with the three Circles and the Rays that separate them.
To connect the rays on a separate sheet of graph paper,
The Alpha center connects to The Beta center, 
 and Beta connects to Delta.

Output will be:
6:    (x,y)  alpha center 
5:        r  alpha radius
4:    (x,y)  beta center
3:        r  beta radius
2:    (x,y)  delta center
1:        r  delta radius

----------------------------------------------------o
The SubRoutines:
----------------------------------------------------o

Many of these programs have a double click feature 
to remind the user of the appropriate input structure.
Double Clickable programs are indicated with a ** notation.

If you use the Double click feature... 
You may either enter the input when The Prompt is provided, 
or hit ENTER to use the objects that are already on the stack.

If you Do Not use the Double Click feature, 
The program will be anticipating that the Stack will be loaded with the
Appropriate Stuff...! (?)

....................................:
Name:               Bep
CheckSum:       # 74BFh
Size:            350.50

Bep takes Either an integer value of 1, 2, 3, 4 or 5 
and produces a Urp, Arp, Bep, Pop or Eetch.

Or a list of The number of Beps & The kind of Beps!

Input:
1:                       KindOfBep
Or
1:   { NumberOfBeps KindOfBeps }

....................................:
Name:             Cpict
CheckSum:       # 1264h
Size:             73.00

Takes no input, 
But moves the Display view to the Center of PICT.

....................................:
Name:              Dots
CheckSum:       # 6714h
Size:            343.00

The Input for Dots may be; 
A single (x,y) coordinate, 
A list of (x,y) coordinates,
Or a stack of (x,y) coordinates with an integer on 1: that indicates how many
of the (x,y)s are on the stack that you'd like Dots to process.
Dots then uses the (x,y) coordinates to draw cute little circles on PICT at
that/those locations.

....................................:
Name:             Focus **
CheckSum:       # 6964h
Size:            284.00

Focus takes The Centers and Angles of two Rays and Returns the position where
theyd intersect.
In the event that the rays are parallel, (MAXR,MAXR) will be returned.

Input is:
4:    (x,y)   Ray Center ( Rectangular Coordinates )
3:        a   Ray Angle
2:    (x,y)   Ray Center ( Rectangular Coordinates )
1:        a   Ray Angle

....................................:
Name:               Ray **
CheckSum:       # 4035h
Size:            266.00

Ray takes An (x,y) Coordinate & An Angle or Another (x,y) Coordinate,
and draws a Ray on PICT that extends beyound the limits of PICT.
If one or both of the (x,y) coordinates are on PICT, little circles will show
their positions.

....................................:
Name:              R->p
CheckSum:       # 319Bh
Size:             71.50

Name:              P->r
CheckSum:       # EB6Ch
Size:             71.50

Rectangular to Polar
Polar to Rectangular
Both coordinates are in the 
(x,y) Rectangular format,
(r,a) for polar.

....................................:

Name:              Tags
CheckSum:       # 49CAh
Size:             69.00

Takes a list of Names to be used as TAGs on 1:,
and Attaches them to the Objects on the Stack, 2: through n:.

....................................:
Name:            0-><-0 **
CheckSum:       # 581Ah
Size:            668.00

Circle to Circle finds the point(s) where there the two circles intersect.
Input is:
4:   (x,y)  Center of Circle ( Rectangular Coordinates ) 
3:       r  Radius of Circle
2:   (x,y)  Center of Circle ( Rectangular Coordinates )
1:       r  Radius of Circle

Output consist of:
3:   (x,y)  Intersection or Nothing
2:   (x,y)  Intersection or Nothing
1:  1 or 0  1 for Intersections found, 
            0 if no intersections found.

If the Circles are just Barely Touching, 
Then the One/Two Intersection(s) Would/Should be Equal.
The User is allowed to Specify how much The Two Circles may be apart from one
another before theyre Considered Genuinely Separated...!
To set this Variable, Open the program with EDIT and change the Value 
'.000000002' That is about 16 lines down, To whatever youd like.

....................................:
Name:             O.?.O **
CheckSum:       # 872Dh
Size:            429.00

How far Apart are Two Circles?
The Input consists of:
4:   (x,y)  Center of Circle ( Rectangular Coordinates )
3:       r  Radius of Circle
2:   (x,y)  Center of Circle ( Rectangular Coordinates )
1:       r  Radius of Circle

Output consist of:
2:   (x,y)  The MidPoint between the Circles
1:       d  Distance Between the Circles

The MidPoint and Distance between the Circles is measured from the Edges of the
Circles along a Ray that Intersects their Centers.
If The Distance is Negative, Then the Circles Intersect, Although the Edges may
not...???

....................................:
Name:               ./.  **
CheckSum:       # F8D6h
Size:            222.00

Mirrored point; finds the mirrored point on the other side of a ray.
Input is:
3:    (x,y) Point along Ray
2:    (x,y) SomeOther Point along Ray
1:    (x,y) Point not along Ray

Output is the mirrored (x,y).

....................................:
Name:              Pxdm
CheckSum:        # 77Ah
Size:             88.00

Returns the (x,y) dimensions of one pixel on PICT.

....................................:
Name:             .1to1
CheckSum:       # F1FFh
Size:            161.50

Modifies PPAR to make the pixels square, and returns the (x,y) dimensions of
one such modified pixel.

....................................:
..............................................:

Directory Name:     ELLPz
CheckSum:         # B468h
Size:             4652.50

%%HP: T(3)A(D)F(.);
DIR
  Ellps
    \<< RCLF \-> f
      \<< DEC DEG -16
CF 64 STWS
"ENTER ELLIPSES DIMENSIONS"
{ "W:"
"X AXES WIDTH FOR ELLIPSE?"
0 } { "H:"
"Y AXES HEIGHT FOR ELLIPSE?"
0 } { "F:"
"REAL FOC\161 ALONG THE X AXES?"
0 }
"KNOWN VARIABLES?"
{ {
"Width & Height"
        \<< DROP
          \<<
          \>>
        \>> } {
"Focii & Width"
        \<< 3 ROLLD
DROP
          \<< SWAP
OVER SQ SWAP SQ - \v/
          \>>
        \>> } {
"Focii & Height"
        \<< SWAP ROT
DROP
          \<< SWAP 0
R\->C 0 3 PICK R\->C -
ABS SWAP
          \>>
        \>> } } 1
CHOOSE
        \<< EVAL 4
ROLLD { "Pict x:"
"For Illustration-Width"
10 } { "Pict y:"
"For Illustration-Height"
10 } 4 \->LIST { 1 5
} { 6 4 # A6h # 50h
} { 0 0 # 83h # 40h
} INFORM
          \<< EVAL
            IFERR
PDIM
            THEN
# 83h # 40h PDIM
            END ROT
EVAL \-> x y
            \<< x y
R\->C x 0 R\->C 0 y R\->C
- ARG 90 + DUP2
(0,0) 90 Focus DUP
4 ROLLD IM NEG y +
3 ROLLD (0,0) 0
Focus DUP RE x SWAP
- x y x + 2 / - DUP
y + SQ SWAP SQ - \v/
DUP y - 6 PICK DUP
IM NEG ROT - 5 PICK
4 ROLL 5 PICK - DUP
5 ROLLD O\->\<-O DROP
SWAP DROP 4 ROLLD
OVER + 3 ROLLD {
"\Ga" "\Gar" "\Gb" "\Gbr"
"\GD" "\GDr" } Tags 6
DUPN ERASE Cpict
-.1 DUP x 1.05 *
XRNG y 1.05 * YRNG
\1831to1 DROP { (0,0)
1 } AXES DRAX 0 360
ARC 0 360 ARC x 0
R\->C 3 PICK - ARG 10
- 120 ARC x 0 R\->C 0
y R\->C 2 Dots 6 PICK
5 PICK DUP 5 PICK
Ray Ray f STOF
            \>>
          \>>
          \<< DROP f
STOF
"Interrupted!"
DOERR
          \>> IFTE
        \>>
        \<< 4 DROPN f
STOF
"Interrupted!"
DOERR
        \>> IFTE
      \>>
    \>>
  Bep
    \<< DUP TYPE 5 ==
      \<< EVAL
      \>>
      \<< 1 SWAP
      \>> IFTE \-> \Ge \GD
      \<< { { 20 15
.5 } { 100 20 .1 }
{ 2000 500 .02 } {
4000 1000 .005 } {
8000 10 .04 } } \GD
GET EVAL \-> a b c
        \<< RCLF -56
CF 1 \Ge
          START
RAND a * b + c BEEP
          NEXT STOF
        \>>
      \>>
    \>>
  Cpict
    \<< PICT SIZE 64
- 2 / SWAP 131 - 2
/ SWAP 2 \->LIST
PVIEW
    \>>
  Dots
    \<< DUP TYPE :&:
Pxdm EVAL RE 2 * \->
\-> r
      \<<
        CASE \-> 5 ==
          THEN OBJ\->
1
          END \-> 1
==
          THEN 1 1
          END \-> 0
==
          THEN 1
          END -56
CF PICT RCL LCD\->
PICT STO { # 0h
# 0h } PVIEW PICT
NEG RAND 3000 *
1000 + .05 BEEP
TEXT PICT STO -56
SF 0
        END
        \<< :&: Cpict
EVAL 1 SWAP
          START 4
:&: Bep EVAL r 0
360 ARC
          NEXT
        \>> IFT
      \>>
    \>>
  Focus
    \<< .2 WAIT KEY
      \<< DROP
"4: (x,y)  3: \<)
2: (x,y)  1: \<)"
"" INPUT OBJ\->
      \>> IFT \-> \Ga \GD \Gb
\.V
      \<< \Ga \Gb - R\->p
V\-> \.V - R\->C P\->r V\-> \GD
\.V - DUP ABS 90 >
        \<< 180 SWAP
- { + }
        \>>
        \<< { - }
        \>> IFTE 3
ROLLD TAN / SWAP
EVAL \.V R\->C P\->r \Gb +
      \>>
    \>>
  Ray
    \<< .2 WAIT KEY
      \<< DROP
"2: (x,y)
1: (x,y) or \<)"
"" INPUT OBJ\->
      \>> IFT DUP
TYPE
      \<< DUP2 - ARG
3 ROLLD OVER 2
      \>>
      \<< SWAP DUP 1
      \>> IFTE Dots \->
\Ga \183
      \<< PPAR 1 2
SUB EVAL - ABS 10 *
DUP \Ga R\->C P\->r \183 +
SWAP \Ga 180 + R\->C
P\->r \183 + LINE
      \>>
    \>>
  R\->p
    \<< RCLF SWAP -19
SF -16 SF V\-> -16 CF
\->V2 SWAP STOF
    \>>
  P\->r
    \<< RCLF SWAP -19
SF V\-> -16 SF \->V2
-16 CF SWAP STOF
    \>>
  Tags
    \<< OBJ\-> \-> $
      \<< 1 $
        START $ 1 +
ROLL SWAP \->TAG $
ROLLD
        NEXT
      \>>
    \>>
  O\->\<-O
    \<< .2 WAIT KEY
      \<< DROP
"Circles Intersect At?"
{ { "4:" "\Ga Center"
} { "3:" "\Ga Rad\161\161"
} { "2:" "\Gb Center"
} { "1:" "\Gb Rad\161\161"
} } { 1 3 } { (0,0)
1 (0,0) 1 } DUP
INFORM
        \<< OBJ\-> DROP
        \>>
        \<<
"Interupt!" DOERR
        \>> IFTE
      \>> IFT
.000000002 \-> \Ga \Ga\173 \Gb
\Gb\173 e
      \<< \Ga \Gb - ABS
\Ga\173 \Gb\173 3 DUPN + \<= 4
ROLLD - ABS \>= AND
        \<< \Gb\173 \Ga\173 \Ga \Gb
- ABS \Gb\173 \-> \183a \183b \183c
'ACOS((\183b^2+\183c^2-\183a
^2)/(2*\183b*\183c))+360'
\Ga \Gb - ARG + R\->C P\->r
\Gb + DUP \Ga \Gb ROT \:- 1
        \>>
        \<< \Ga \Ga\173 \Gb \Gb\173
O\183?\183O e \>=
          \<< DUP
          \>>
          \<< DROP 0
          \>> IFTE
        \>> IFTE
      \>>
    \>>
  O\183?\183O
    \<< .2 WAIT KEY
      \<< DROP
"LociOfCircles" { {
"4:"
"Rectangular Center of \Ga"
} { "3:"
"Rad\161\161 of \Ga" } {
"2:"
"Rectangular Center of \Gb"
} { "1:"
"Rad\161\161 of \Gb" } } {
1 3 } { (0,0) 1
(0,0) 1 } DUP
INFORM
        \<< OBJ\-> DROP
        \>>
        \<<
"Interrupted!"
DOERR
        \>> IFTE
      \>> IFT \-> \Ga \Ga\183
\Gb \Gb\183
      \<< \Ga \Gb - DUP
ARG SWAP ABS \Ga\183 \Gb\183
+ - DUP 2 / \Gb\183 +
ROT R\->C P\->r \Gb +
SWAP
      \>>
    \>>
  \:-
    \<< .2 WAIT KEY
      \<< DROP
"3:  Line End (x,y)
2:  Line End (x,y)
1: Reference (x,y)"
"" INPUT OBJ\->
      \>> IFT \-> \1831 \1832
\1833
      \<< \1831 \1832 - ARG
\1833 \1832 - DUP ABS
SWAP ARG 3 PICK -
NEG ROT + R\->C :&:
P\->r EVAL \1832 +
      \>>
    \>>
  Pxdm
    \<< { # 1h # 0h }
PX\->C { # 0h # 1h }
PX\->C -
    \>>
  \1831to1
    \<<
      \<< { # 1h # 0h
} PX\->C { # 0h # 1h
} PX\->C -
      \>> DUP EVAL V\->
DUP2 MAX OVER ==
      \<< SWAP / *W
      \>>
      \<< / *H
      \>> IFTE EVAL
    \>>
  PPAR {
(-9.99999999976E-2,-.50466052916)
(8.4,3.56503644017)
X 0 { (0,0) 1 }
FUNCTION Y }
END

-[ Terminus ]-