Post Reply 
Set program angle mode
05-06-2024, 11:52 AM
Post: #1
Set program angle mode
Hello,

Is there a function to set program angle units to automatically calculate in radians?

Like this jacobian matrix program
Code:
#cas
 jacob(args):=
 begin
 local argv,argc,mat,f;
 LOCAL var,fn,j,k,gr,vd;
 argv:=[args];
 argc:=size(argv);
 IF argc == 3 THEN
   return subst(transpose(diff(argv[1],argv[2])),argv[3]);
  END;
 IF argc == 2 THEN
   return transpose(diff(argv[1],argv[2]));
  END;
 return "Input:[f1(x1,...,xn),...,fm(x1,...,xn)], [x1,...,xn][,[x1=a1,...xn=an]]"; 
 end;
#end

Credits to slavomic & Arno K : topic https://www.hpmuseum.org/forum/thread-3852.html

To make it automatically run in radian mode?

I've found commands/ functions
HAngle = 0 for Radians mode
HAngle = 1 for Degrees mode
HAngle = 2 for Gradians mode

HAngle:=0;

But when I add this code, Error bad argument, or it stays in Degree mode leaving "pi" in derivates.

Code:
#cas
 jacob(args):=
 begin
 local argv,argc,mat,f;
 LOCAL var,fn,j,k,gr,vd;
HAngle:=0;
 argv:=[args];
 argc:=size(argv);
 IF argc == 3 THEN
   return subst(transpose(diff(argv[1],argv[2])),argv[3]);
  END;
 IF argc == 2 THEN
   return transpose(diff(argv[1],argv[2]));
  END;
 return "Input:[f1(x1,...,xn),...,fm(x1,...,xn)], [x1,...,xn][,[x1=a1,...xn=an]]"; 
 end;
#end

I just want to leave my calculator in Degree mode, but when I input the jacobian matrix and run the program for it to be automatically in radian mode so I don't have to manually change Degrees-> Radian ( input, and run program) then return to Degrees
hope you understand what im trying to achieve.
Find all posts by this user
Quote this message in a reply
05-06-2024, 01:18 PM (This post was last modified: 05-06-2024 01:20 PM by StephenG1CMZ.)
Post: #2
RE: Set program angle mode
Apparently either
HAngle:=
Or
AAngle:=
can be used from code, although there is this thread regarding a possible bug.
https://www.hpmuseum.org/forum/thread-19...ght=Hangle

I wonder if the problem is that HAngle is a PPL variable and the code snippets are cas?

Unfortunately I don't have a HP Prime app to check.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
05-07-2024, 07:09 AM (This post was last modified: 05-07-2024 07:10 AM by Amer7.)
Post: #3
RE: Set program angle mode
(05-06-2024 01:18 PM)StephenG1CMZ Wrote:  Apparently either
HAngle:=
Or
AAngle:=
can be used from code, although there is this thread regarding a possible bug.
https://www.hpmuseum.org/forum/thread-19...ght=Hangle

I wonder if the problem is that HAngle is a PPL variable and the code snippets are cas?

Unfortunately I don't have a HP Prime app to check.

AAngle:=1; works when I insert it after Local variables.
Example: Calculator set in Degrees
I run the program, it returns correct answer in radians ( and it switches calculator in Radian) it doesn't stay in degrees.
I don't think it's ideal, but i think its much better than manually switching.
Thank you
Find all posts by this user
Quote this message in a reply
05-07-2024, 03:52 PM (This post was last modified: 05-07-2024 03:52 PM by toml_12953.)
Post: #4
RE: Set program angle mode
(05-07-2024 07:09 AM)Amer7 Wrote:  
(05-06-2024 01:18 PM)StephenG1CMZ Wrote:  Apparently either
HAngle:=
Or
AAngle:=
can be used from code, although there is this thread regarding a possible bug.
https://www.hpmuseum.org/forum/thread-19...ght=Hangle

I wonder if the problem is that HAngle is a PPL variable and the code snippets are cas?

Unfortunately I don't have a HP Prime app to check.

AAngle:=1; works when I insert it after Local variables.
Example: Calculator set in Degrees
I run the program, it returns correct answer in radians ( and it switches calculator in Radian) it doesn't stay in degrees.
I don't think it's ideal, but i think its much better than manually switching.
Thank you

HAngle sets angle mode globally, AAngle sets it during the current program's run only.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
05-08-2024, 12:34 PM
Post: #5
RE: Set program angle mode
(05-07-2024 03:52 PM)toml_12953 Wrote:  HAngle sets angle mode globally, AAngle sets it during the current program's run only.

I don't think that's correct. AAngle sets the angle mode for the current app, overriding the setting of HAngle. Every app has its own AAngle setting. It does NOT automatically reset when a program ends. Press Vars [CAS] Function Modes Help to see the Help screen about AAngle, and press Vars [Home] Settings Help to see the Help screen about HAngle.

BOTTOM LINE: HAngle sets the angle mode UNLESS AAngle>0, in which case HAngle is ignored and the angle mode is set by AAngle. Yes, HAngle is global across all apps, but AAngle is not local to programs, it is different in each app.

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
05-09-2024, 11:44 AM
Post: #6
RE: Set program angle mode
Thank you guys for the feedback!
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)