(15C) Area and Perimeter of irregular polygon - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (15C) Area and Perimeter of irregular polygon (/thread-20949.html) |
(15C) Area and Perimeter of irregular polygon - Marcel - 12-04-2023 06:17 PM 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! RE: (15C) Area and Perimeter of irregular polygon - Werner - 12-05-2023 12:53 PM 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 RE: (15C) Area and Perimeter of irregular polygon - Marcel - 12-05-2023 01:50 PM 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 RE: (15C) Area and Perimeter of irregular polygon - Werner - 12-05-2023 02:33 PM 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 RE: (15C) Area and Perimeter of irregular polygon - Marcel - 12-05-2023 03:14 PM 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! RE: (15C) Area and Perimeter of irregular polygon - Marcel - 12-05-2023 05:57 PM Hi Werner! I try your program..Wow! You must add to it the peremeter and upload it on the forum! I am waiting for your version. Marcel. RE: (15C) Area and Perimeter of irregular polygon - John Keith - 12-05-2023 07:12 PM Though rather long and involved, this thread may be relevant to the current discussion. RE: (15C) Area and Perimeter of irregular polygon - Werner - 12-06-2023 09:47 AM 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 |