home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!ncr-sd!ncrcae!ncrhub2!ncrwat!john.Latala
- From: john.Latala@Waterloo.NCR.COM (john Latala)
- Newsgroups: comp.sys.hp48
- Subject: solving triangles
- Message-ID: <10313@ncrwat.Waterloo.NCR.COM>
- Date: 19 Dec 92 13:34:24 GMT
- Sender: news@ncrwat.Waterloo.NCR.COM
- Lines: 56
-
- I wrote a number of routines for solving various triangle combinations,
- things like SSS, SAS, SSA, ... . These work quite well. but after
- playing with them for a while I thought it would be nice to make a nice
- 'wrapper' program that would figure out which routine to call all by
- itself.
-
- I was thinking of a routine that takes an argument like:
-
- { S1 A1 S2 A2 S3 A3 }
-
- for the three sides and three angles. If all you have are the sides you
- would use:
-
- { S1 ? S2 ? S3 ? }
-
- and the routine would return with the '?' replaced by their correct
- values. In the case where there are two possible solutions to the
- triangle something like:
-
- { S1 A1 S2 { A2.1 A2.2 } { S3.1 S3.2 } { A3.1 A3.2 } }
-
- would come back.
-
- The problem I'm having is coming up with a way to code the wrapper
- program so it doesn't take forever to run.
-
- Initially I was thinking of scanning an input like { S1 ? S2 ? S3 ? }
- and converting each known value to a 1 and each unknown value to a 0
- then treating the number as a binary. The three sides case would be
- taken as #101010b.
-
- This leads to 64 possible cases which makes for a rather large and ugly
- case statement to say the least.
-
- Another technique I've used on a couple of programs is to keep two
- parallel lists. The first one is a selector list while the second one
- has a list of matching programs:
-
- Selector : { N1 N2 N3 ... Nn }
- Programs : { << p1 >> << p2 >> << p3 >> ... << pn >> }
-
- doing a sequence like:
-
- PROGRAM SELECTOR n POS GET EVAL
-
- will use the position of n in the selector list to pick a code fragment
- out of the program list that gets evaluated (the actual code is a little
- more complicated because if checks if the POS returns a 0).
-
- Even this method seems like a lot of effort.
-
- Can anybody think of an easier way of doing this kind of decoding?
- --
- john.Latala@Waterloo.NCR.COM
-
- [ ... unused entry in the random signature database ... ]
-