Re: Storing to Geometry App variables (HP Prime) (910 Views)
Reply
Advisor
StefanD
Posts: 12
Registered: ‎12-05-2013
Message 1 of 10 (964 Views)

Storing to Geometry App variables (HP Prime)

I am trying to write a little program to make a plot of a vector field. I want to create the vectors in the Geometry App variables (GA, GB, ...)

 

I tried around a little bit, but it seems that I can't store anything to these variables. For example if I do the following in the CAS view the variable GA remains unchanged in the Geometry symbolic view:

GA:=vector(1+i)

 I also tried to assign the variable from within program code in the Geometry App program. This does not work either.

 

Any ideas?

 

- Stefan

 

Trusted Contributor
cyrille
Posts: 78
Registered: ‎11-18-2004
Message 2 of 10 (910 Views)

Re: Storing to Geometry App variables (HP Prime)

Hello,

 

The short answer is that you can not....

The geometry variables are more like program locals, not variables like the others.

Basicaly, what happends is that the geometry app maintains and saves a list of instructions of the form:

GA:= graphic instr 1

GB:= graphic instr 2

...

GZ:= graphic instr 26

 

and then 'executes' the program to create CAS objects that descibes the drawing of each elements.

the G?:= is nessecary to allow later reuse of the resulting object

Each time something changes, the whole program is re-executed and all the variables will be overriden...

 

so, to do what you wanted, you would need to change the geometry program. Unfortunately, there is no variable that represents it at this point in time.

 

sorry.

 

cyrille

Advisor
StefanD
Posts: 12
Registered: ‎12-05-2013
Message 3 of 10 (875 Views)

Re: Storing to Geometry App variables (HP Prime)

That is sad.

 

Now I am working my way around it. I wrote a litte program to draw vectors:

LOCAL drw_vect(XY,LOC) //XY is a complex number giving the compponents of the vector. LOC is a complex number, giving the location on the screen where the tail of the vector starts.
BEGIN
LOCAL X, Y, LOCX, LOCY, TLS, TWS;
LOCAL T1X, T1Y, T2X, T2Y; // Points to draw the arrow tip.
TLS:=0.85; // Tip length scaling factor.
TWS:=0.05; // Tip width scaling factor
X:=RE(XY); // X component of the vector
Y:=IM(XY); // Y component of the vector
LOCX:=RE(LOC); // Location X component
LOCY:=IM(LOC); // Location Y component

// calculate coordinates for arrow tip
T1X:=LOCX+TLS*X-TWS*Y;
T1Y:=LOCY+TLS*Y+TWS*X;
T2X:=LOCX+TLS*X+TWS*Y;
T2Y:=LOCY+TLS*Y-TWS*X;

LINE(LOCX,LOCY,LOCX+X,LOCY+Y,1); //Draw body of the arrow
TRIANGLE(T1X, T1Y, T2X, T2Y,LOCX+X, LOCY+Y,0); // draw tip pf the arrow
END;

 Stefan

Frequent Advisor
Vlad_AB
Posts: 25
Registered: ‎06-26-2013
Message 4 of 10 (861 Views)

Re: Storing to Geometry App variables (HP Prime)

Hi, StefanD !

 

Try the plotfield command.

 

ans0812201301.JPG

 

ans0812201302.JPG

 

ans0812201303.JPG

 

or

 

ans0812201304.JPG

 

ans0812201305.JPG

Honored Contributor
Tim Wessman
Posts: 790
Registered: ‎01-08-2009
Message 5 of 10 (850 Views)

Re: Storing to Geometry App variables (HP Prime)

Yes, this is probably the best way to accomplish what you are wanting at the moment.

 

However, the CAS variables are not going to follow along with your geometry app copy, so that might be problematic for the moment.

--

TW


Although I work for the HP calculator group, the views and comments expressed here are my own.
Advisor
StefanD
Posts: 12
Registered: ‎12-05-2013
Message 6 of 10 (793 Views)

Re: Storing to Geometry App variables (HP Prime)

I think the plotfield command is not quite what I want. I would like to enter a R^2 -> R^2 function. In other words a function that depends on x and y and gives a 2D vector as output.

 

That is what I hacked together so far. It is still all hard coded, no fancy menus to enter the function or the limits in which the function is evaluated. I also have some hard coded scaling factors in the code because I don't know how I can adjust the zoom level. But I think you get the idea:

 

LOCAL drw_vect(XY,LOC) //XY is a complex number giving the compponents of the vector. LOC is a complex number, giving the location on the screen where the tail of the vector starts.
BEGIN
LOCAL X, Y, LOCX, LOCY, TLS, TWS;
LOCAL T1X, T1Y, T2X, T2Y; // Points to draw the arrow tip.
TLS:=0.8; // Tip length scaling factor.
TWS:=0.05; // Tip width scaling factor
X:=RE(XY); // X component of the vector
Y:=IM(XY); // Y component of the vector
LOCX:=RE(LOC); // Location X component
LOCY:=IM(LOC); // Location Y component

// calculate coordinates for arrow tip
T1X:=LOCX+TLS*X-TWS*Y;
T1Y:=LOCY+TLS*Y+TWS*X;
T2X:=LOCX+TLS*X+TWS*Y;
T2Y:=LOCY+TLS*Y-TWS*X;

LINE(LOCX,LOCY,LOCX+X,LOCY+Y,1); //Draw body of the arrow
TRIANGLE(T1X, T1Y, T2X, T2Y,LOCX+X, LOCY+Y,0); // draw tip pf the arrow
//LINE(T1X,T1Y,LOCX+X,LOCY+Y,1);
END;


LOCAL mygrid(XMIN, XMAX, YMIN, YMAX, grid)
BEGIN
  LOCAL IX, IY;
  FOR IX FROM XMIN TO XMAX STEP grid DO
    FOR IY FROM YMIN TO YMAX STEP grid DO
      ARC(IX,IY,1);
    END;
  END;
  ARC(0,0,1,#0000FF);
END;

LOCAL myfunc(x,y)
BEGIN
RETURN sin(pi/2*y)-i*sin(pi/2*x);
END;

EXPORT draw1()
BEGIN
LOCAL JX, JY, DX, DY, grid;
DX:=25;
DY:=25;
grid := 2;
RECT();
T:=TICKS;
FOR JX FROM -DX TO DX STEP grid DO
  FOR JY FROM -DY TO DY STEP grid DO
    drw_vect(10*myfunc(JX/50,JY/50),JX+i*JY);
  END;
END;
FREEZE;
T:=TICKS-T;

END;

 

 

The output:

 fieldplot_prime.png

 

 

Can I somehow make use of an Apps plot view to zoom in the plot? I already noticed that my program uses the zoom factor of the "Function" app which is running. I would like to draw into the Plot view of the Function app. But my attempts to just create copy of the "Function" App and add a VIEW "Plot", Plot() line in the code did not work. I guess I can not overwrite the built in App functions. Or I did it wrong.

 

I don't want to reinvent the wheel and write code to provide interactive zooming and so on if this is already available in an App. Hence I am grateful for some hints.

Frequent Advisor
Vlad_AB
Posts: 25
Registered: ‎06-26-2013
Message 7 of 10 (775 Views)

Re: Storing to Geometry App variables (HP Prime)

Hi!

 

:-)

 

ans1012201300.JPG

 

ans1012201301.JPG

 

ans1012201302.JPG

 

ans1012201303.JPG

 

 

The output:

ans1012201304.JPG

Advisor
StefanD
Posts: 12
Registered: ‎12-05-2013
Message 8 of 10 (755 Views)

Re: Storing to Geometry App variables (HP Prime)

Ok, but this does not give you the information about the magnitude, but only the angle (and the angle is ambigous because there are now arrow tip indicators). Although it looks like there are different lengths of the slope indicators.

 

Additionally, for unknown reasons, this works for me only in the emulator but not on the hardware calculator. I already tried to fix it by resetting (Format C) the calculator and double checked all settings. The Firmware is v5447 (both, in emulator and hardware). But it did not help. See below a screenshot of the hardware calculator output:

 

2013-12-10-161236.jpg

 

Did you try your solution on a hardware calc or in the emulator?

 

Thank you!

Frequent Advisor
Vlad_AB
Posts: 25
Registered: ‎06-26-2013
Message 9 of 10 (727 Views)

Re: Storing to Geometry App variables (HP Prime)

Hi!

 

I did try my solution on a hardware calc and in the emulator with option 'normalize'.

 

plotfield(ex,[x = (Xmin .. Xmax),y = (Ymin .. Ymax)],'normalize')

 


StefanD wrote:

Ok, but this does not give you the information about the magnitude, but only the angle (and the angle is ambigous because there are now arrow tip indicators). Although it looks like there are different lengths of the slope indicators.


Ok, try my version of the prog:

EXPORT vecfield_2(func)

BEGIN

     func▶V1;

     LOCAL A,B,X,Y,H,TWS;

     TWS:=0.12;

     RECT();

     H:=(Xmax-Xmin)/11;

     FOR Y FROM Ymin TO Ymax STEP H DO

          FOR X FROM Xmin TO Xmax STEP H DO

               A:=X+RE(V1(X,Y))*TWS;

               B:=Y+IM(V1(X,Y))*TWS;

               LINE(X,Y,A,B);

               ARC(A,B,1);

          END;

     END;

     FREEZE;

END;

 

Example. f(X,Y)=sin(π/2*Y)-i*sin(π/2*X).

 

1) The Function app must be a current app (Xmin=Ymin=-0.5; Xmax=Ymax=0.5).

2) Type vecfield_2('sin(π/2*Y)-i*sin(π/2*X)') and press Enter.

 

The output:

 

ans1112201301.JPG

Advisor
StefanD
Posts: 12
Registered: ‎12-05-2013
Message 10 of 10 (687 Views)

Re: Making an App (was: Storing to Geometry App variables (HP Prime))

Ok, so we both managed to draw arrows. Now how to go on from here?

Since I don't see any possibility to modify the preinstalled Function or Geometry apps, I guess I have to write my own App. If I am wrong and somebody could tell me how to modify the preinstalled apps please tell me.

 

So a couple of questions have come up on my side:

1. What makes an App different from a Program?

2. How do I make a program that appears in the Apps overview (NOT starting with a copy of an existing App)

3. How do I make advanced input forms? Take for example the "Symb" input of the function app. How is that done with the existing commands? Did they draw this all by pixel on off commands? I can't imagine that :P

4. Are the preinstalled apps written in HPPL? or did they use native code?

 

Stefan

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.