HP 48G coordinate join program  Printable Version + HP Forums (https://archived.hpcalc.org/museumforum) + Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum1.html) + Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum2.html) + Thread: HP 48G coordinate join program (/thread100802.html) 
HP 48G coordinate join program  dan  10092006 I was wondering if anyone can give me some advice on how to use one set of input data to do two caculations? i'm writing a coordinate join program for my 48g (im not very skilled i only learnt to program a few hours ago) and i want my set of eastings and northings for 2 points to be able to calculate horizontal distance and quadrant angle, which they can already do by themselves, but i cant seem to combine them together properly into one soft key. here is what ive come up with so far:
Hoz Distance: << > A B C D 'sqrt( (CA)^2 + (DB)^2)' >> Quadrant Angle: << > A B C D 'ATAN( (DB) / (CA) )' >> *where A,B,C and D are east1, north1, east2, north2, respectively I want these two values to be either side by side such as (Dist, QA), or in different stack positions (preferrably the latter) such as:
2: 155.396 any advice would be greatly appreciated!
cheers, Re: HP 48G coordinate join program  Bruno FĂ©rard  10092006 Hi! I hoped I understood your issue correctly. Actually the easiest is to merge both programs in one : << > A B C D << 'sqrt((CA)^2+(DB)^2)' EVAL 'ATAN((DB)/(CA))' EVAL >> To get the 2 values on the stack. If your prefer to have it displayed in cimplex form, you just need to add R>C after the last EVAL.
Now if you prefer keeping 2 separate programs, you can create a new one like this :
Regards, Bruno
Re: HP 48G coordinate join program  Han  10092006 The HP48 series can also take an algebraic expression instead of a subprogram. For example,
<< > A 'A^2+4' >> would also work. If you want it in complex mode (note you may need to change the system flags on how a complex number is displayed: u+vi versus (u,v))
<< would get the job done and return a complex number whose real part is the distance and whose imaginary part represents the angle. You can optionally add in the command C>R to convert from complex to two reals:
<< To add to Bruno's post, if you stored the distance program under DIST and the angle program under ANGL the you could just use the following program:
<< Edited: 9 Oct 2006, 8:18 p.m.
Re: HP 48G coordinate join program  Han  10092006 Depending on your system flags, sometimes EVAL will not produce numerical results (has to do with symbolic vs numeric results). You may want to use >NUM instead, as this will always ensure that your results are numerical and not symbolic (algebraic expressioni involving the sqrt function).
Han
Re: HP 48G coordinate join program  Marcus von Cube, Germany  10102006 Quote:<< This is syntactically incorrect because you can either use an algebraic after > or a program but not an algebraic followed by some other command.
If you want a complex number where the angle is in fact an angle, try the following: <<<) is the angle symbol (right shift space on the 48). Go to the modes screen and change the coordinate system to 'Polar', otherwise your results are displayed in rectangular coordinates. You can switch between these display modes and watch the effect on the stack.
Marcus
Re: HP 48G coordinate join program  dan  10102006 thanks everyone for all your help, this is a really helpful forum here! the EVAL worked just fine, but i will certainly play around with all the other suggestions to learn some more about RPL.
thanks again ;)
Re: HP 48G coordinate join program  Chiu Yiu Wai  10102006 it is my join program, wish it can give you some hints, one pair value > two calculation > two answer
if you use other hp RPN calculator, you will find that
1 enter 1 >P I think that you know the different 45 and 135
<< RECT * set calculator to rectangular mode ** you can refer the vector function from you manual
Re: HP 48G coordinate join program  Han  10102006 Quote: Actually, it is in fact syntactically correct. One just has to keep in mind that whatever follows that algebraic object (or program) can not require the input that is used since the scope of those variables lies within the algebraic object and not anywhere outside. The > function simply allows us to embed a subroutine within a program directly. So more commands can follow if we want. In other words, << > T 'T^2' 2 + >> with input 2 would correctly return the expected result 8. However << > T 'T^2' T + >>
with input 2 would return unexpected results (depends on what T is). But you are right about the polar vs rectangular mode. I just realized I was in rectangular mode, so that my solution would be ok. However if one is in polar mode, then the <) is needed.
Edited: 10 Oct 2006, 5:44 p.m.
Re: HP 48G coordinate join program  Marcus von Cube, Germany  10112006 Han, thanks for the clarification about the use of > and the local variable scoping.
Quote: That's not quite correct. The polar/rectangular mode setting has an influence just on the display of complex numbers or vectors, not on the entry format. If you want to enter a complex number in polar coordinates, you must use the angle symbol on the second number. What my proposal actually meant was to represent a value that is actually composed of a length and a direction in the calculator as such. So no matter what the display format is, the angle symbol in the formaula always a good idea if you want to perform other operations on the value. In order to see it correctly, polar display should be set. As a hint to Dan: Just use complex numbers or vectors for your calculation. Put two of them on the stack, add them together and choose the proper display format. You can use the functions ABS and ARG to extract the vector length and angle of the result, respectively.
Marcus
Re: HP 48G coordinate join program  Han  10112006 Marcus, Ahh, now I am beginning where I was confused. I think your suggestion about using complex numbers is indeed the best, as the ABS and ARG functions save us from having to write programs for those values (and saves a few bytes of RAM, too).
Han
