HP Forums

Full Version: Problem with polar_coordinates()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Bonjour,

Windows 10 Pro Rev : 1709
HP Prime virtual calculator Build 2018 1 24 Rev : 13333

iPhone IOS V : 11.2.6
IOS HP Prime V : 1.4.1.13513

Problem with polar_coordinates() (in degree mode)

Functions Library extract …
------------------
// Conversion R-P
EXPORT rp(X,Y)
BEGIN
M0:=polar_coordinates(X,Y);
MSGBOX(X) ;
MSGBOX(Y) ;
MSGBOX(M0) ;

RETURN(M0) ;
END ;
------------
This function works on iPhone with keyboard input (X, Y and M0 msgboxes are OK).
This function does not work in program mode with iPhone, (M0 stay [0,0] with msgbox).

The same program work exhaustively with HP Prime virtual calculator on my desktop without any problem.

Is there a bug on the new IOS HP Prime or there is a problem with my function. (With old IOS HP Prime version, funtion worked correctly).
I have uninstalled and installed IOS HP Prime, switched off an on IOS device several times without change.

Thanks a lot for your attention
I'm not seeing this on a version I just built and am running in the iOS simulator. I don't have any hardware handy to check on.

I tried running the function directly from the HOME screen

rp(10,10) [ENTER] for example. I then see a 10 box, 10 box and then [14.14..., .0785...] in a box. The vector is returned.

Is that what I should be testing? Anyone else see this issue?
Bonsoir,

I found an elegant solution from Michael de Estrada :

// Conversion P-R
EXPORT pr(X,Y)
BEGIN
RETURN[X*COS(Y),X*SIN(Y)];
//RETURN(X*COS(Y),X*SIN(Y));
END;

// Conversion R-P
EXPORT rp(X,Y)
BEGIN
RETURN[ABS((X,Y)),ARG((X,Y)) MOD 360];
//RETURN(ABS((X,Y)),ARG((X,Y)) MOD 360);
END;

Thanks a lot for your attention.
Hello,

I do not think that the mod 360 is a good idea.
First, ARG should only return values from 0 to 360.
Furthemore, this code is assuming degree mode (which is not a given).

I would therefore suggest removing it.

Cyrille
Bonjour,

Ok, If ARG() returns the correct value (for me), I agree with you to remove "MOD 360" but it does not.

Thank you for your comment.
(03-13-2018 09:41 AM)cyrille de brébisson Wrote: [ -> ]ARG should only return values from 0 to 360.

(03-13-2018 09:54 AM)Lamas Wrote: [ -> ]Ok, If ARG() returns the correct value (for me), I agree with you to remove "MOD 360" but it does not.

Lamas is right. They are different. In degree mode, ARG returns angles in the interval (-180,180], whereas MOD 360 returns values in the interval [0,360).
aquí un vídeo del tema que tratas de solucionar


On Home Mode fail

phasor1 := ( √(2) ∡ 3*(π/4) ); "Syntax Error"

More info
http://www.hpmuseum.org/forum/thread-798...70023.html
Hello,

I did not realize that the result was in the -180, 180 range. Then, maybe the mod should be with 2*acos(-1))

Cyrille
A couple of years ago I requested that atan2 be put on a list for future release enhancements. This would be useful for programs that need the inverse tangent mapped to the interval [0,2*pi). Polar coordinates, and navigation software are typical examples. It's easy to create a stand-alone program for this, but with all the other tools in the toolbox, atan2 seems like it would be a useful addition.

https://en.wikipedia.org/wiki/Atan2

-Dale-
(03-16-2018 02:04 PM)DrD Wrote: [ -> ]A couple of years ago I requested that atan2 be put on a list for future release enhancements. This would be useful for programs that need the inverse tangent mapped to the interval [0,2*pi). Polar coordinates, and navigation software are typical examples. It's easy to create a stand-alone program for this, but with all the other tools in the toolbox, atan2 seems like it would be a useful addition.

https://en.wikipedia.org/wiki/Atan2

-Dale-

+1
(03-16-2018 02:04 PM)DrD Wrote: [ -> ]A couple of years ago I requested that atan2 be put on a list for future release enhancements. This would be useful for programs that need the inverse tangent mapped to the interval [0,2*pi). Polar coordinates, and navigation software are typical examples. It's easy to create a stand-alone program for this, but with all the other tools in the toolbox, atan2 seems like it would be a useful addition.

https://en.wikipedia.org/wiki/Atan2

-Dale-

Note that the linked article has an RPL equivalent, but it is incorrect. It should be
\<< R\->C ARG \>>
(03-12-2018 06:02 PM)Lamas Wrote: [ -> ]Bonjour,

Windows 10 Pro Rev : 1709
HP Prime virtual calculator Build 2018 1 24 Rev : 13333

iPhone IOS V : 11.2.6
IOS HP Prime V : 1.4.1.13513

This function works on iPhone with keyboard input (X, Y and M0 msgboxes are OK).
This function does not work in program mode with iPhone, (M0 stay [0,0] with msgbox).


I ran the same program on iOS 11.3 with Prime Pro app 1.4.1.13513 and it works fine. Maybe the newer version of iOS fixed the problem.
Bonjour,

I just checked with the last firmwares update and I found, like you, that the problem disappeared. It is OK now.

Thanks a lot for your reply.
Well that is kind of bizarre... :?
Reference URL's