HP Forums
ARC_P() Unexpected results. - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: ARC_P() Unexpected results. (/thread-18155.html)



ARC_P() Unexpected results. - matalog - 03-21-2022 10:57 PM

The following is drawing arcs using ARC_P(), and it works as expected most of the way, but at these values it displays an unexpected ARC. The same code works fine on ARCs over radius 15, but at a radius of 10, it jumps to this semicircle. You can see it in the video.

[Image: ARCw1.jpg?raw=1]

[Image: ARCw2.jpg?raw=1]

https://www.dropbox.com/s/s2moqdne4nryjlx/clip0227.avi?dl=0

Code:
EXPORT ANIM()
BEGIN
DIMGROB_P(G1,320,240);
 RECT_P();
 LOCAL A:=60;
LOCAL B:=2*π/A;

  WHILE ISKEYDOWN(4)=0 DO

LOCAL COL:=RANDINT(16777216);
LOCAL SIZE:=RANDINT(100);
 
  FOR N FROM 1 TO 60 DO
RECT_P(G1);
 ARC_P(G1,160,120,10,B*N/2-0.0001,2*π-B*N/2,{#000000h,COL}); 
  BLIT_P(G0,0,0,320,240,G1,0,0,320,240); 
  TEXTOUT_P(STRING(B*N/2-0.0001)+"  ,  "+STRING(2*π-B*N/2),100,20);
   WAIT(.1)
END;
    WAIT(.2) ;
FOR N FROM 1 TO 60 DO
RECT_P(G1);
 ARC_P(G1,160,120,10,B*(30-N/2),2*π-B*(30-N/2),{#000000h,COL}); 
  BLIT_P(G0,0,0,320,240,G1,0,0,320,240); 
  TEXTOUT_P(STRING(B*(30-N/2))+"  ,  "+STRING(2*π-B*(30-N/2)),100,20);
    WAIT(.1)
END;
    WAIT(.2)


END;

  
END;


Is it a problem with ARC_P? Or is it a problem with the approximation of the equations involving PI?

If I did not add the: -0.0001 in the first ARC_P() command, then the ARCs would also show similar problems with bigger radiuses.

waka waka.


RE: ARC_P() Unexpected results. - tgallo - 03-23-2022 10:48 AM

Does it behave the same way in both the virtual and actual calculators?


RE: ARC_P() Unexpected results. - matalog - 03-23-2022 11:21 AM

(03-23-2022 10:48 AM)tgallo Wrote:  Does it behave the same way in both the virtual and actual calculators?

Yeah, it happens on both.