home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / hp48 / 6410 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  2.2 KB

  1. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!ncr-sd!ncrcae!ncrhub2!ncrwat!john.Latala
  2. From: john.Latala@Waterloo.NCR.COM (john Latala)
  3. Newsgroups: comp.sys.hp48
  4. Subject: solving triangles
  5. Message-ID: <10313@ncrwat.Waterloo.NCR.COM>
  6. Date: 19 Dec 92 13:34:24 GMT
  7. Sender: news@ncrwat.Waterloo.NCR.COM
  8. Lines: 56
  9.  
  10. I wrote a number of routines for solving various triangle combinations,
  11. things like SSS, SAS, SSA, ... . These work quite well. but after
  12. playing with them for a while I thought it would be nice to make a nice
  13. 'wrapper' program that would figure out which routine to call all by
  14. itself.
  15.  
  16. I was thinking of a routine that takes an argument like:
  17.  
  18.     { S1 A1 S2 A2 S3 A3 }
  19.  
  20. for the three sides and three angles. If all you have are the sides you
  21. would use:
  22.  
  23.     { S1 ? S2 ? S3 ? }
  24.  
  25. and the routine would return with the '?' replaced by their correct
  26. values. In the case where there are two possible solutions to the
  27. triangle something like:
  28.  
  29.     { S1 A1 S2 { A2.1 A2.2 } { S3.1 S3.2 } { A3.1 A3.2 } }
  30.  
  31. would come back.
  32.  
  33. The problem I'm having is coming up with a way to code the wrapper
  34. program so it doesn't take forever to run.
  35.  
  36. Initially I was thinking of scanning an input like { S1 ? S2 ? S3 ? }
  37. and converting each known value to a 1 and each unknown value to a 0
  38. then treating the number as a binary.  The three sides case would be
  39. taken as #101010b.
  40.  
  41. This leads to 64 possible cases which makes for a rather large and ugly
  42. case statement to say the least.
  43.  
  44. Another technique I've used on a couple of programs is to keep two
  45. parallel lists. The first one is a selector list while the second one
  46. has a list of matching programs:
  47.  
  48.     Selector : { N1 N2 N3 ... Nn }
  49.     Programs : { << p1 >> << p2 >> << p3 >> ... << pn >> }
  50.  
  51. doing a sequence like:
  52.  
  53.     PROGRAM SELECTOR n POS GET EVAL
  54.  
  55. will use the position of n in the selector list to pick a code fragment
  56. out of the program list that gets evaluated (the actual code is a little
  57. more complicated because if checks if the POS returns a 0).
  58.  
  59. Even this method seems like a lot of effort.
  60.  
  61. Can anybody think of an easier way of doing this kind of decoding?
  62. --
  63. john.Latala@Waterloo.NCR.COM
  64.  
  65. [ ... unused entry in the random signature database ... ]
  66.