Program format from 33s to 35s



#5

Hello all.

I am new to this forum. I've been reading the posts for a ehile, and decided to go ahead and post my question. I am hoping to get some help from some of the experts whose messages I have been reaing recently.

I used the program from Dave Coffin for the HP-33s for distance and bearing calculation. Now, I have just bought a 35s, and have found that the polar to rectangular conversion just doesnt work the same way. Unfortunately, I am just an airline pilot, and am no computer or math expert.

I was hoping that someone could help me modify this program to make it work in the HP-35s, since replacing the critical lines (D08, D13, D16, D20, D25) by the routines I read about yesterday in this site dont make it work.

Here's the Dave Coffin program:

D01 LBL D
D02 DEG
D03 INPUT N
D04 STO X
D05 INPUT E
D06 INPUT N
D07 1
D08 (polar to rectangular)
D09 INPUT E
D10 R up
D11 -
D12 x<>y
D13 (polar to rectangular)
D14 R up
D15 x<>y
D16 (rectangular to polar)
D17 x<>y
D18 RCL- X
D19 x<>y
D20 (polar to rectangular)
D21 180
D22 Rdown
D23 Rdown
D24 +/-
D25 (rectangular to polar)
D26 Rdown
D27 -
D28 x<>y
D29 ACOS
D30 60
D31 ×
D32 RTN

You enter initial Latitude and Longitude and Final Latitude and Longitude, and it returns the distance in nautical miles and true departure course to fly the great circle trajectory.

I hope I am not bothering the audience with my ignorance about HP calculators.

Thanks in advance for any help.

Rafael.

Edited for grammar.

Edited: 15 Sept 2007, 2:39 p.m.


#6

Welcome, Rafael!

Quote:
Unfortunately, I am just an airline pilot, and am no computer or math expert.

Certainly no need to be humble about that...

Quote:
Now, I have just bought a 35s, and have found that the polar to rectangular conversion just doesnt work the same way (as it did in the HP-33s).

Yes, this has been source of considerable consternation in this group. I belive that it was a horrible idea.

I've also had to deal with that same issue while porting my HP-32S/32SII/33s program to the HP-35s. The basic problem is that while "Th,r->y,x" and "y,x->Th,r" utilize only two stack registers, the conversion procedures that would be employed on the HP-35s almost always require more. This might cause the program to fail, by causing stack overload.

If the program were optimized for the HP-35s, many of the conversions could be eliminated, with calculations done using complex numbers in polar mode. But that would take some effort.

Polar to rectangular:

I replaced "Th,r->y,x" with code that used all four stack registers.

(magnitude)
ENTER
ENTER
(angle value)
ENTER
SIN
x<>y
COS
Roll_up
* (result is x-coordinate)
Roll_down
* (result is y-coordinate)

For two-level calculations, an alternative is to store results and inputs to lettered registers, then recall them as necessary:

(magnitude)
STO M
(angle value)
STO A
SIN
* (result is y-coordinate)
x<> M
RCL A
COS
* (result is x-coordinate)
RCL M (result is y-coordinate)

Rectangular to polar:

The difficulty is that ARG (or conversion to polar representation of a complex number) is the only way to access the "atan2" function, which gives the proper quadrant of the angle -- very important in navigation.

Using complex-valued functions, with one extra stack register:

(x-coordinate)
(y-coordinate)
i
*
+
ENTER
ABS (result is magnitude)
x<>y
ARG (result is angle value)

To use only two stack registers will require a storage register and a bit more thought...

Quote:
I hope I am not bothering the audience with my ignorance about HP calculators.

Thanks in advance for any help.


Not at all; our pleasure.

-- KS


Edited: 15 Sept 2007, 6:50 p.m.


#7

Rafael,

Like Karl says, welcome! Following up on some of Karl's points, the following routines preserve the stack and Last X and require no registers:

Rectangular to Polar
ABS
Roll Down
Roll Down
Eqn LASTx+i*REGT
ENTER
Roll Down
Roll Down
Eqn ARG(REGT)
Eqn ABS(REGT)
RTN

Polar to Rectangular
ABS
x<>y
Roll Down
Roll Down
Eqn LASTx*SIN(REGZ)
Eqn LASTx*COS(REGT)
RTN

The original program you presented would appear as follows with these routines added as subroutines:

D001  LBL D
D002 DEG
D003 INPUT N
D004 STO X
D005 INPUT E
D006 INPUT N
D007 1
D008 XEQ D043 (polar to rectangular)
D009 INPUT E
D010 R up
D011 -
D012 x<>y
D013 XEQ D043 (polar to rectangular)
D014 R up
D015 x<>y
D016 XEQ D033 (rectangular to polar)
D017 x<>y
D018 RCL- X
D019 x<>y
D020 XEQ D043 (polar to rectangular)
D021 180
D022 Rdown
D023 Rdown
D024 +/-
D025 XEQ D033 (rectangular to polar)
D026 Rdown
D027 -
D028 x<>y
D029 ACOS
D030 60
D031 ×
D032 RTN
D033 ABS
D034 Roll Down
D035 Roll Down
D036 Eqn LASTx+i*REGT
D037 ENTER
D038 Roll Down
D039 Roll Down
D040 Eqn ARG(REGT)
D041 Eqn ABS(REGT)
D042 RTN
D043 ABS
D044 x<>y
D045 Roll Down
D046 Roll Down
D047 Eqn LASTx*SIN(REGZ)
D048 Eqn LASTx*COS(REGT)
D049 RTN


Of course it would be far better if the next version of the 35s looks like this:





Edited to replace the original routines with Miguel's improved versions.

Edited: 17 Sept 2007, 10:11 a.m. after one or more responses were posted


#8

Hello Jeff and welcome Rafael,

Please see at this two versions for P->R and R->P, they are shorter and get the same result (they preserve the stack and LAST x), I think:

Polar to Rectangular
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
ABS
x<->y
RDN
RDN
eqn LASTx*SIN(REGZ)
eqn LASTx*COS(REGT)
RTN

Rectangular to Polar
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
ABS
RDN
RDN
eqn LASTx+i*REGT
ENTER
RDN
RDN
eqn ARG(REGT)
eqn ABS(REGT)
RTN

Please tell me what you think.

Regards,

Miguel


Edited: 16 Sept 2007, 9:53 a.m. after one or more responses were posted


#9

Usage of ABS as first line makes both routines give wrong answer where DIST or Y-coord is negative. Also using equations implies taking into consideration status of flag 10.

Regards,
Reth

Edited: 16 Sept 2007, 6:17 a.m.


#10

Thanks a lot for all for your quick replies to my message.

I'll input your routines in the 25s and will perform some sample calculations. I will compare the calc returns to the correct answer and will let you know, since some have pointed out possible errors.

Stay well.

Rafael.


#11

Hello colleague!

Quote:
I will compare the calc returns to the correct answer and will let you know, since some have pointed out possible errors.

I can tell you right now that you will not get any correct answer by trying to solve a spherical problem (= great circle navigation) by using a flat approach (i.e. using those built-in or homemade P/R conversions). It will work sufficiently well for very short distances only.

You need to program the correct formulae instead (look here for example: http://en.wikipedia.org/wiki/Great-circle_distance ) if you want correct results.

Anyway: Please don't tell me that you intend to navigate along great circle routes by typing co-ordinates into your pocket calculator (or that your employer allows you to do that!). Otherwise I will prefer to stay on the ground while you are up there ;-)

Happy landings,
Max


#12

Quote:
Hello colleague!

I can tell you right now that you will not get any correct answer by trying to solve a spherical problem (= great circle navigation) by using a flat approach (i.e. using those built-in or homemade P/R conversions). It will work sufficiently well for very short distances only.

You need to program the correct formulae instead (look here for example: http://en.wikipedia.org/wiki/Great-circle_distance ) if you want correct results.

Anyway: Please don't tell me that you intend to navigate along great circle routes by typing co-ordinates into your pocket calculator (or that your employer allows you to do that!). Otherwise I will prefer to stay on the ground while you are up there ;-)

Happy landings,
Max


Max!

Nah, dont worry! I trust our two good old million-dollar Honeywell FMS's, along with our three laser gyro IRS's on board for actual navigation over the atlantic in the Airbus.

If those fail, there is a completely detailed procedure for that.

This is just a little hobby I got going, and since I already succeeded solving spherical trigonometry ecuations in the older and bigger HP-48sx for the calculation of the great circle distances and angles, I wanted to approach this problem in the smaller HP-35s.

It's spherical triangle ecuations you got me working on "as we speak", but as I said, I'm no computer expert and it's hard.

Happy landings to all,

Rafael.

#13

Hi Reth,

In the P->R procedure that is prevented thanks to the use of LASTx: the original value before the ABS is there.

I corrected the R->P procedure to have the same behavior: the use of LASTx to recover the original value.

You are right about the flag 10 and that will depend on the use of these routines in Rafael's program.

Thanks,

Miguel


Edited: 16 Sept 2007, 9:57 a.m.

#14

Quote:
Please tell me what you think.

I think I like them better than my versions. Nice work!
#15

For a long article on rectangular to polar conversions look at this discussion. By the end, the programs for doing the conversion were pretty good. I've submitted the "best" to the museum for inclusion in the software library. I've also included them here:

P001  LBL P
P002 FS? 10
P003 GTO P011
P004* Rv
P005 Rv
P006 eqn REGZ+i*REGT
P007 ARG
P008 LASTx
P009 ABS
P010 RTN
P011* CF 10
P012 XEQ P004
P013 SF 10
P014 RTN

R001 LBL R
R002 FS? 10
R003 GTO R012
R004* Rv
R005 Rv
R006 eqn [REGZ*SIN(REGT),REGZ*COS(REGT)]
R007 [1,0]
R008 x<>y
R009 *
R010 EQN LASTx*[0,1]
R011 RTN
R012* CF 10
R013 XEQ R004
R014 SF 10
R015 RTN

Both routines preserve the Z and T registers and return their results in the X and Y registers. The are also independent of the settings on the calculator and honour the current trig mode.

- Pauli


Possibly Related Threads...
Thread Author Replies Views Last Post
  Prime: how to detect date format giancarlo 1 878 12-02-2013, 11:21 AM
Last Post: Michael de Estrada
  HP 50g - displaying result in engineering format Sean Freeman 10 1,947 11-24-2013, 05:44 AM
Last Post: C.Ret
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 1,545 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  HP PRIME: Fixed 4 number format 0.001000 Joseph Ec 18 3,300 11-07-2013, 11:51 AM
Last Post: Geoff Quickfall
  PRIME: re-format the flash drive to recover the operating system Harold A Climer 2 1,019 11-06-2013, 12:22 AM
Last Post: Michael de Estrada
  File Format: hpprgm Thomas Chrapkiewicz 6 1,595 10-30-2013, 09:32 PM
Last Post: Thomas Chrapkiewicz
  Interesting Base Conversions - Porting a 1975 HP 25 Program to the HP 35S Eddie W. Shore 1 815 10-13-2013, 07:49 PM
Last Post: BruceH
  33s, 35s & 42s--The Timex(R) Factor Matt Agajanian 7 1,294 09-13-2013, 12:28 AM
Last Post: Matt Agajanian
  go71b 'lexs' or 'raws' file format? Christoph Giesselink 2 868 08-21-2013, 02:53 AM
Last Post: Christoph Giesselink
  Planar Triangles Program: HP 35S Eddie W. Shore 0 583 06-02-2013, 11:15 AM
Last Post: Eddie W. Shore

Forum Jump: