(15C) Area and Perimeter of irregular polygon
12-04-2023, 06:17 PM (This post was last modified: 12-07-2023 01:16 AM by Marcel.)
Post: #1
 Marcel Member Posts: 179 Joined: Mar 2014
(15C) Area and Perimeter of irregular polygon
Hi!
I upload a document with a program for calculating the Area and the Perimeter of an irregular polygon for the HP 15C.
Have fun!

Attached File(s)
Area and Perimeter of Irregular Polygons.pdf (Size: 336.47 KB / Downloads: 6)
12-05-2023, 12:53 PM
Post: #2
 Werner Senior Member Posts: 887 Joined: Dec 2013
RE: (15C) Area and Perimeter of irregular polygon
There's an error in the Area formula (not in the program): the first term also needs a minus sign.
If the area is all you need, you may try this small program (concocted on the fly ;-)
Enter the coefficients in any matrix, recall the matrix to the stack and (GSB) A.

33 Bytes

X       Y       Z       T
001 LBL A
002 STO I
003 MATRIX 1
004uRCL (i)
005 RCL 0          dummy
006 0
007uRCL (i)
008 LBL 1
009 GSB 0
010uRCL (i)        yj      A       xj      xj
011 GTO 1
012 GSB 0
013 ABS
014 2
015 /
016 RTN
017 LBL 0          yi      A               xi
018 R^             xi      yi      A
019uRCL (i)
020 +              xi+xj   yi      A       A
021 X<>Y
022 LASTX
023 Rv             yi      xi+xj   A       xj
024 RCL- (i)
025 x
026 +
027 RTN

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
12-05-2023, 01:50 PM
Post: #3
 Marcel Member Posts: 179 Joined: Mar 2014
RE: (15C) Area and Perimeter of irregular polygon
Hi Werner!

I think the formula is OK.. but a small error at the end of page 4 in the

Area = ...

I corrected the -1. It should be 1... Sorry!

I upload a new document with the correction.

I will try your program today.

Marcel
12-05-2023, 02:33 PM (This post was last modified: 12-05-2023 02:34 PM by Werner.)
Post: #4
 Werner Senior Member Posts: 887 Joined: Dec 2013
RE: (15C) Area and Perimeter of irregular polygon
Hi Marcel, yes that was an error, too.
But the formula you wrote (apart from the ||):

$$Area = \frac{(x_{1}y_{2}-x_{2}y_{1})-(x_{2}y_{3}-x_{3}y_{2})- ..-(x_{n}y_{1}-x_{1}y_{n})}{2}$$

That first term must be negative also, or just switch them all around

$$Area = \frac{(x_{2}y_{1}-x_{1}y_{2})+(x_{3}y_{2}-x_{2}y_{3})+ ..+(x_{1}y_{n}-x_{n}y_{1})}{2}$$

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
12-05-2023, 03:14 PM
Post: #5
 Marcel Member Posts: 179 Joined: Mar 2014
RE: (15C) Area and Perimeter of irregular polygon
Hi again Werner!

In english you said Shame on me! (I speak french..)

I put minus sign (-) but it is a plus sign (+).

It is corrected now...

Marcel!
12-05-2023, 05:57 PM
Post: #6
 Marcel Member Posts: 179 Joined: Mar 2014
RE: (15C) Area and Perimeter of irregular polygon
Hi Werner!

You must add to it the peremeter and upload it on the forum!

I am waiting for your version.

Marcel.
12-05-2023, 07:12 PM
Post: #7
 John Keith Senior Member Posts: 1,028 Joined: Dec 2013
RE: (15C) Area and Perimeter of irregular polygon
Though rather long and involved, this thread may be relevant to the current discussion.
12-06-2023, 09:47 AM
Post: #8
 Werner Senior Member Posts: 887 Joined: Dec 2013
RE: (15C) Area and Perimeter of irregular polygon
Area (A) (improved wrt the previous version) and perimeter (C)
(though not together; but the program can be easily changed to that extent, using a data register)

55 bytes

X       Y       Z       T
001 LBL A
002 GSB 0
003 LBL 1          yi      A       -       xi
004 RCLx (i)       xj*yi   A       -       xi
005 R^
006uRCL (i)
007 Rv             xi      xj*yi   A       xj
008 RCLx (i)       yj*xi
009 -
010 +
011uRCL (i)
012 GTO 1
013 Rv
014 ABS
015 2
016 /
017 RTN

018 LBL C
019 GSB 0
020 LBL 2          yi      P       xi
021 RCL (i)        xj      yi      P       xi
022 R^
023 -
024uRCL (i)
025 Rv             xj-xi   yi      P       xj
026 X<>Y
027 RCL- (i)
028 ->P            d       -       P       xj
029 X<>Y
030 Rv
031 +              P       xj
032uRCL (i)
033 GTO 2
034 Rv
035 RTN

036 LBL 0
037 STO I
038 MATRIX 1
039 RCL DIM I 2 n
040 SQRT
041 RCL g(i)
042 0
043 RCL DIM I
044 RCL g(i)       yn      0       xn      xn
045 RTN

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
 « Next Oldest | Next Newest »

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