- Finding the area of a figure when given the points
- 11 Mar 2019 01:24:24 pm
- Last edited by Jasonpm on 11 Mar 2019 11:27:32 pm; edited 2 times in total
If you are given a graph with the points of a bounded polygon, you can enter the points into this program and get the area. Works for polygons up to 10 points.
Code:
Yeah, I need to learn how to optimize it. I don't know how to do this other than hardcoding every value 3-10. Resulting in a ridiculously large program for what it does
I appreciate feedback. Criticize it as much as you want. I am fairly new to code.
---------------------------------------------------------------------------------------------------------------------
EDIT!!!
Just finished making that code shorter. The new code comes in at about 4.3% of the original size in terms of bytes.
I still want feedback
If you care the code is posted below. (Ti-84 Silver edition [monochrome])
Code:
Code:
ClrHome
Input "How Many Points?",Z
Disp "Enter the Points"
Disp "Going Counter"
Disp "Clockwise"
If X<=2
Then
Disp "Please Enter A"
Disp "Value From 3-10"
Else
If X=10
Then
Input "X1=",A
Input "Y1=",B
Input "X2=",C
Input "Y2=",D
Input "X3=",E
Input "Y3=",F
Input "X4=",G
Input "Y4=",H
Input "X5=",I
Input "Y5=",J
Input "X6=",K
Input "Y6=",L
Input "X7=",M
Input "Y7=",N
Input "X8=",O
Input "Y8=",P
Input "X9=",Q
Input "Y9=",R
Input "X10=",S
Input "Y10=",T
{2,2->dim([A]
{2,2->dim([B]
{2,2->dim([C]
{2,2->dim([D]
{2,2->dim([E]
{2,2->dim([F]
{2,2->dim([G]
{2,2->dim([H]
{2,2->dim([I]
{2,2->dim([J]
A->[A](1,1):B->[A](2,1):C->[A](1,2):D->[A](2,2)
C->[B](1,1):D->[B](2,1):E->[B](1,2):F->[B](2,2)
E->[C](1,1):F->[C](2,1):G->[C](1,2):H->[C](2,2)
G->[D](1,1):H->[D](2,1):I->[D](1,2):J->[D](2,2)
I->[E](1,1):J->[E](2,1):K->[E](1,2):L->[E](2,2)
K->[F](1,1):L->[F](2,1):M->[F](1,2):N->[F](2,2)
M->[G](1,1):N->[G](2,1):O->[G](1,2):P->[G](2,2)
O->[H](1,1):P->[H](2,1):Q->[H](1,2):R->[H](2,2)
Q->[I](1,1):R->[I](2,1):S->[I](1,2):T->[I](2,2)
S->[J](1,1):T->[J](2,1):A->[J](1,2):B->[J](2,2)
.5((Det([A])+(Det([B])+(Det([C])+(Det([D])+(Det([E])+(Det([F])+(Det([G])+(Det([H])+(Det([I])+(Det([J]))->Y
Disp "Area=",Y
Else
If X=9
Then
Input "X1=",A
Input "Y1=",B
Input "X2=",C
Input "Y2=",D
Input "X3=",E
Input "Y3=",F
Input "X4=",G
Input "Y4=",H
Input "X5=",I
Input "Y5=",J
Input "X6=",K
Input "Y6=",L
Input "X7=",M
Input "Y7=",N
Input "X8=",O
Input "Y8=",P
Input "X9=",Q
Input "Y9=",R
{2,2->dim([A]
{2,2->dim([B]
{2,2->dim([C]
{2,2->dim([D]
{2,2->dim([E]
{2,2->dim([F]
{2,2->dim([G]
{2,2->dim([H]
{2,2->dim([I]
A->[A](1,1):B->[A](2,1):C->[A](1,2):D->[A](2,2)
C->[B](1,1):D->[B](2,1):E->[B](1,2):F->[B](2,2)
E->[C](1,1):F->[C](2,1):G->[C](1,2):H->[C](2,2)
G->[D](1,1):H->[D](2,1):I->[D](1,2):J->[D](2,2)
I->[E](1,1):J->[E](2,1):K->[E](1,2):L->[E](2,2)
K->[F](1,1):L->[F](2,1):M->[F](1,2):N->[F](2,2)
M->[G](1,1):N->[G](2,1):O->[G](1,2):P->[G](2,2)
O->[H](1,1):P->[H](2,1):Q->[H](1,2):R->[H](2,2)
Q->[I](1,1):R->[I](2,1):A->[I](1,2):B->[I](2,2)
.5((Det([A])+(Det([B])+(Det([C])+(Det([D])+(Det([E])+(Det([F])+(Det([G])+(Det([H])+(Det([I]))->Y
Disp "Area=",Y
Else
If X=8
Then
Input "X1=",A
Input "Y1=",B
Input "X2=",C
Input "Y2=",D
Input "X3=",E
Input "Y3=",F
Input "X4=",G
Input "Y4=",H
Input "X5=",I
Input "Y5=",J
Input "X6=",K
Input "Y6=",L
Input "X7=",M
Input "Y7=",N
Input "X8=",O
Input "Y8=",P
{2,2->dim([A]
{2,2->dim([B]
{2,2->dim([C]
{2,2->dim([D]
{2,2->dim([E]
{2,2->dim([F]
{2,2->dim([G]
{2,2->dim([H]
A->[A](1,1):B->[A](2,1):C->[A](1,2):D->[A](2,2)
C->[B](1,1):D->[B](2,1):E->[B](1,2):F->[B](2,2)
E->[C](1,1):F->[C](2,1):G->[C](1,2):H->[C](2,2)
G->[D](1,1):H->[D](2,1):I->[D](1,2):J->[D](2,2)
I->[E](1,1):J->[E](2,1):K->[E](1,2):L->[E](2,2)
K->[F](1,1):L->[F](2,1):M->[F](1,2):N->[F](2,2)
M->[G](1,1):N->[G](2,1):O->[G](1,2):P->[G](2,2)
O->[H](1,1):P->[H](2,1):A->[H](1,2):B->[H](2,2)
.5((Det([A])+(Det([B])+(Det([C])+(Det([D])+(Det([E])+(Det([F])+(Det([G])+(Det([H]))->Y
Disp "Area=",Y
Else
If X=7
Then
Input "X1=",A
Input "Y1=",B
Input "X2=",C
Input "Y2=",D
Input "X3=",E
Input "Y3=",F
Input "X4=",G
Input "Y4=",H
Input "X5=",I
Input "Y5=",J
Input "X6=",K
Input "Y6=",L
Input "X7=",M
Input "Y7=",N
{2,2->dim([A]
{2,2->dim([B]
{2,2->dim([C]
{2,2->dim([D]
{2,2->dim([E]
{2,2->dim([F]
{2,2->dim([G]
A->[A](1,1):B->[A](2,1):C->[A](1,2):D->[A](2,2)
C->[B](1,1):D->[B](2,1):E->[B](1,2):F->[B](2,2)
E->[C](1,1):F->[C](2,1):G->[C](1,2):H->[C](2,2)
G->[D](1,1):H->[D](2,1):I->[D](1,2):J->[D](2,2)
I->[E](1,1):J->[E](2,1):K->[E](1,2):L->[E](2,2)
K->[F](1,1):L->[F](2,1):M->[F](1,2):N->[F](2,2)
M->[G](1,1):N->[G](2,1):A->[G](1,2):B->[G](2,2)
.5((Det([A])+(Det([B])+(Det([C])+(Det([D])+(Det([E])+(Det([F])+(Det([G]))->Y
Disp "Area=",Y
If X=6
Then
Input "X1=",A
Input "Y1=",B
Input "X2=",C
Input "Y2=",D
Input "X3=",E
Input "Y3=",F
Input "X4=",G
Input "Y4=",H
Input "X5=",I
Input "Y5=",J
Input "X6=",K
Input "Y6=",L
{2,2->dim([A]
{2,2->dim([B]
{2,2->dim([C]
{2,2->dim([D]
{2,2->dim([E]
{2,2->dim([F]
A->[A](1,1):B->[A](2,1):C->[A](1,2):D->[A](2,2)
C->[B](1,1):D->[B](2,1):E->[B](1,2):F->[B](2,2)
E->[C](1,1):F->[C](2,1):G->[C](1,2):H->[C](2,2)
G->[D](1,1):H->[D](2,1):I->[D](1,2):J->[D](2,2)
I->[E](1,1):J->[E](2,1):K->[E](1,2):L->[E](2,2)
K->[F](1,1):L->[F](2,1):A->[F](1,2):B->[F](2,2)
.5((Det([A])+(Det([B])+(Det([C])+(Det([D])+(Det([E])+(Det([F]))->Y
Disp "Area=",Y
Else
If X=5
Then
Input "X1=",A
Input "Y1=",B
Input "X2=",C
Input "Y2=",D
Input "X3=",E
Input "Y3=",F
Input "X4=",G
Input "Y4=",H
Input "X5=",I
Input "Y5=",J
{2,2->dim([A]
{2,2->dim([B]
{2,2->dim([C]
{2,2->dim([D]
{2,2->dim([E]
A->[A](1,1):B->[A](2,1):C->[A](1,2):D->[A](2,2)
C->[B](1,1):D->[B](2,1):E->[B](1,2):F->[B](2,2)
E->[C](1,1):F->[C](2,1):G->[C](1,2):H->[C](2,2)
G->[D](1,1):H->[D](2,1):I->[D](1,2):J->[D](2,2)
I->[E](1,1):J->[E](2,1):A->[E](1,2):B->[E](2,2)
.5((Det([A])+(Det([B])+(Det([C])+(Det([D])+(Det([E]))->Y
Disp "Area=",Y
Else
If X=4
Then
Input "X1=",A
Input "Y1=",B
Input "X2=",C
Input "Y2=",D
Input "X3=",E
Input "Y3=",F
Input "X4=",G
Input "Y4=",H
{2,2->dim([A]
{2,2->dim([B]
{2,2->dim([C]
{2,2->dim([D]
A->[A](1,1):B->[A](2,1):C->[A](1,2):D->[A](2,2)
C->[B](1,1):D->[B](2,1):E->[B](1,2):F->[B](2,2)
E->[C](1,1):F->[C](2,1):G->[C](1,2):H->[C](2,2)
G->[D](1,1):H->[D](2,1):A->[D](1,2):B->[D](2,2)
.5((Det([A])+(Det([B])+(Det([C])+(Det([D]))->Y
Disp "Area=",Y
Else
If X=3
Then
Input "X1=",A
Input "Y1=",B
Input "X2=",C
Input "Y2=",D
Input "X3=",E
Input "Y3=",F
{2,2->dim([A]
{2,2->dim([B]
{2,2->dim([C]
A->[A](1,1):B->[A](2,1):C->[A](1,2):D->[A](2,2)
C->[B](1,1):D->[B](2,1):E->[B](1,2):F->[B](2,2)
E->[C](1,1):F->[C](2,1):A->[C](1,2):B->[C](2,2)
.5((Det([A])+(Det([B])+(Det([C]))->Y
Disp "Area=",Y
Yeah, I need to learn how to optimize it. I don't know how to do this other than hardcoding every value 3-10. Resulting in a ridiculously large program for what it does
I appreciate feedback. Criticize it as much as you want. I am fairly new to code.
---------------------------------------------------------------------------------------------------------------------
EDIT!!!
Just finished making that code shorter. The new code comes in at about 4.3% of the original size in terms of bytes.
I still want feedback
If you care the code is posted below. (Ti-84 Silver edition [monochrome])
Code:
Input "Nmbr Of Points=",Z
Disp "Enter Points"
Disp "Going Counter ClockWise"
Input "X=?",A
Input "Y=?",B
0->dim(L1
{2,2}->dim([A]
A->[A](1,1)
B->[A](2,1)
For(N,2,Z)
Prompt X
Prompt Y
X->[A](1,2)
Y->[A](2,2)
det([A])->L1(dim(L1)+1)
X->[A](1,1)
Y->[A](2,1)
End
A->[A](1,2)
B->[A](2,2)
det([A])->L1(Dim (L1)+1)
sum(L1)*.5->C
Disp "Area=",C