I am trying to write a basic program for my TI-84 that finds the area of polygons on a 2d plane. For reference, I have written this in python many times, here is what it does:
x_list,y_list,verts,tot_1,tot_2=[],[],int(input("How many vertices are on the polygon: ")),0,0 //sets vars to defaults and gets num of vertices
for i in range(verts): //gets X and Y values of each point for num. of vertices
x_list.append(float(input("X value of point %s: " % str(i+1)))) //appends x value given to x list
y_list.append(float(input("Y value of point %s: " % str(i+1)))) //appends y value given to y list
for ind in range(verts-1):
tot_1 += (x_list[ind]*y_list[ind+1])-(y_list[ind]*x_list[ind+1])
print(str(abs((tot_1)/2))) //prints area: abs value of total over two
this just does the very basic algorithm also shown here in regular mathematics: http://www.mathopenref.com/coordpolygonarea.html
now when I try to write the same thing in TI-Basic (using the TI Connect application and sending to calculator), it returns a syntax error on the first reference to one of the lists; "Check all arguments entered". The line is surrounded in asterisks. comments are not in the actual code
ClrHome //clears screen
Prompt V //gets number of vertices
0→T //sets total to 0
Disp V //displays vertices, was used for testing
For(N,1,V,1) //runs code for number of vertices
Input "x val: ",X //gets latest x val
Input "y val: ",Y //gets latest y val
**X→L1(1+dim(L1))** //appends x to listand
Y→L2(1+dim(L2)) //y to list
End //end for
For(I,1,P,1)
T+((L1(I)*L2(I+1))-(L2(I)*L1(I+1))→T //adds up total
End
Disp abs(T/2)
when changing the code on the calculator by changing the L1 to the list1 character and L2 to the list2 character, all it did was return the value 12.5*number of vertices-2. My questions are:
got it, i'm silly.
1st, used the list variables given on the syntax reference in ti-connect
2nd, the algorithm in the second for loop was wrong.