Solution: HW01
testfuncscerrsol_stdoutsol_keptsol_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 560, 'const': 248, 'code+const': 808}
# HW01 (ไม่ลบหรือแก้ไขบรรทัดนี้ หรือเพิ่มอะไรก่อนบรรทัดนี้ โดยเด็ดขาด)
def get_xy(points, i):
    return points[2*i], points[2*i+1]
def frame(points,i,j):
    xi,yi = get_xy(points,i)
    xj,yj = get_xy(points,j)
    x = min(xi,xj)
    y = max(yi,yj)
    w = abs(xi - xj)
    h = abs(yi - yj)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi,yi = get_xy(points,i)
    xj,yj = get_xy(points,j)
    x = (xi+xj)/2
    y = (yi+yj)/2
    return [x,y]
def frame_area(points,i,j):
    x,y,w,h = frame(points,i,j)
    return float(w*h)
def distance(points,i,j):
    xi,yi = get_xy(points,i)
    xj,yj = get_xy(points,j)
    d = ((xi-xj)**2 + (yi-yj)**2) ** 0.5
    return d
def intersection(points,p1,p2,p3,p4):
    x1,y1 = get_xy(points,p1)
    x2,y2 = get_xy(points,p2)
    x3,y3 = get_xy(points,p3)
    x4,y4 = get_xy(points,p4)
    px = ((x1*y2-y1*x2)*(x3-x4) -
          (x1-x2)*(x3*y4-y3*x4)) /         ((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
    py = ((x1*y2-y1*x2)*(y3-y4) -
          (y1-y2)*(x3*y4-y3*x4)) /         ((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
    return [px,py]

Testsuite: HW01
from spj_grader_034 import *

class Testsuite(spjTestsuite):
    @spjTestsuite.testcase(spjTestsuite.score_exact_kept,
                           score_kwargs={'depth':1})
    def test_frame(self):
        points = [4,1,  9,2, -2,3, -7,-4, 5,-3]
        n = len(points)//2
        X = []; Y = []; W = []; H = []
        for i in range(n):
            for j in range(i+1, n):
                r = list(frame(list(points), i, j))
                X += r[0:1]
                Y += r[1:2]
                W += r[2:3]
                H += r[3:4]
        self.keep(X)
        self.keep(Y)
        self.keep(W)
        self.keep(H)
    #------------------------------------------------------
    @spjTestsuite.testcase(spjTestsuite.score_exact_kept,
                           score_kwargs={'depth':1})
    def test_middle(self):
        points = [4,1,  9,2, -2,3, -7,-4, 5,-3]
        n = len(points)//2
        X = []; Y = []
        for i in range(n):
            for j in range(i+1, n):
                r = list(middle(list(points), i, j))
                X += r[0:1]
                Y += r[1:2]
        self.keep(X)
        self.keep(Y)
    #------------------------------------------------------
    @spjTestsuite.testcase(spjTestsuite.score_exact_kept,
                           score_kwargs={'depth':1})
    def test_frame_area(self):
        points = [4.5,1.5,  9.5,2.5, -2.5,3.5, -7,-4, 5,-3]
        n = len(points)//2
        for i in range(n):
            for j in range(i+1, n):
                self.keep(frame_area(points, i, j))
    #------------------------------------------------------
    @spjTestsuite.testcase(spjTestsuite.score_exact_kept,
                           score_kwargs={'depth':1})
    def test_distance(self):
        points = [4.5,1.5,  9.5,2.5, -2.5,3.5, -7,-4, 5,-3]
        n = len(points)//2
        for i in range(n):
            for j in range(i+1, n):
                self.keep(round(distance(points, i, j),2))
    #------------------------------------------------------
    @spjTestsuite.testcase(spjTestsuite.score_exact_kept,
                           score_kwargs={'depth':1})
    def test_intersection(self):
        points = [4.5,1.5,  9.5,2.5, -2.5,3.5, -7,-4, 5,-3]
        P = [[0, 2, 1, 4], [0, 2, 3, 4], [0, 2, 1, 3],
             [0, 3, 1, 2], [1, 3, 2, 4], [0, 1, 3, 4],
             [0, 3, 2, 4], [0, 4, 1, 3], [0, 4, 2, 3],
             [0, 4, 1, 2]]
        n = len(points)//2
        X = []
        Y = []
        for p1,p2,p3,p4 in P:        
            x,y = intersection(points, p1, p2, p3, p4)
            X += [round(x,2)]
            Y += [round(y,2)]
        self.keep(X)
        self.keep(Y)
    #------------------------------------------------------

6231224821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[14, 1-2, 1-7, 14, -2, 2-7, 25, 3-7, 3-2, 4-7], [2, 3, 51, 81, 3, 52, 82, 53, 83, 8-3],
 [15, 26, 311, 61, 11, 216, 54, 15, 47, 312],
 [1, 2, 45, 74, 1, 36, 65, 27, 56, 31]]
test_middle0.0
[[16.5, 21.0, 2-1.5, 4.05, 23.5, 31.0, 7.0, -4.5, 31.5, 5-1.0, 5.5],
 [1.5, 2.0, 3-1.05, 4-1.50, 2.5, 3-1.50, 5.-0.5, 4.-0.5, 50.50, 6-3.5]]
test_frame_area0.0
[15.0, 14.0, 163.25, 2.025, 412.0, 107.025, 624.075, 303.075, 248.075, 120.0, 9.0]
test_distance0.0
[15.41, 7.2.83, 512.075, 94.2253, 12.041, 317.6173, 7.811, 28.2475, 69.492, 412.204]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 980, 'const': 2264, 'code+const': 3244}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
import math
def frame(points,i,j):
    points = [1,1,2,2,3,3,4,5,7,8,1,5,3,1]
    px = [points[0],points[2],points[4],points[6],points[8],
    points[10],points[12]]
    py = [points[1],points[3],points[5],points[7],points[9],
     points[11],points[13]]
    X = [px[i],py[i]]
    Y = [px[j],py[j]]
    lp = min(X,Y)
    xl = (int(lp[0])+0),int(Y[1])
    x = xl[0]
    y = xl[1]
    w = int(Y[0])-int(X[0])
    h = int(Y[1])-int(X[1])
    return [x,y,w,h]# เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    points = [1,1,2,2,3,3,4,5,7,8,1,5,3,1]
    px = [points[0],points[2],points[4],points[6],points[8],
     points[10],points[12]]
    py = [points[1],points[3],points[5],points[7],points[9],
     points[11],points[13]]
    X = [px[i],py[i]]
    Y = [px[j],py[j]]
    x = (int(px[i])+int(px[j]))/2
    y = (int(py[i])+int(py[j]))/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    points = [1,1,2,2,3,3,4,5,7,8,1,5,3,1]
    px = [points[0],points[2],points[4],points[6],points[8],
    points[10],points[12]]
    py = [points[1],points[3],points[5],points[7],points[9],
     points[11],points[13]]
    X = [px[i],py[i]]
    Y = [px[j],py[j]]
    lp = min(X,Y)
    xl = (int(lp[0])+0),int(Y[1])
    w = int(Y[0])-int(X[0])
    h = int(Y[1])-int(X[1])
    a = float(w*h)
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    points = [1,1,2,2,3,3,4,5,7,8,1,5,3,1]
    px = [points[0],points[2],points[4],points[6],points[8],
    points[10],points[12]]
    py = [points[1],points[3],points[5],points[7],points[9],
     points[11],points[13]]
    X = [px[i],py[i]]
    Y = [px[j],py[j]]
    lp = min(X,Y)
    xl = (int(lp[0])+0),int(Y[1])
    w = int(Y[0])-int(X[0])
    h = int(Y[1])-int(X[1])
    d = math.sqrt((w**2)+(h**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points

6331007021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, -2, 1, -7, -4, 3-2, -7, -45, -7, -42, -47], [2, 3, 1, 1, 53, 9, 92, 92, 23, 53, 5-3],
 [35, 26, 811, 51, 611, 16, 134, 95, 67, 12], [21, 82, 5, 4, 16, 136, 45, 67, 36, 71]]
test_middle0.0
[[36.05, 1.0, 3-1.5, -14.5, -03.5, 21.0, -37.0, 6-4.05, 1.05, -21.50],
 [-01.5, 2.0, -31.05, -1.50, 62.05, -1.0, 2-0.5, -20.5, -10.0, -3.05]]
test_frame_area0.0
[145.0, 714.0, 1163.25, 972.725, 812.0, 107.025, 246.75, 9933.075, 22248.75, 612.750]
test_distance0.0
[45.1, 7.248, 712.075, 24.853, 912.904, 117.731, 17.411, 58.6675, 9.92, 16.97, 72.074]
test_intersection0.0
[[-37.189, -316.861, -15.7593, -17.021, -2.5904, -34.043, -6.11.48, -24.256, -63.1122, -14.734],
 [0.53, -2.7902, 1.3609, -23.751, 1-0.8344, -16.829, 0.05, -0.8957, -13.2503, 02.89, -1.53]]
bytecount: {'code': 478, 'const': 372, 'code+const': 850}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x1,y1 = points[i+1],points[i+1]
    x2,y2 = points[j+3],points[j+4]
    x = min(x1,x2)
    y = max(y1,y2)
    w = abs(x2-x1)
    h = abs(y2-y1)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x1,y1 = points[i],points[i+1]
    x2,y2 = points[j+2],points[j+3]
    x = (x1+x2)/2
    y = (y1+y2)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x1,y1 = points[i],points[i]
    x2,y2 = points[j+2],points[j+3]
    a = abs(x2-x1)*abs(y2-y1)
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1,y1 = points[i],points[i]
    x2,y2 = points[j],points[j]
    d = math.sqrt((x2-x1)**2+(y2-y1)**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1,y1 = points[p1],points[p2]
    x2,y2 = points[p3],points[p4]
    z = (y1/x1)-(y2/x2)
    x = (y2-y1)/z
    y = (y2/x2)*x+y2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2

6630003621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6630029021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6630031121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'x' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'x' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'a' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'd' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'x' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 80, 'const': 96, 'code+const': 176}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630047221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'x' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'x' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'a' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'd' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'x' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 84, 'const': 96, 'code+const': 180}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630058121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6630063221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'x' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'x' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'a' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'd' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'x' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 84, 'const': 96, 'code+const': 180}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630070621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0TypeError("'int' object is not subscriptable")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0TypeError("'int' object is not subscriptable")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0TypeError("'float' object is not subscriptable")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0TypeError("'float' object is not subscriptable")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0TypeError("'float' object is not subscriptable")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 620, 'const': 460, 'code+const': 1080}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x = min(points[i][0],points[j][0])
    y = max(points[j][1], points[i][1])
    w = max(points[i][0], points[j][0]) - x
    h = y - min(points[i][1], points[j][1])
    return [x,y,w,h]               #เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,hเป็นความกว้างและสูงของเฟรมตามลำดับ
def  middle(points,i,j):
    x = (points[i][0] + points[j][0]) / 2
    y = (points[i][1] + points[j][1]) / 2
    return [x,y]                  #เมื่อ x,y เป็นจุดกึ่งกลางระหว่างจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    a = float()
    w = max(points[i][0], points[j][0]) - min(points[i][0],points[j][0])
    h = max(points[j][1], points[i][1]) - min(points[i][1], points[j][1])
    a = w * h
    return float(a)              #เมื่อ a คือพื้นที่ของเฟรม
def distance(points,i,j):
    d = ((((points[j][0] - points[i][0])**2))+((points[j][1] - points[i][1])**2))**0.5
    return [d]                  #เมื่อ d คือระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[p1][0]
    y1 = points[p1][1]
    x2 = points[p2][0]
    y2 = points[p2][1]
    x3 = points[p3][0]
    y3 = points[p3][1]
    x4 = points[p4][0]
    y4 = points[p4][1]
    m1 = (y2-y1)/(x2-x1)     #y=mx+c
    c1 = y1-(m1*x1)
    m2 = (y4-y3)/(x4-x3)
    c2 = y3-(m2*x3)          #0=(m1-m2)x+(c1-c2)
    x = (c2-c1)/(m1-m2)
    y = (m1*x) + c1
    return[x,y]              #เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630075821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6630080921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6630081521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'xn' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'xn' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'xn' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'xn' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'xn' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 594, 'const': 232, 'code+const': 826}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  xi = int(xn[i])
  yi = int(yn[i])
  xj = int(xn[j])
  yj = int(yn[j])
  x = min(xi,xj)
  y = max(yi,yj)
  w = xi - xj
  h = yi - yj
  w = abs(w)
  h = abs(h)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = int(xn[i])
  yi = int(yn[i])
  xj = int(xn[j])
  yj = int(yn[j])
  x = (xi+xj)/2
  y = (yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  b = frame(points,i,j)
  w = b[2]
  h = b[3]
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = int(xn[i])
  yi = int(yn[i])
  xj = int(xn[j])
  yj = int(yn[j])
  dd = ((xi-xj)**2)+((yi-yj)**2)
  d = math.sqrt(dd)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xp1 = int(xn[p1])
  yp1 = int(yn[p1])
  xp2 = int(xn[p2])
  yp2 = int(yn[p2])
  xp3 = int(xn[p3])
  yp3 = int(yn[p3])
  xp4 = int(xn[p4])
  yp4 = int(yn[p4])
  #แก้สมการ 2 ตัวแปร
  # y = ((yp2-yp1)/(xp2-xp1))(x-xp1) + yp1
  # y = ((yp4-yp3)/(xp4-xp3))(x-xp3) + yp3
  x = (((yp4-yp3)/(xp4-xp3))*xp3-((yp2-yp1)/(xp2-xp1))*xp1-yp3+yp1)/(((yp4-yp3)/(xp4-xp3))-((yp2-yp1)/(xp2-xp1)))
  y = ((yp2-yp1)/(xp2-xp1))*(x-xp1) + yp1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630089621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6630174221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6630311921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631001521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631008021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631013021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0 return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
^
IndentationError: unindent does not match any outer indentation level
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0 return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
^
IndentationError: unindent does not match any outer indentation level
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0 return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
^
IndentationError: unindent does not match any outer indentation level
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0 return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
^
IndentationError: unindent does not match any outer indentation level
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0 return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
^
IndentationError: unindent does not match any outer indentation level
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
# HW01 (ไม่ลบหรือแก้ไขบรรทัดนี้ หรือเพิ่มอะไรก่อนบรรทัดนี้ โดยเด็ดขาด)

def frame(points,i,j):




  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ


def middle(points,i,j):
    xi = points[i*2]
    yi = points[i*2+1]
    xj = points[j*2]
    yj = points[j*2+1]

    return [(xi + xj) / 2, (yi + yj) / 2] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points


def frame_area(points,i,j):
    xi = points[i*2]
    yi = points[i*2+1]
    xj = points[j*2]
    yj = points[j*2+1]

    w = abs(xi - xj)
    h = abs(yi - yj)
    x = min(xi,xj)
    y = max(yi,yj)


  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม


def distance(points,i,j):
    xi = points[i*2]
    yi = points[i*2+1]
    xj = points[j*2]
    yj = points[j*2+1]

    w = abs(xi - xj)
    h = abs(yi - yj)

    return (w**2+h**2)**0.5


  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points


def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2]
    y1 = points[p1*2+1]
    x2 = points[p2*2]
    y2 = points[p2*2+1]
    x3 = points[p3*2]
    y3 = points[p3*2+1]
    x4 = points[p4*2]
    y4 = points[p4*2+1]

    m1 = (y2-y1)/(x2-x1)
    m2 = (y4-y3)/(x4-x3)

    c1 = y1 - m1*x1
    c2 = y3 - m2*x3

    x = (c2-c1)/(m1-m2)
    y = m1*x + c1






  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631018221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631021021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631023321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631025621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631027921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631103921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
^
IndentationError: unindent does not match any outer indentation level
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
^
IndentationError: unindent does not match any outer indentation level
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
^
IndentationError: unindent does not match any outer indentation level
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
^
IndentationError: unindent does not match any outer indentation level
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
^
IndentationError: unindent does not match any outer indentation level
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
# HW01 (ไม่ลบหรือแก้ไขบรรทัดนี้ หรือเพิ่มอะไรก่อนบรรทัดนี้ โดยเด็ดขาด)

def frame(points,i,j):
    x = (points[i*2])
    y = (points[(j*2)+1])
    w = (points[j*2]-points[i*2])
    h = (points[(j*2)+1]-points[(i*2)+1])



  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ


def middle(points,i,j):
    x = (points[i*2]+points[j*2])/2
    y = (points[(i*2)+1]+points[(j*2)+1])/2


  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points


def frame_area(points,i,j):
    w = (points[j*2]-points[i*2])
    h = (points[(j*2)+1]-points[(i*2)+1])
    a = (w*h)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม


def distance(points,i,j):
  d = (((points[i*2]-points[j*2])**2) + ((points[(i*2)+1]-points[(j*2)+1])**2))**(1/2)


  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points


def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2]
    y1 = points[p1*2+1]
    x2 = points[p2*2]
    y2 = points[p2*2+1]
    x3 = points[p3*2]
    y3 = points[p3*2+1]
    x4 = points[p4*2]
    y4 = points[p4*2+1]

    a = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)

    x = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / a
    y = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / a

  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631106821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631113121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631114821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631121121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'x' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'x' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'a' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'd' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'x' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 508, 'const': 376, 'code+const': 884}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x_left = min(points[i*2], points[j*2])
  y_top = max(points[i*2 + 1], points[j*2 + 1])
  width = abs(points[i*2] - points[j*2])
  height = abs(points[i*2 + 1] - points[j*2 + 1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
  return [x_left, y_top, width, height]
def middle(points,i,j):
  x_middle = (points[i*2] + points[j*2])/2
  y_middle = (points[i*2 + 1] + points[j*2 + 1])
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
  return [x_middle, y_middle]
def frame_area(points,i,j):
  width = abs(points[i*2] - points[j*2])
  height = abs(points[i*2 + 1] - points[j*2 + 1])
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
  return width * height
def distance(points,i,j):
  x_diff = points[j*2] - points[i*2]
  y_diff = points[j*2 + 1] - points[i*2 + 1]
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
  return math.sqrt(x_diff ** 2 + y_diff ** 2)
def intersection(points,p1,p2,p3,p4):
  x1, y1 = points[p1*2], points[p1*2 + 1]
  x2, y2 = points[p2*2], points[p2*2 + 1]
  x3, y3 = points[p3*2], points[p3*2 + 1]
  x4, y4 = points[p4*2], points[p4*2 + 1]
  return [x, y]
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631126321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631128621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631129221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631133721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631207521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0TypeError("'list' object is not callable")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0TypeError("'list' object is not callable")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0TypeError("'list' object is not callable")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0TypeError("'list' object is not callable")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0TypeError("type list doesn't define __round__ method")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 780, 'const': 400, 'code+const': 1180}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1,y1 = [points(2*i) , points(2*i+1)]
  x2,y2 = [points(2*j) , points(2*j+1)]
  x = min(x1,x2)
  y = max(y1,y2)
  w = abs(x2-x1)
  h = abs(y2-y1)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1,y1 = [points(2*i) , points(2*i+1)]
  x2,y2 = [points(2*j) , points(2*j+1)]
  x = float[(x1+x2)/2]
  y = float[(y1+y2)/2]
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1,y1 = [points(2*i) , points(2*i+1)]
  x2,y2 = [points(2*j) , points(2*j+1)]
  w = abs[points(2*i) - points(2*j)]
  h = abs[points(2*j+1) - points(2*j+1)]
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1,y1 = [points(2*i) , points(2*i+1)]
  x2,y2 = [points(2*j) , points(2*j+1)]
  import math
  d = math.sqrt[(points(2*i) - points(2*j))**2 + points(2*i+1) - points(2*j+1)]
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,y1 = points[p1*2],points[(p1*2)+1]
  x2,y2 = points[p2*2],points[(p2*2)+1]
  x3,y3 = points[p3*2],points[(p3*2)+1]
  x4,y4 = points[p4*2],points[(p4*2)+1]
  m1 = (y2-y1)/(x2-x1)
  c1 = y1/m1*x1
  m2 = (y4-y3)/(x4-x3)
  c2 = y2/m2*x2
  x = (c2-c1)/(m1-m2)
  y = [(m2*c1-m1*c2)/(m2-m1)]
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631210321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631214921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631221221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631315621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631322021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
^
IndentationError: unindent does not match any outer indentation level
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
^
IndentationError: unindent does not match any outer indentation level
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
^
IndentationError: unindent does not match any outer indentation level
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
^
IndentationError: unindent does not match any outer indentation level
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
^
IndentationError: unindent does not match any outer indentation level
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
# HW01 (ไม่ลบหรือแก้ไขบรรทัดนี้ หรือเพิ่มอะไรก่อนบรรทัดนี้ โดยเด็ดขาด)

def frame(points,i,j):
    p1 = [points[i*2],points[i*2+1]]
    p2 = [points[j*2],points[j*2+1]]
    x = min(p1[0],p2[0])
    y = max(p1[1],p2[1])
    h = max(p1[1],p2[1])-min(p1[1],p2[1])
    w = max(p1[0],p2[0])-min(p1[0],p2[0])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ


def middle(points,i,j):
    x=(points[i*2]+points[j*2])/2
    y=(points[i*2+1]+points[j*2+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points


def frame_area(points,i,j):
    frame_area(points,i,j):
    frame_list  = frame(points,i,j)
    a = frame_list[2]*frame_list[3]
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม


def distance(points,i,j):
    d = math.sqrt((points[i*2]-points[j*2])**2+(points[i*2+1]-points[j*2+1])**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points


def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2]
    y1 = points[p1*2+1]
    x2 = points[p3*2]
    y2 = points[p3*2+1]
    m1 = (y1-points[p2*2+1])/(x1-points[p2*2])
    m2 = (y2-points[p4*2+1])/(x2-points[p4*2])
    x  = (m1*x1-m2*x2)/(m1-m2)+(y2-y1)/(m1-m2)
    y = (m1*m2/(m2-m1))*(y1/m1-y2/m2+x2-x1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631361421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631451221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[04, 0-2, 0-7, 04, 0-2, 0-7, 05, 0-7, 0-2, 0-7], [02, 03, 01, 01, 03, 02, 02, 03, 03, 0-3],
 [05, 06, 011, 01, 011, 016, 04, 05, 07, 012],
 [01, 02, 05, 04, 01, 06, 05, 07, 06, 01]]
test_middle0.0
[[3.0, 36.5, 01.0, 0-1.5, 64.05, 23.5, 31.0, -37.0, -24.5, -1.5, -1.0],
 [3.0, 31.5, 02.0, 0-1.5, 6-1.0, 2.5, 3-1.0, -30.05, -20.5, -50.0, -3.5]]
test_frame_area0.0
[05.0, 014.0, 063.025, 02.025, 012.0, 107.025, 024.075, 033.075, 048.075, 012.0]
test_distance0.0
[05.01, 07.028, 012.075, 04.053, 012.04, 017.073, 07.011, 08.075, 09.092, 012.04]
test_intersection0.0
[[-17.2689, 516.0381, -35.193, -3967.02, 02.304, 15.-34.43, 1.1348, -54.6, 13.22.86, -4.324],
 [20.53, -2.02, 1.092, 2.671, 36-0.33, 3.0644, -106.429, 20.095, -180.571, 134.903, -162.1493]]
bytecount: {'code': 818, 'const': 400, 'code+const': 1218}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
     x1=points[2*i]
     y1=points[(2*j)+1]
     x3=points[2*i]
     y3=points[(2*j)+1]
     diff_x_pow2=math.pow(x3-x1,2)
     diff_y_pow2=math.pow(y3-y1,2)
     d=math.sqrt(diff_x_pow2 + diff_y_pow2)
     a=(x3-x1)
     b=(y3-y1)
     m=[a,b]
     x=min(m)
     y=max(m)
     w=min(m)
     h=max(m)
     return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
     x1=points[2*i]
     x3=points[(2*j)+1]
     y1=points[2*i]
     y3=points[(2*j)+1]
     x=(x3+x1)/2
     y=(y3+y1)/2
     return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
     x1=points[2*i]
     y1=points[(2*j)+1]
     x3=points[2*i]
     y3=points[(2*j)+1]
     diff_x_pow2=math.pow(x3-x1,2)
     diff_y_pow2=math.pow(y3-y1,2)
     d=math.sqrt(diff_x_pow2 + diff_y_pow2)
     a=(x3-x1)
     b=(y3-y1)
     m=[a,b]
     x=min(m)
     y=max(m)
     w=min(m)
     h=max(m)
     a=(w*h)
     return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
     x1=points[2*i]
     y1=points[(2*j)+1]
     x2=points[2*i]
     y2=points[(2*j)+1]
     diff_x_pow2=math.pow(x2-x1,2)
     diff_y_pow2=math.pow(y2-y1,2)
     d=math.sqrt(diff_x_pow2 + diff_y_pow2)
     return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
     x1=points[2*p1]
     y1=points[(2*p1)+1]
     x2=points[2*p2]
     y2=points[(2*p2)+1]
     x3=points[2*p3]
     y3=points[(2*p3)+1]
     x4=points[2*p4]
     y4=points[(2*p4)+1]
     ma=(y3-y1)/(x2-x1)
     mb=(y4-y3)/(x4-x3)
     c1=(y1)-ma*(x1)
     c2=(y3)-ma*(x3)
     x=(c2-c1)/(ma-mb)
     y=((mb*c1)-(ma*c2))/(mb-ma)
     return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631453521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631463821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631504921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631508421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631509021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631520921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631521521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631523821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[04, 0-2, 0-7, 04, 1-2, 1-7, 15, 2-7, -2, 3-7], [1, 2, 3, 41, 21, 3, 42, 2, 3, 43, 4-3],
 [15, 26, 311, 41, 11, 216, 34, 15, 27, 12],
 [1, 2, 35, 4, 1, 26, 35, 17, 26, 1]]
test_middle0.0
[[06.5, 1.0, -1.5, 24.05, 13.5, 21.0, 27.50, 2-4.5, 31.05, 3-1.50],
 [01.5, 12.0, -1.5, 2-1.0, 12.5, 2-1.0, 2-0.5, 2-0.5, 30.0, -3.5]]
test_frame_area0.0
[15.0, 14.0, 963.025, 162.025, 12.0, 4.107.25, 924.075, 133.075, 48.075, 12.0]
test_distance0.0
[15.41, 27.283, 4.124.75, 54.6653, 12.041, 217.873, 47.2411, 18.4175, 29.8392, 12.041]
test_intersection0.0
[[07.089, 016.081, 05.093, 07.02, 02.04, 0-34.043, 01.048, 04.06, 03.022, 04.034],
 [0.053, 0-2.02, 01.09, 02.071, -0.044, 0-6.029, 0.05, 0.057, 013.03, 02.093]]
bytecount: {'code': 504, 'const': 200, 'code+const': 704}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  xi,yi = i,i
  xj,yj = j,j
  x,y = xi,yj
  w = abs(xj-xi)
  h = abs(yj-yi)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi,yi = i,i
  xj,yj = j,j
  x = (xi + xj)/2
  y = (yi + yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi,yi = i,i
  xj,yj = j,j
  w = abs(xj-xi)
  h = abs(yj-yi)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi,yi = i,i
  xj,yj = j,j
  d = math.sqrt((xj-xi)**2+(yj-yi)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
      x1,y1 = p1,p1
      x2,y2 = p2,p2
      x3,y3 = p3,p3
      x4,y4 = p4,p4
      det = (x1-x2)*(y3-y4)-(y1-y2)*(x3-x4)
      x = (((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4))/(det+(det == 0))) * (det != 0)
      y = (((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4))/(det+(det == 0))) * (det != 0)
      return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631525021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631527321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
IndentationError: unexpected indent
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
IndentationError: unexpected indent
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
IndentationError: unexpected indent
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
IndentationError: unexpected indent
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
IndentationError: unexpected indent
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
 xi, yi = points[2*i], points[2*i+1]
 xj, yj = points[2*j], points[2*j+1]
 left_x = min(xi, xj)
 left_y = min(yi, yj)
 width = abs(xi-xj)
 height = abs(yi-yj)
 return [left_x, left_y, width, height]
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
 xi, yi = points[2*i], points[2*i+1]
 xj, yj = points[2*j], points[2*j+1]
 return [(xi+xj)/2,(yi+yj)/2]
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
 frame_area = frame(points,i,j)
 return frame_data[2]*frame_data[3]
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
 xi, yi = points[2*i], points[2*i+1]
 xj, yj = points[2*j], points[2*j+1]
 return ((xj-xi)**2+(yj-yi)**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
 x1, y1 = points[2*p1], points[2*p1+1]
 x2, y2 = points[2*p2], points[2*p2+1]
 x3, y3 = points[2*p3], points[2*p3+1]
 x4, y4 = points[2*p4], points[2*p4+1]
 x = ((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
 y = ((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
 return [x,y]
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631530121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'list_x' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'list_x' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'list_x' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'list_x' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'list_y' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 518, 'const': 176, 'code+const': 694}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  #top left corner's coordinate
  x = min(list_x[i],list_x[j])
  y = max(list_y[i],list_y[j])
  #mininmum frame of 2 coordinates
  w = abs(list_x[j]-list_x[i])
  h = abs(list_y[j]-list_y[i])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = float(list_x[i]+list_x[j])/2
  y = float(list_y[i]+list_y[j])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs(list_x[j]-list_x[i])
  h = abs(list_y[j]-list_y[i])
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  #uses pythagorus to find distance between 2 coordinates
  delta_x = abs(list_x[i]-list_x[j])
  delta_y = abs(list_y[i]-list_y[j])
  d = float(math.sqrt((delta_x)**2+(delta_y)**2))
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  #Ax+By=C
  #L1
  A1 = list_y[p2]-list_y[p1]
  B1 = list_x[p1]-list_x[p2]
  C1 = (A1*list_x[p1]+B1*list_y[p1])
  #L2
  A2 = list_y[p4]-list_y[p3]
  B2 = list_x[p3]-list_x[p4]
  C2 = (A2*list_x[p3]+B2*list_y[p3])
  #find determinant
  D = (A1*B2)-(A2*B1)
  Dx = (C1*B2)-(C2*B1)
  Dy = (A1*C2)-(A2*C1)
  #find intercept
  x = float(Dx/D)
  y = float(Dy/D)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631541021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631551321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631553621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6631802921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6632093421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6632106021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6632123621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6632174621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 4, 'const': 16, 'code+const': 20}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none

6630037021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[14, -2, -7, 14, -2, -7, 5, -7, -2, -27], [92, 93, 91, 91, 3, 2, 2, -23, -23, -3],
 [85, 36, 811, 41, 11, 16, 4, 95, 37, 712], [71, 62, 135, 124, 1, 6, 5, 27, 16, 61]]
test_middle0.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 6.0, 2.5, 3-1.0, 1-0.5, -0.5, 0.50, 2-3.5]]
test_frame_area0.3
[56.0, 214.0, 11463.725, 432.725, 12.0, 107.25, 24.75, 14.25, 133.275, 48.75, 12.0]
test_distance0.1
[75.071, 7.218, 132.675, 14.5.123, 12.04, 8.85, 17.739, 7.1.81, 98.751, 79.92, 12.04]
test_intersection0.0
[[2.22, 17.489, 16.871, 5.983, 6.17, -36.5702, 52.304, -34.43, 1.48, 4.16, 3.22, 4.341],
 [20.153, -2.021, 21.2509, 2.271, 1-0.1944, -6.7129, 10.905, 30.2157, 413.5903, 2.934]]
bytecount: {'code': 632, 'const': 400, 'code+const': 1032}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1 = points[i+1]
    y1 = points[i+2]
    x2 = points[j*2]
    y2 = points[(j*2)+1]
    w = abs(x1-x2)
    h = abs(y1-y2)
    xa = min(x1,x2)
    ya = max(y1,y2)
    return [xa,ya,w,h]
def middle(points,i,j):
    x1 = points[i*2]
    y1 = points[i+1]
    x2 = points[j*2]
    y2 = points[(j*2)+1]
    a = abs((x1+x2)/2)
    b = abs((y1+y2)/2)
    return[a,b]
def frame_area(points,i,j):
    x1 = points[i+1]
    y1 = points[i+2]
    x2 = points[j*2]
    y2 = points[(j*2)+1]
    w = abs(x1-x2)
    h = abs(y1-y2)
    area = abs(w*h)
    return float(area)
def distance(points,i,j):
    x1 = points[i+1]
    y1 = points[i+2]
    x2 = points[j+2]
    y2 = points[(j*2)+1]
    D = ((x2-x1)**2+(y2-y1)**2)**0.5
    return float(D)
def intersection(points,p1,p2,p3,p4):
  x1 = points[p1*2]
  y1 = points[p1*2+1]
  x2 = points[p2*2]
  y2 = points[p2*2+1]
  x3 = points[p3*2]
  y3 = points[p3*2+1]
  x4 = points[p4*2]
  y4 = points[p4*2+1]
  m12 = (y2-y1)/(x2-x1)
  m34 = (y4-y3)/(x4-x3)
  c12 = y1-m12*x1
  c34 = y3-m34*y3
  x =(c12-c34)/(m34-m12)
  y = (m12*x)+c12
  return[x,y]

6331507521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0IndexError('list index out of range')
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.5
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [61.5, 12.0, -1.5, 4-1.50, 32.5, -1.0, 7-0.05, -40.5, 10.50, -13.05]]
test_frame_area0.0
[105.0, 714.0, 9763.725, 32.725, 712.0, 222.1075, 56.25, 624.75, 33.75, 48.75, 12.0]
test_distance0.0
[75.071, 97.928, 162.2675, 04.7153, 162.9704, 2317.373, 67.3611, 68.3675, 109.6192, 162.9704]
test_intersection0.0
[[37.189, 316.81, 5.93.1, -7.0.12, -02.504, -34.043, -0.1.48, 4.336, 43.3322, 4.334],
 [30.153, 3-2.102, 31.109, -02.71, -0.544, -36.029, -0.105, 40.3357, 413.303, 42.393]]
bytecount: {'code': 610, 'const': 396, 'code+const': 1006}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
     x1 = points[i*2]
     y1 = points[i*2]
     x2 = points[j*2]
     y2 = points[(j*2)+5]
     x = min(x1,y1)
     y = max(x2,y2)
     w = abs(x2-x1)
     h = abs(y2-y1)
     return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2]
    x2 = points[j*2]
    y2 = points[j*2]
    x = (x2+x1)/2.0
    y = (y2+y1)/2.0
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2]
    x2 = points[j*2]
    y2 = points[(j*2)+1]
    w = abs(x2-x1)
    h = abs(y2-y1)
    a = w * h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2]
    x2 = points[j*2]
    y2 = points[j*2]
    x = (x2-x1)
    y = (y2-y1)
    d = ((x**2)+(y**2))**(1/2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2]
    y1 = points[(p1*2)+1]
    x2 = points[p2*2]
    y2 = points[(p2*2)-2]
    x3 = points[p3*2]
    y3 = points[p3*2]
    x4 = points[p4*2]
    y4 = points[p4*2]
    m1 = (y2-y1)/(x2-x1)
    m2 = (y4-y3)/(x4-x3)
    x = ((x1*m1)-(x3*m2)-y1+y3)/(m1-m2)
    y = round((m2*(x-x3))+y3,15)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630068421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.2
[5.0, 124.0, 5563.025, 42.025, 112.0, 96107.025, 204.075, 33.75.0, 428.075, 12.0]
test_distance0.2
[5.1, 67.328, 12.0875, 4.1253, 112.054, 17.0973, 67.411, 8.675, 9.292, 12.04]
test_intersection0.0
[[7.3289, 136.81, 5.2493, 67.6702, 2.1604, -314.043, 1.648, 4.26, 3.22.07, 34.634],
 [0.1153, -2.027, 01.509, 2.271, -0.5744, -6.029, 0.095, 0.257, 813.703, 2.493]]
bytecount: {'code': 1160, 'const': 520, 'code+const': 1680}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  XY1 = points[2*i:2*i+2:1]
  XY2 = points[2*j:2*j+2:1]
  x = XY1[0]
  y = XY2[1]
  w = abs(int(XY2[0]) - int(XY1[0]))
  h = abs(int(XY2[1]) - int(XY1[1]))
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  XY1 = points[2*i:2*i+2:1]
  XY2 = points[2*j:2*j+2:1]
  x = abs((int(XY1[0])+int(XY2[0]))/2)
  y = abs((int(XY1[1])+int(XY2[1]))/2)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  XY1 = points[2*i:2*i+2:1]
  XY2 = points[2*j:2*j+2:1]
  w = abs(int(XY2[0]) - int(XY1[0]))
  h = abs(int(XY2[1]) - int(XY1[1]))
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  XY1 = points[2*i:2*i+2:1]
  XY2 = points[2*j:2*j+2:1]
  w = abs(int(XY2[0]) - int(XY1[0]))
  h = abs(int(XY2[1]) - int(XY1[1]))
  d = (w**2+h**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  XY1 = points[2*p1:2*p1+2:1]
  XY2 = points[2*p2:2*p2+2:1]
  XY3 = points[2*p3:2*p3+2:1]
  XY4 = points[2*p4:2*p4+2:1]
  x = abs((((int(XY1[0])*int(XY2[1])-int(XY2[0])*int(XY1[1]))*(int(XY3[0])-int(XY4[0])))-((int(XY3[0])*int(XY4[1])-int(XY4[0])*int(XY3[1]))*(int(XY1[0])-int(XY2[0]))))/(((int(XY1[0]))-int(XY2[0]))*(int(XY3[1])-int(XY4[1]))-((int(XY1[1]))-int(XY2[1]))*(int(XY3[0])-int(XY4[0]))))
  y = abs((((int(XY1[0])*int(XY2[1])-int(XY2[0])*int(XY1[1]))*(int(XY3[1])-int(XY4[1])))-((int(XY3[0])*int(XY4[1])-int(XY4[0])*int(XY3[1]))*(int(XY1[1])-int(XY2[1]))))/(((int(XY1[0]))-int(XY2[0]))*(int(XY3[1])-int(XY4[1]))-((int(XY1[1]))-int(XY2[1]))*(int(XY3[0])-int(XY4[0]))))
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631122821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0NameError("name 'frame' is not defined")
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[6.5, -61.0, -11.5, 14.5, -113.5, -16.0, -47.0, -4.5, 71.5, -12.0],
 [1.5, 2.0, -1.5, -41.0, 12.5, -61.0, -0.5, -70.5, -60.0, 1-3.5]]
test_frame_area0.0
[65.0, 614.0, 63.025, 62.025, 612.0, 6107.025, 624.075, 633.075, 648.075, 612.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 208, 'const': 252, 'code+const': 460}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def middle(points,i,j):
  a = list(points[::2]) #ค่าx
  b = list(points[1::2]) #ค่าy
  x = a[j] - a[i] # ค่า x มาจากตำแหน่ง Xj - Xi ในลิสต์ points
  y = b[j] - b[i] # ค่า y มาจากตำแหน่ง Yj - Yi ในลิสต์ points
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
#  x = list(points[::2]) #ค่าx
#  y = list(points[1::2]) #ค่าy
  a = 3*2 #ค่าจากตัวอย่างรูปภาพค่ะ (หนูไม่รู้ว่านำค่า i,j ไปใช้ในการเขียนโค้ดนี้ยังไงค่ะT_T)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  a = list(points[::2]) #ค่าx
  b = list(points[1::2]) #ค่าy
  d = ( ((a[i]-a[j]))**2 + ((b[i]-b[j]))**2 )**(1/2) #นำค่า ( (Xi-Xj)**2 + (Yi-Yj)**2 )**(1/2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
#def intersection(points,p1,p2,p3,p4):
#  a = list(points[::2]) #ค่าx
#  b = list(points[1::2]) #ค่าy
#  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631454121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0NameError("name 'middle' is not defined")
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'frame_area' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0NameError("name 'distance' is not defined")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0NameError("name 'intersection' is not defined")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 148, 'const': 88, 'code+const': 236}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points, i, j):
    x = min(points[2 * i], points[2 * j])
    y = max(points[2 * i + 1], points[2 * j + 1])
    w = abs(points[2 * i] - points[2 * j])
    h = abs(points[2 * i + 1] - points[2 * j + 1])
    return [x, y, w, h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ

6631455821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[['['4, '['-2, '['-7, '['4, '['-2, '['-7, '['5, '['-7, '['-2, '['-7],
 ['4'2, '-'3, '-'1, '4'1, '-'3, '-'2, '5'2, '-'3, '-'3, '-'3],
 [','5, '2'6, '7'11, '1,' 11, '2'16, '7'4, ','5, '7', '12', '7'],
 [' '1, ','2, '5,', ' '4, ','1, ','6, ' '5, ','7, ','6, ','1]]
test_middle0.0
[['['6.5, '['1.0, '['-1.5, '['4.5, '['3.5, '['1.0, '['7.0, '['-4.5, '['1.5, '['-1.0],
 ['6'1.5, '1'2.0, '-'1.5, '4'-1.0, '3'2.5, '-1'.0, '7'-0.5, '-'0.5, '1'0.0, '-'3.5]]
test_frame_area0.1
[5.0, 14.0, 63.25, 02.725, 712.0, 3107.725, 24.275, 233.275, 148.275, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0ValueError('too many values to unpack (expected 2)')
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 1156, 'const': 945, 'code+const': 2101}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
class LinearPoint :
   def __init__(self, x, y):
        self.x = x
        self.y = y
def frame(myList,pointFromlist1,pointFromlist2):
      index1 = int(pointFromlist1)
      index2 = int(pointFromlist2)
      point1 = LinearPoint(myList[2*(index1)],myList[(2*(index1))+1])
      point2 = LinearPoint(myList[2*(index2)],myList[(2*(index2))+1])
      maxPointx = max(point1.x,point2.x)
      minPointx = min(point1.x,point2.x)
      maxPointy = max(point1.y,point2.y)
      minPointy = min(point1.y,point2.y)
      wide = max(abs(point1.x),abs(point2.x)) - min(abs(point1.x),abs(point2.x))
      tall = max(abs(point1.y),abs(point2.y)) - min(abs(point1.y),abs(point2.y))
      AnsFrame = f"[{minPointx}, {maxPointy}, {wide}, {tall}]"
      return AnsFrame
def middle(myList,pointFromlist1,pointFromlist2):
      index1 = int(pointFromlist1)
      index2 = int(pointFromlist2)
      point1 = LinearPoint(myList[2*(index1)],myList[(2*(index1))+1])
      point2 = LinearPoint(myList[2*(index2)],myList[(2*(index2))+1])
      midPointx = point2.x + ((point1.x - point2.x) / 2)
      midPointy = point2.y + ((point1.y - point2.y) / 2)
      AnsMiddle = f"[{float(midPointx)}, {float(midPointy)}]"
      return AnsMiddle
def frame_area(myList,pointFromlist1,pointFromlist2):
      index1 = int(pointFromlist1)
      index2 = int(pointFromlist2)
      point1 = LinearPoint(myList[2*(index1)],myList[(2*(index1))+1])
      point2 = LinearPoint(myList[2*(index2)],myList[(2*(index2))+1])
      wide = max(abs(point1.x),abs(point2.x)) - min(abs(point1.x),abs(point2.x))
      tall = max(abs(point1.y),abs(point2.y)) - min(abs(point1.y),abs(point2.y))
      FrameArea = float(wide*tall)
      return FrameArea
def distance(myList,pointFromlist1,pointFromlist2):
      index1 = int(pointFromlist1)
      index2 = int(pointFromlist2)
      point1 = LinearPoint(myList[2*(index1)],myList[(2*(index1))+1])
      point2 = LinearPoint(myList[2*(index2)],myList[(2*(index2))+1])
      distance2 = pow(float(point2.x - point1.x),2) + pow(float(point2.y - point1.y),2)
      Distance = math.sqrt(distance2)
      return Distance
def intersection(myList,pointFromlist1,pointFromlist2,pointFromlist3,pointFromlist4):
      index1 = int(pointFromlist1)
      index2 = int(pointFromlist2)
      index3 = int(pointFromlist3)
      index4 = int(pointFromlist4)
      point1 = LinearPoint(myList[2*(index1)],myList[(2*(index1))+1])
      point2 = LinearPoint(myList[2*(index2)],myList[(2*(index2))+1])
      point3 = LinearPoint(myList[2*(index3)],myList[(2*(index3))+1])
      point4 = LinearPoint(myList[2*(index4)],myList[(2*(index4))+1])
      # linear1 A1x + B1y = C1
      A1 = (point2.y) - (point1.y)
      B1 = (point1.x) - (point2.x)
      C1 = (A1*(point1.x)) + (B1*(point1.y))
      # linear2 A2x + B2y = C2
      A2 = (point4.y) - (point3.y)
      B2 = (point3.x) - (point4.x)
      C2 = (A2*(point3.x)) + (B2*(point3.y))
      detoflinear = (A1*B2) - (A2*B1)
      intersectionPointx = (((B2*C1) - (B1*C2))/detoflinear)
      intersectionPointy = (((A1*C2) - (A2*C1))/detoflinear)
      return f"[{intersectionPointx}, {intersectionPointy}]"

6631220621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, -6, -11, 1, -11, -16, -4, -5, 7, 12], [1, 2, -5, -4, 1, -6, -5, -7, -6, 1]]
test_middle0.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, 0-1.5, 3-1.0, 32.05, 0-1.0, 2-0.5, 3-0.5, 2.0, 4.0, 0-3.5]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, 7-6.429, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 584, 'const': 400, 'code+const': 984}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x = points[(i*2)]
  y = points[(j*2)+1]
  w = points[(j*2)] - points[(i*2)]
  h = points[(j*2)+1] - points[(i*2)+1]
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = abs(( points[(i*2)] + points[(j*2)] )/2)
  y = abs(( points[(i*2)+1] + points[(j*2)] )/2)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = points[(j*2)] - points[(i*2)]
  h = points[(j*2)+1] - points[(i*2)+1]
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  a = (points[(i*2)] - points[(j*2)])**2
  b = (points[(i*2)+1] - points[(j*2)+1])**2
  d = (a+b)**(0.5)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,a,b,f,g):
  m = (points[(b*2)+1] - points[(a*2)+1]) / (points[(b*2)] - points[(a*2)])
  c = points[(b*2)+1] - (m*points[(b*2)])
  M = (points[(g*2)+1] - points[(f*2)+1]) / (points[(g*2)] - points[(f*2)])
  C = points[(g*2)+1] - (M*points[(g*2)])
  x = abs((C-c)/(m-M))
  y = (m*x)+c
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631512921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[14, 1-2, 1-7, 14, -2, 2-7, 25, 3-7, 3-2, -47], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.3IndexError('list index out of range')
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0TypeError("unsupported operand type(s) for ^: 'float' and 'float'")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[47.64, 18.97, 106.3, -812.46, -5.5593, -67.02, 2.04, -534.243, 01.7548, 04.66, 03.79]22,
 [4.634, 18.97],
 1[0.53, -12.4602, -51.5509, 2.71, -60.044, -56.29, 0.705, 0.6657, 13.03, 2.793]]
bytecount: {'code': 602, 'const': 456, 'code+const': 1058}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x1 = points[::2]
  y1 = points[1::2]
  a = x1[i]
  b = y1[i]
  c = x1[j]
  d = y1[j]
  x = b
  y = d
  w = abs(a-c)
  h = abs(b-d)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x0 = points[::2]
  y0 = points[1::2]
  a = x0[i]
  b = y0[i]
  c = x0[j]
  d = y0[j]
  x = (a+c)/2
  y = (b+d)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x2 = points[:-1:2]
  y2 = points[1:-1:2]
  l = x2[i]
  m = y2[i]
  n = x2[j]
  o = y2[j]
  w = abs(l-n)
  h = abs(m-o)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x4 = points[::2]
  y4 = points[1::2]
  w = x4[i]
  x = y4[i]
  y = x4[j]
  z = x4[j]
  d = math.sqrt(abs(w-y)^2 - abs(x-z)^2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x5 = points[::2]
  y5 = points[1::2]
  a = x5[p1]
  b = y5[p1]
  c = x5[p2]
  d = y5[p2]
  e = x5[p3]
  f = y5[p3]
  g = x5[p4]
  h = y5[p4]
  m1 = (d-b)/(c-a)
  m2 = (h-f)/(g-e)
  x = 7/(m2-m1)
  y = x
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630057521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.5
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -01.5, -31.0, 32.05, 0-1.0, -20.5, 3-0.5, -2.0, 4.0, 0-3.5]]
test_frame_area0.2
[5.0, 124.0, 563.25, 42.25, 112.0, 96107.25, 204.75, 33.75, 428.75, 12.0]
test_distance0.2
[5.1, 67.328, 12.0875, 4.1253, 112.054, 17.0973, 67.411, 8.675, 9.292, 12.04]
test_intersection0.0
[[7.3289, 136.81, 5.2493, 67.6702, 2.1604, -314.043, 1.648, 4.26, 3.22.07, 34.634],
 [-0.1153, -2.027, 01.509, 2.271, -0.5744, -6.029, -0.095, 0.257, 813.703, 2.493]]
bytecount: {'code': 894, 'const': 520, 'code+const': 1414}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  p1 = points[2*i:2*i+2]
  p2 = points[2*j:2*j+2]
  x1 = int(p1[0]); y1 = int(p1[1])
  x2 = int(p2[0]); y2 = int(p2[1])
  x = min(x1,x2)
  y = max(y1,y2)
  w = abs(x1-x2)
  h = abs(y1-y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  p1 = points[2*i:2*i+2]
  p2 = points[2*j:2*j+2]
  x1 = int(p1[0]); y1 = int(p1[1])
  x2 = int(p2[0]); y2 = int(p2[1])
  x = (x1+x2)/2
  y = (y1+x2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  p1 = points[2*i:2*i+2]
  p2 = points[2*j:2*j+2]
  x1 = int(p1[0]); y1 = int(p1[1])
  x2 = int(p2[0]); y2 = int(p2[1])
  w = abs(x1-x2)
  h = abs(y1-y2)
  a = w*h
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  p1 = points[2*i:2*i+2]
  p2 = points[2*j:2*j+2]
  x1 = int(p1[0]); y1 = int(p1[1])
  x2 = int(p2[0]); y2 = int(p2[1])
  dx = abs(x1-x2)
  dy = abs(y1-y2)
  d = math.sqrt(dx**2+dy**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ poin
def intersection(points,p1,p2,p3,p4):
  p1 = points[2*p1:2*p1+2]
  p2 = points[2*p2:2*p2+2]
  p3 = points[2*p3:2*p3+2]
  p4 = points[2*p4:2*p4+2]
  x1 = int(p1[0]); y1 = int(p1[1])
  x2 = int(p2[0]); y2 = int(p2[1])
  x3 = int(p3[0]); y3 = int(p3[1])
  x4 = int(p4[0]); y4 = int(p4[1])
  m1 = (y2-y1)/(x2-x1)
  m2 = (y4-y3)/(x4-x3)
  x = (y3 + m1*x1 - y1 -m2*x3)/(m1-m2)
  y = m1*(x-x1) + y1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630024821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.2
[5.0, -124.0, 563.25, -42.25, -112.0, 96107.25, 204.75, 33.75, -428.75, 12.0]
test_distance0.2
[5.1, 67.328, 12.0875, 4.1253, 112.054, 17.0973, 67.411, 8.675, 9.292, 12.04]
test_intersection0.0
[[7.3289, 136.81, 5.2493, 67.6702, 2.1604, -314.043, 1.648, 4.26, 3.22.07, 34.634],
 [-0.1153, -2.027, 01.509, 2.271, -0.5744, -6.029, -0.095, 0.257, 813.703, 2.493]]
bytecount: {'code': 748, 'const': 400, 'code+const': 1148}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1 = int(points[i*2]) ; y1 = int(points[(i*2)+1])
    x2 = int(points[j*2]) ; y2 = int(points[(j*2)+1])
    x = x1-x2 ; y = y1-y2
    A = min(x1,x2) ; B = max(y1,y2) ; w = abs(x) ; h = abs(y)
    return [A,B,w,h]
def middle(points,i,j):
    x1 = int(points[i*2]) ; y1 = int(points[(i*2)+1])
    x2 = int(points[j*2]) ; y2 = int(points[(j*2)+1])
    x = (x1+x2)/2 ; y = (y1+y2)/2
    return [x,y]
def frame_area(points,i,j):
    x1 = int(points[i*2]) ; y1 = int(points[(i*2)+1])
    x2 = int(points[j*2]) ; y2 = int(points[(j*2)+1])
    x = x1-x2 ; y = y1-y2 ; w = abs(x) ; h = abs(y)
    a = x*y
    return a
def distance(points,i,j):
    x1 = int(points[i*2]) ; y1 = int(points[(i*2)+1])
    x2 = int(points[j*2]) ; y2 = int(points[(j*2)+1])
    a = (x1-x2)**2  ; b = (y1-y2)**2 ; d = (a+b)**(1/2)
    return d
def intersection(points,p1,p2,p3,p4):
    x1 = int(points[p1*2]) ; y1 = int(points[(p1*2)+1])
    x2 = int(points[p2*2]) ; y2 = int(points[(p2*2)+1])
    x3 = int(points[p3*2]) ; y3 = int(points[(p3*2)+1])
    x4 = int(points[p4*2]) ; y4 = int(points[(p4*2)+1])
    M1 = (y1-y2)/(x1-x2) ; M2 = (y3-y4)/(x3-x4)  # Y =MX+C
    C1 = y1-x1*M1 ; C2 = y3-x3*M2
    X = (C2-C1)/(M1-M2) ; Y = M1*X+C1
    return [X,Y]

6630076421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.2
[5.0, 124.0, 5563.025, 42.025, 112.0, 96107.025, 204.075, 33.75.0, 428.075, 12.0]
test_distance0.2
[5.1, 67.328, 12.0875, 4.1253, 112.054, 17.0973, 67.411, 8.675, 9.292, 12.04]
test_intersection0.0ZeroDivisionError('float division by zero')
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 840, 'const': 496, 'code+const': 1336}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    d1 = points[2*i:2*i+2]
    d2 = points[2*j:2*j+2]
    x1 = int(d1[0])
    y1 = int(d1[1])
    x2 = int(d2[0])
    y2 = int(d2[1])
    x = min(x1,x2) #จุดซ้ายสุดเเปลว่าxต้องน้อยสุด
    y = max(y1,y2) #บนสุด=yมากสุด
    w = abs(x1-x2)
    h = abs(y1-y2)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    d1 = points[2*i:2*i+2]
    d2 = points[2*j:2*j+2]
    x1 = int(d1[0])
    y1 = int(d1[1])
    x2 = int(d2[0])
    y2 = int(d2[1])
    x = float((x1+x2)/2)
    y = float((y1+y2)/2)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j): #[ 0 1 2 3 4 5 6 7 8 ] [x1 y1 x2 y2
    d1 = points[2*i:2*i+2]
    d2 = points[2*j:2*j+2]
    x1 = int(d1[0])
    y1 = int(d1[1])
    x2 = int(d2[0])
    y2 = int(d2[1])
    a = abs(x1-x2)*abs(y1-y2)
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    d1 = points[2*i:2*i+2]
    d2 = points[2*j:2*j+2]
    x1 = int(d1[0])
    y1 = int(d1[1])
    x2 = int(d2[0])
    y2 = int(d2[1])
    dx = (x2-x1)**2
    dy = (y2-y1)**2
    d = float((dx+dy)**0.5)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[2*p1] ; y1 = points[2*p1+1]
    x2 = points[2*p2] ; y2 = points[2*p2+1]
    x3 = points[2*p3] ; y3 = points[2*p3+1]
    x4 = points[2*p4] ; y4 = points[2*p4+1]
    ml1 = int((y2-y1)/(x2-x1))
    ml2 = int((y4-y3)/(x4-x3))
    x = float((ml1*x1-ml2*x3+y3-y1)/(ml1-ml2))
    y = float(((x3-x1)*(ml1*ml2)+y1*ml2-y3*ml1)/(ml2-ml1))
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631309921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.2
[5.0, 124.0, 5563.025, 42.025, 112.0, 96107.025, 204.075, 33.75.0, 428.075, 12.0]
test_distance0.2
[5.1, 67.328, 12.0875, 4.1253, 112.054, 17.0973, 67.411, 8.675, 9.292, 12.04]
test_intersection0.0IndexError('list index out of range')
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 828, 'const': 452, 'code+const': 1280}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1 = int(points[i * 2])
  y1 = int(points[(i * 2) + 1])
  x2 = int(points[j * 2])
  y2 = int(points[(j * 2) + 1])
  x = int(min(x1, x2))
  y = int(max(y1, y2))
  w = abs((int(points[j * 2])) - int(points[i * 2]))
  h = abs((int(points[(j * 2) + 1])) - int(points[(i * 2) + 1]))
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (int(points[i * 2]) + int(points[j * 2])) / 2
  y = (int(points[(i * 2) + 1]) + int(points[(j * 2) +1])) / 2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs((int(points[j * 2])) - int(points[i * 2]))
  h = abs((int(points[(j * 2) + 1])) - int(points[(i * 2) + 1]))
  a = w * h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d = ((int(points[i * 2]) - int(points[j * 2])) ** 2 + (int(points[(i * 2) + 1]) - int(points[(j * 2) + 1])) ** 2) ** 0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  point_1 = points[p1 * 2 : (p1 * 2) + 2]
  point_2 = points[p2 * 2 : (p2 * 2) + 2]
  point_3 = points[p3 * 2 : (p3 * 2) + 2]
  point_4 = points[p4 * 2 : (p1 * 4) + 2]
  m1 = (float(point_2[1]) - float(point_1[1])) / (float(point_2[0]) - float(point_1[0]))
  m2 = (float(point_4[1]) - float(point_3[1])) / (float(point_4[0]) - float(point_3[0]))
  x1 = float(point_1[0])
  y1 = float(point_1[1])
  x3 = float(point_3[0])
  y3 = float(point_3[1])
  x = (y3 - y1 - (m2 * x3) + (m1 * x1)) / (m1 - m2)
  y = ((y1 * m2) - (y3 * m1) + (m1 * m2 * (x3 - x1))) / (m2 - m1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630005921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, -6, -11, 1, -11, -16, -4, -5, 7, 12], [1, 2, -5, -4, 1, -6, -5, -7, -6, 1]]
test_middle0.0
[[6.5.0, -61.0, -11.05, 14.05, -3.05, -81.0, 47.0, -164.05, -41.05, 3-1.0],
 [1.05, 2.0, -51.05, -41.0, -62.05, -13.0, -12.0.5, -60.05, -50.0, -13.05]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 564, 'const': 288, 'code+const': 852}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x3, y3 = points[j*2:j*2+2]
    return [x1, y3, x3-x1, y3-y1] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x0, y0 = points[i:i+2]
    x2, y2 = points[j*2:j*2+2]
    x1 = x2-x0
    y1 = y2-y0
    return [float(x1), float(y1)] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x1, y1 = points[i*2:i*2+2]
    x3, y3 = points[j*2:j*2+2]
    return float((x3-x1)*(y3-y1)) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1, y1 = points[i*2:i*2+2]
    x2, y2 = points[j*2:j*2+2]
    return ((x2-x1)**2+(y1-y2)**2)**0.5 # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,a,b,c,d): #5=(1,5) 6=(3,1) 1=(2,2) 2==(3,3)
    x5, y5 = points[a*2:a*2+2]
    x6, y6 = points[b*2:b*2+2]
    x1, y1 = points[c*2:c*2+2]
    x2, y2 = points[d*2:d*2+2]
    m1 = (y5-y6)/(x5-x6)
    m2 = (y1-y2)/(x1-x2)
    X  = (y1 - m2*x1 - y5 + m1*x5) / (m1 - m2)
    Y = m1*X + (y5 - m1*x5)
    return [X,Y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631004421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.1ValueError('math domain error')
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.926, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 774, 'const': 496, 'code+const': 1270}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    P = [points[2*i],points[2*i+1]]
    Q = [points[2*j],points[2*j+1]]
    x = P[0]
    y = Q[1]
    w = abs(Q[0]-P[0])
    h = abs(Q[1]-P[1])
    return [x,y,w,h]
def middle(points,i,j):
    P = [points[2*i],points[2*i+1]]
    Q = [points[2*j],points[2*j+1]]
    x = abs((Q[0]+P[0])/2)
    y = abs((Q[1]+P[1])/2)
    return [x,y]
def frame_area(points,i,j):
    P = [points[2*i],points[2*i+1]]
    Q = [points[2*j],points[2*j+1]]
    A = abs((Q[0]-P[0])*(Q[1]-P[1]))
    return float(A)
def distance(points,i,j):
    P = [points[2*i],points[2*i+1]]
    Q = [points[2*j],points[2*j+1]]
    d = math.sqrt((Q[0]-P[0])**2+(Q[1]-P[1]))
    return d
def intersection(points,p1,p2,p3,p4):
    Px = points[2*p1]
    Py = points[2*p1+1]
    Qx = points[2*p2]
    Qy = points[2*p2+1]
    Rx = points[2*p3]
    Ry = points[2*p3+1]
    Sx = points[2*p4]
    Sy = points[2*p4+1]
    x = ((Px*Qy-Py*Qx)*(Rx-Sx)-(Px-Qx)*(Rx*Sy-Ry*Sx))/((Px-Qx)*(Ry-Sy)-(Py-Qy)*(Rx-Sx))
    y = ((Px*Qy-Py*Qx)*(Ry-Sy)-(Py-Qy)*(Rx*Sy-Ry*Sx))/((Px-Qx)*(Ry-Sy)-(Py-Qy)*(Rx-Sx))
    return [x,y]

6630009421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, 61, 51, 3, 82, 72, 103, 93, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[3.0, 36.5, 01.0, 0-1.5, 64.05, 23.5, 31.0, 37.0, 2-4.5, 1.5, -1.0],
 [31.5, 2.0, 3-1.5, 0-1.0, 02.5, 2-1.0, 1-0.5, 1.-0, 2.5, 30.0, 0-3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.3
[65.731, 7.28.9, 132.2175, 14.1253, 12.04, 167.6273, 7.11, 48.6175, 9.92, 142.1504]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 606, 'const': 372, 'code+const': 978}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    dx = abs(points[i+i]-points[j+j])
    dy = abs(points[2*i+1]-points[2*j+1])
    p1 = points[i+i]
    p2 = points[2*i+1]+dy
    p3 = [p1,p2,dx,dy]
    return p3 # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
     m = [abs((points[2*i]+points[2*j+1])/2),abs((points[i]+points[j+j+1])/2)]
     return m # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    dx = abs(points[i+i]-points[j+j])
    dy = abs(points[2*i+1]-points[2*j+1])
    a = dx*dy
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    import math
    d = math.sqrt(((points[2*i]-points[2*j])**2)+((points[i+i-1]-points[j+j-1])**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    m1 = (points[p2+p2+1]-points[p1+p1+1])/(points[p2+p2]-points[p1+p1])
    m2 = (points[p4+p4+1]-points[p3+p3+1])/(points[p4+p4]-points[p3+p3])
    c1 = points[p1+p1+1]-(m1*points[p1+p1])
    c2 = points[p3+p3+1]-(m2*points[p3+p3])
    x = (c2-c1)/(m1-m2)
    y = (m2*x)+c2
    z = [x,y]
    return z # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630012221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[3.0, -26.5, -5.0, 1.0, 1.0, -1.5, 4.5, -3.05, 31.0, 7.0],
 [3-4.05, 31.5, 0-1.0],
 0[1.5, 2.0, -1.5, -1.0, 2.5, 3-1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[-7.2689, 416.813, 25.8693, 47.4502, 2.3204, -834.5643, 1.482, 34.236, 113.622, 84.034],
 [40.8653, 1-2.6102, 1.097, 12.4871, -0.3344, -16.29, 0.1105, 0.2257, 123.9403, -62.44, -930.02]]
bytecount: {'code': 638, 'const': 400, 'code+const': 1038}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    w = abs(x2-x1)
    h = abs(y2-y1)
    x = min(x1,x2)
    y = max(y1,y2)
    return [x,y,w,h]
def middle(points,i,j):
    x1 = points[i-1]
    y1 = points[i]
    x2 = points[j*2]
    y2 = points[j*2+1]
    x = (x1+x2)/2
    y = (y1+y2)/2
    return [x,y]
def frame_area(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    w = abs(x2-x1)
    h = abs(y2-y1)
    a = w*h
    return float(a)
def distance(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    d = math.sqrt((x1-x2)**2 + (y1-y2)**2)
    return d
def intersection(points,p1,p2,p3,p4):
     x1 = points[p1*2]
     y1 = points[p1*2+1]
     x2 = points[p2*2]
     y2 = points[p2*2+1]
     x3 = points[p3*2]
     y3 = points[p3*2+1]
     x4 = points[p4*2]
     y4 = points[p4*2+1]
     m12 = (y2-y1)/(x2-x1)
     m34 = (y4-y3)/(x4-x3)
     c12 = y1 - m12*x1
     c34 = y3 - m34*x3
     x =  c34-c12/(m12 - m34)
     y = m12*x + c12
     return [x,y]

6630033421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0
['5.0', '14.0', '63.25', '2.25', '12.0', '107.25', '24.75', '33.75', '48.75', '12'.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[-37.3189, 416.816, 85.493, 7.02, -12.404, -34.16, 5.5743, 31.468, 4.796, 3.0622, 4.8734],
 [30.753, -2.02, 1.609, 02.371, -10.34, 0.4, 1-6.7129, 10.05, -10.0857, 143.4403, -12.8693]]
bytecount: {'code': 694, 'const': 400, 'code+const': 1094}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x=min(points[i*2],points[j*2])
  y=max((points[i*2+1]),(points[j*2+1]))
  w=abs(points[i*2]-points[j*2])
  h=abs(points[i*2+1]-points[j*2+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x=(points[i*2]+points[j*2])/2
  y=(points[i*2+1]+points[j*2+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w=abs(points[i*2]-points[j*2])
  h=abs(points[i*2+1]-points[j*2+1])
  a=w*h
  return str(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  w=abs(points[i*2]-points[j*2])
  h=abs(points[i*2+1]-points[j*2+1])
  d=math.sqrt(pow(w,2)+pow(h,2))
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1=points[p1*2]
  y1=points[p1*2+1]
  x2=points[p2*2]
  y2=points[p2*2+1]
  x3=points[p3*2]
  y3=points[p3*2+1]
  x4=points[p4*2]
  y4=points[p4*2+1]
  d=(x1-x2)*(y3-y4)-(y1-y2)*(x3-x4)
  x=((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*x4-y3*x4))/d
  y=((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*x4-y3*x4))/d
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630041421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0
[-65.250, -614.250, -63.25, -62.25, -6.125.0, -6107.25, -624.275, -633.275, -648.275, -6.125.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[7.89, 16.81, -05.1793, 7.6102, 12.1704, -1134.95, -43.0, -12.7548, 4.96, 3.622, 4.934],
 [0.6153, -2.8302, 1.09, 2.671, 5-0.1744, -56.295, 0.05, -60.757, -2.1, 93.603, -2.193]]
bytecount: {'code': 638, 'const': 500, 'code+const': 1138}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    xi = [points[(i)*2], points[(j)*2]]
    yi = [points[(i)*2+1], points[(j)*2+1]]
    h = abs(yi[0]-yi[1]); w = abs(xi[0]-xi[1])
    x = min(xi); y=max(yi)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    y = (points[(i)*2+1] + points[(j)*2+1])/2
    x = (points[(i)*2] + points[(j)*2])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    frame(points,i,j)
    a = points[3]*points[4]
    return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi = [points[(i)*2], points[(j)*2]]
    yi = [points[(i)*2+1], points[(j)*2+1]]
    d = math.sqrt((xi[0]-xi[1])**2+(yi[0]-yi[1])**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xi = [points[(p1)*2], points[(p2)*2], points[(p3)*2], points[(p4)*2]]
  yi = [points[(p1)*2+1], points[(p2)*2+1], points[(p3)*2+1], points[(p4)*2+1]]
  m1 = (yi[1]-yi[0]) / (xi[1]-xi[0])
  m2 = (yi[3]-yi[2]) / (yi[3]-yi[2])
  c1 = yi[0] - m1*xi[0]
  c2 = yi[2] - m2*xi[2]
  x = (c2-c1) / (m1-m2)
  y = m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p

6630046621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[6.5.0, 61.0, 1-1.05, 14.05, 113.05, 16.0, 47.0, 5-4.05, 71.05, -12.0],
 [1.05, 2.0, -1.5, -1.0, 42.05, -1.0, 6-0.05, 5.-0, 7.05, 60.0, 1-3.05]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[2.22, 17.489, 16.871, 5.983, 6.17, -36.5702, 52.304, -34.43, 1.48, 4.16, 3.22, 4.341],
 [20.153, -2.021, 21.2509, 2.271, 1-0.1944, -6.7129, 10.905, 30.2157, 413.5903, 2.934]]
bytecount: {'code': 650, 'const': 400, 'code+const': 1050}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1 = points[i*2]
  y1 = points[i*2+1]
  x2 = points[j*2]
  y2 = points[j*2+1]
  w = abs(x1-x2)
  h = abs(y1-y2)
  x = min(x1,x2)
  y = max(y1,y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1 = points[i*2]
  y1 = points[i*2+1]
  x2 = points[j*2]
  y2 = points[j*2+1]
  x = float(abs(x1-x2))
  y = float(abs(y1-y2))
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1 = points[i*2]
  y1 = points[i*2+1]
  x2 = points[j*2]
  y2 = points[j*2+1]
  w = abs(x1-x2)
  h = abs(y1-y2)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1 = points[i*2]
  y1 = points[i*2+1]
  x2 = points[j*2]
  y2 = points[j*2+1]
  import math
  d = math.sqrt((x1-x2)**2+(y1-y2)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[p1*2]
  y1 = points[p1*2+1]
  x2 = points[p2*2]
  y2 = points[p2*2+1]
  x3 = points[p3*2]
  y3 = points[p3*2+1]
  x4 = points[p4*2]
  y4 = points[p4*2+1]
  m12 = (y2-y1)/(x2-x1)
  m34 = (y4-y3)/(x4-x3)
  c12 = y1-m12*x1
  c34 = y3-m34*y3
  x =(c12-c34)/(m34-m12)
  y = (m12*x)+c12
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631215521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[-36.5, 51.0, -21.5, -64.5, 83.5, 1.0, -37.0, -74.5, -11.5, -41.0],
 [81.5, 2.0, -1.5, -31.0, 2, -7.5, -11.0, -60.5, -40.5, 10.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[3227.2589, -2176.081, 4885.093, -1167.502, 267.504, 65-34.043, 162.548, -2874.56, -373.522, -2664.534],
 [510.8253, -552.02, 1.09, 121.6871, -390.6144, -586.829, -0.805, 230.597, -14103.03, 2151.0, -9388.5]]
bytecount: {'code': 768, 'const': 372, 'code+const': 1140}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x=min([points[2*i],points[2*j]])
  y=max(points[(2*i)+1],points[(2*j)+1])
  w=abs(points[2*i]-points[2*j])
  h=abs(points[(2*i)+1]-points[(2*j)+1])
  return [x,y,w,h]
def middle(points,i,j):
  xi,yi=points[i],points[i+1]
  xj,yj=points[j],points[j+1]
  x=xj-xi
  y=yj-yi
  return [x,y]
def frame_area(points,i,j):
  xi,yi=points[2*i],points[(2*i)+1]
  xj,yj=points[2*j],points[(2*j)+1]
  diff_x=abs(xi-xj)
  diff_y=abs(yi-yj)
  area=diff_x*diff_y
  area=float(area)
  return(area)
def distance(points,i,j):
  xi,yi=points[2*i],points[(2*i)+1]
  xj,yj=points[2*j],points[(2*j)+1]
  diff_x=xj-xi
  diff_y=yj-yi
  dis_sec=math.pow(diff_x,2)+math.pow(diff_y,2)
  distance=math.sqrt(dis_sec)
  return(distance)
def intersection(points,p1,p2,p3,p4):
  x1,y1=points[2*p1],points[(2*p1)+1]
  x2,y2=points[2*p2],points[(2*p2)+1]
  x3,y3=points[2*p3],points[(2*p3)+1]
  x4,y4=points[2*p4],points[(2*p4)+1]
  x_intersection=(x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4)/(x1-x2)*(y3-y4)-(y1-y2)*(x3-x4)
  y_intersection=(x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4)/(x1-x2)*(y3-y4)-(y1-y2)*(x3-x4)
  return [x_intersection,y_intersection]

6632034421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[6.5, 1.0, -21.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -21.5, -1.0, 2.5, -1.0, -10.5, -10.5, 0.0, -43.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[37.6789, 316.6781, 35.6793, 17.502, 2.504, 1-34.543, 1.548, 214.06, 3.21.02, 214.034],
 [0.53, -2.6702, 31.6709, 32.671, 1-0.544, -6.2.59, 10.05, 10.5, 21.07, 213.03, 21.093]]
bytecount: {'code': 630, 'const': 424, 'code+const': 1054}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
# ค่า i = 1 ค่า j = 3 เราพิจารณาหาจุด point
  x1=points[(i*2)]#x1=2
  y1=points[(i*2)+1]#y1=2
  x3=points[(j*2)]#x3=4
  y3=points[(j*2)+1] #y3=5
  x=min(x1,x3)
  y=max(y1,y3)
  w=abs(x3-x1)
  h=abs(y3-y1)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
# ค่า i = 0 ค่า j = 2 เราพิจารณาหาจุด point
  x0=points[i*2]#x0=1
  y0=points[(i*2)+1]#y0=1
  x2=points[(j*2)]#x2=3
  y2=points[(j*2)+1]#y2=3
  x=(x0+x2)//2 #จุดกึ่งกลางระหว่างจุด2จุด
  y=(y0+y2)//2#จุดกึ่งกลางระหว่างจุด2จุด
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
# ค่า i = 1 ค่า j = 3 เราพิจารณาหาจุด point
  x1=points[(i*2)]#x1=2
  y1=points[(i*2)+1]#y1=2
  x3=points[(j*2)]#x3=4
  y3=points[(j*2)+1] #y3=5
  w=abs(x3-x1)
  h=abs(y3-y1)
  a=w*h #area
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
# ค่า i = 1 ค่า j = 2 เราพิจารณาหาจุด point
  x1=points[(i*2)] # x1=2
  y1=points[(i*2)+1] # y1=2
  x2=points[(j*2)] #x2=3
  y2=points[(j*2)+1] #y2=3
  d=math.sqrt((x1-x2)**2+(y1-y2)**2) # สูตรหาเส้นระหว่างจุด2จุด
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
# ค่า p1 = 5 , ค่า p2 = 6 , ค่า p3 = 1  ,ค่า p4 = 2 เราพิจารณาหาจุด point
  x5 =points[(p1*2)]
  y5 =points[(p1*2)+1]
  x6=points[(p2*2)]
  y6=points[(p2*2)+1]
  x1=points[(p3*2)]
  y1=points[(p3*2)+1]
  x2=points[(p4*2)]
  y2=points[(p4*2)+1]
  m5=(y5-y6)//(x5-x6)
  m1=(y1-y2)//(x1-x2)
  c=y5-m5*x5
  y=m5*(7/3)+c # ผมลองใช้สมการ y=m5*y+c มันไม่สามารถแก้ให้ผมได้ ผมแก้เองแล้วแทนกลับครับ ผมนั่งหาแนวทางมาทั้งวันเลยได้แค่นี้ครับ
  x=m5*(7/3)+c #y=x
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6531408221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, -6, -11, 1, -11, -16, -4, -5, 7, 12], [1, 2, -5, -4, 1, -6, -5, -7, -6, 1]]
test_middle0.5
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [61.5, 12.0, -1.5, 4-1.50, 32.5, -1.0, 7-0.05, -40.5, 10.50, -13.05]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 592, 'const': 540, 'code+const': 1132}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    xo = points[:-1:2]
    yo = points[1::2]
    a = xo[i]
    b = yo[j]
    c = xo[j]-xo[i] #cคือความกว้าง
    d = yo[j]-yo[i] #dคือความยาว
    [x,y,w,h] = [a,b,c,d]
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xo = points[:-1:2]
    yo = points[1::2]
    [x,y] = [(xo[i]+xo[j])/2,(xo[i]+xo[j])/2]
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xo = points[:-1:2]
    yo = points[1::2]
    c = xo[j]-xo[i] #cคือความกว้าง
    d = yo[j]-yo[i] #dคือความยาว
    a = float(c)*float(d)
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xo = points[:-1:2]
    yo = points[1::2]
    r = ((xo[i]-xo[j])**2) + ((yo[i]-yo[j])**2)
    d = ((float(r)))**(1/2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    xo = points[:-1:2]
    yo = points[1::2]
    m1 = (yo[p1]-yo[p2])/(xo[p1]-xo[p2])
    m2 = (yo[p3]-yo[p4])/(xo[p3]-xo[p4])
    c1 = yo[p1]-(m1*xo[p1])
    c2 = yo[p3]-(m2*xo[p3])
    a = (c1-c2)/(m2-m1)
    b = (((c1-c2)/(m2-m1))*m1)+c1
    [x,y] = [a,b]
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631007321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, -6, -11, 1, -11, -16, -4, -5, 7, 12], [21, 32, -45, -34, 31, -46, -35, -47, -36, -31]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.5
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [-12.99, -30.853, -92.072, -14.09, 2.71, -50.3344, -69.4629, -30.605, 320.579, 135.5603, 332.932]]
bytecount: {'code': 596, 'const': 428, 'code+const': 1024}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
 x,y = [points[2*i],points[(2*j)+1]]
 w,h = [points[2*j]-points[2*i],points[(2*j)+1]]
 return [x,y,w,h]
def middle(points,i,j):
 x = (points[2*i]+points[2*j])/2
 y = (points[(2*i)+1]+points[(2*j)+1])/2
 return [x,y]
def frame_area(points,i,j):
 w,h = [points[2*j]-points[2*i],points[(2*j)+1]-points[(2*i)+1]]
 return float(w*h)
def distance(points,i,j):
 w,h = [points[2*j]-points[2*i],points[(2*j)+1]-points[(2*i)+1]]
 d = ((w**2)+(h**2))**0.5
 return d
def intersection(points,p1,p2,p3,p4):
 w1,h1 = [points[2*p2]-points[2*p1],points[(2*p2)+1]-points[(2*p1)+1]]
 m1 = h1/w1
 w2,h2 = [points[2*p4]-points[2*p3],points[(2*p4)+1]-points[(2*p3)+1]]
 m2 = h2/w2
 c1 = points[(2*p1)+1] - m1*(points[2*p1])
 c2 = points[(2*p3)+1] - m2*(points[2*p3])
 u = (c2-c1)/(m1-m2)
 v = -2*(u)+c1
 return [u,v]

6631342521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.2
[5.0, 124.0, 5563.025, 42.025, 112.0, 96107.025, 204.075, 33.75.0, 428.075, 12.0]
test_distance0.2
[5.1, 67.328, 12.0875, 4.1253, 112.054, 17.0973, 67.411, 8.675, 9.292, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 714, 'const': 400, 'code+const': 1114}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x = min(points[i*2], points[j*2])
  y = max(points[i*2+1], points[j*2+1])
  w = abs(int(points[i*2])-int(points[j*2]))
  h = abs(int(points[i*2+1])-int(points[j*2+1]))
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (int(points[i*2])+int(points[j*2]))/2
  y = (int(points[i*2+1])+int(points[j*2+1]))/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs(int(points[i*2])-int(points[j*2]))
  h = abs(int(points[i*2+1])-int(points[j*2+1]))
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  w = abs(int(points[i*2])-int(points[j*2]))
  h = abs(int(points[i*2+1])-int(points[j*2+1]))
  d = math.sqrt(w*w+h*h)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  a = points[2*p1]
  b = points[2*p1+1]
  c = points[2*p2]
  d = points[2*p2+1]
  e = points[2*p3]
  f = points[2*p3+1]
  g = points[2*p4]
  h = points[2*p4+1]
  t = ((a-e)*(f-h)-(b-f)*(e-g))/((a-c)*(f-h)-(b-d)*(e-g))
  x = (a+t*(c-a))
  y = (b+t*(d-b))
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630074121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[[6.5], [1.0], [-1.5], [4.5], [3.5], [1.0], [7.0], [-4.5], [1.5], [-1.0]],
 [[1.5], [2.0], [-1.5], [-1.0], [2.5], [-1.0], [-0.5], [-0.5], [0.0], [-3.5]]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.5
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [70.8953, 16-2.8102, 51.093, 7.02.71, 2-0.044, -346.4329, 10.4805, 40.657, 13.2203, 42.934]]
bytecount: {'code': 662, 'const': 400, 'code+const': 1062}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
   x1 = points[i*2]
   y1 = points[i*2+1]
   x2 = points[j*2 ]
   y2 = points[j*2+1]
   x = min(x1,x2)
   y = max(y1,y2)
   w = abs(x2-x1)
   h = abs(y2-y1)
   return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
   x1 = points[i*2]
   y1 = points[i*2+1]
   x2 = points[j*2 ]
   y2 = points[j*2+1]
   x = [(x1+x2)/2]
   y = [(y1+y2)/2]
   return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
   x1 = points[i*2]
   y1 = points[i*2+1]
   x2 = points[j*2 ]
   y2 = points[j*2+1]
   x = min(x1,x2)
   y = max(y1,y2)
   w = abs(x2-x1)
   h = abs(y2-y1)
   a = w*h
   return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    d = math.sqrt((x1-x2)**2+(y1-y2)**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2]
    y1 = points[p1*2+1]
    x2 = points[p2*2]
    y2 = points[p2*2+1]
    x3 = points[p3*2]
    y3 = points[p3*2+1]
    x4 = points[p4*2]
    y4 = points[p4*2+1]
    m1 = (y2-y1)/(x2-x1)
    m2 = (y4-y3)/(x4-x3)
    c1 = y1-m1*x1
    c2 = y3-m2*x3
    x = (c2-c1)/(m1-m2)
    y = x
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631124021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [3.059411708155, 6704, 3.7947331192202055, 7.249827584156743, 2.47386337537059611, 6.627216610312357,
  10.252804494381037, 3.841874542459709, 5.161395160225576, 5.531726674375732, 7.224956747275377],
 [4.079215610874228, 5.059644256269408, 9.666436778875658, 3.2984845004941286, 8.836288813749809,
  13.67040599250805, 5.122499389946279, 6.8818602136341027, 7.37563556583431, 9.6332756630338371]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0
[135.0, 2614.0, 8163.025, 102.025, 712.0, 1507.025, 24.75.0, 383.075, 498.075, 712.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 822, 'const': 520, 'code+const': 1342}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  import math
  x,y,w,h = (min([points[2*i],points[(2*j)]]) ,max([points[2*i+1],points[2*j+1]]) ,(math.sqrt((points[2*i]-points[(2*j)])**2 + (points[2*i+1]-points[2*j+1])**2))*0.6 ,(math.sqrt((points[2*i]-points[(2*j)])**2 + (points[2*i+1]-points[2*j+1])**2))*0.8 )
  return [x,y,w,h]
def middle(points,i,j):
  x,y=(points[2*i]+points[(2*j)])/2 , (points[(2*i)+1]+points[(2*j)+1])/2
  return[x,y]
def frame_area(points,i,j):
  import math
  a = round(0.5*((math.sqrt((points[2*i]-points[(2*j)])**2 + (points[2*i+1]-points[2*j+1])**2))**2))
  return float(a)
def distance(points,i,j):
  import math
  d  = math.sqrt((points[2*i]-points[(2*j)])**2 + (points[2*i+1]-points[2*j+1])**2)
  return (d)
def intersection(points,p1,p2,p3,p4):
  x1,y1 = points[p1*2:(p1+1)*2]
  x2,y2 = points[p2*2:(p2+1)*2]
  x3,y3 = points[p3*2:(p3+1)*2]
  x4,y4 = points[p4*2:(p4+1)*2]
  x_intersection = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)
  x_intersection /= (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)
  y_intersection = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)
  y_intersection /= (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)
  return [x_intersection, y_intersection]

6631223521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0
[5.01, 7.0728, 112.675, 54.523, 12.04, 167.573, 7.911, 48.75, 109.6192, 12.04]
test_intersection0.5
[[-7.89, -16.81, -5.93, -7.02, -2.04, -34.43, -1.48, -4.6, -3.22, -4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 710, 'const': 400, 'code+const': 1110}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x=min(points[2*i], points[2*j])
  y=max(points[2*i+1], points[2*j+1])
  w=abs(points[2*i]-points[2*j])
  h=abs(points[2*i+1]-points[2*j+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x=(points[2*i] + points[2*j])/2
  y=(points[2*i+1] + points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x=min(points[2*i], points[2*j])
  y=max(points[2*i+1],points[2*j+1])
  w=abs(points[2*i]-points[2*j])
  h=abs(points[2*i+1]-points[2*j+1])
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi=points[2*i]
  yi=points[2*i+1]
  xj=points[2*j]
  yj=points[2*j-1]
  d=math.sqrt((xi-xj)**2 + (yi-yj)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[2*p1]
  y1 = points[2*p1+1]
  x2 = points[2*p2]
  y2 = points[2*p2+1]
  x3 = points[2*p3]
  y3 = points[2*p3+1]
  x4 = points[2*p4]
  y4 = points[2*p4+1]
  m1 = (y1-y2)/(x1-x2)
  m2 = (y3-y4)/(x3-x4)
  c1 = y1-m1*x1
  c2 = y4-m2*x4
  x = (c2-c1)/(m2-m1)
  y = ((c2*m1-c1*m2)/(m1-m2))
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6331512621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, -6, -11, 1, -11, -16, -4, -5, 7, 12], [1, 2, -5, -4, 1, -6, -5, -7, -6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 658, 'const': 520, 'code+const': 1178}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    w = (points[0::2][j])-((points[0::2][i]))
    h = (points[1::2][j])-((points[1::2][i]))
    x_i = (points[0::2][i])
    y_j = (points[1::2][j])
    x = x_i
    y = y_j
    return [x,y,w,h]
# เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x_i = points[0::2][i]
    y_i = points[1::2][i]
    x_j = points[0::2][j]
    y_j = points[1::2][j]
    x = float((x_i+x_j)/2)
    y = float((y_i+y_j)/2)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    w = (points[0::2][j])-((points[0::2][i]))
    h = (points[1::2][j])-((points[1::2][i]))
    a = (w*h)
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    d = math.sqrt(((points[0::2][i]-points[0::2][j])**2)+(points[1::2][i]-points[1::2][j])**2)
    return float(d) # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[0::2]
    y1 = points[1::2]
    x_p1  =x1[p1]
    y_p1  =y1[p1]
    x_p2  =x1[p2]
    y_p2  =y1[p2]
    x_p3  =x1[p3]
    y_p3  =y1[p3]
    x_p4  =x1[p4]
    y_p4  =y1[p4]
    m1 = (y_p2 - y_p1)/ (x_p2 - x_p1)
    m2 = (y_p4 - y_p3) / (x_p4 - x_p3)
    x = ((y_p4-y_p2) + m1*x_p2 - (m2*x_p4))/(m1-m2)
    y =  y_p2 - (m1*(x_p2 - x))
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6530394921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, -6, -11, 1, -11, -16, -4, -5, 7, 12], [1, 2, -5, -4, 1, -6, -5, -7, -6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 592, 'const': 400, 'code+const': 992}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x = points[2*i]
  y = points[2*j+1]
  w = points[2*j] - x
  h = y - points[2*i+1]
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  k = int(2*j)
  x = float(points[k] + points[2*i]) /2
  y = float(points[k+1] + points[2*i+1]) /2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x = points[2*i]
  y = points[2*j+1]
  w = points[2*j] - x
  h = y - points[2*i+1]
  a = float(w*h)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1 = points[2*i]
  x2 = points[2*j]
  y1 = points[2*i+1]
  y2 = points[2*j+1]
  d = float(((x2-x1)**2+(y2-y1)**2)**0.5)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[p1*2]
  x2 = points[p2*2]
  y1 = points[p1*2+1]
  y2 = points[p2*2+1]
  m1 = (y2-y1)/(x2-x1)
  c1 = y1-m1*x1
  x3 = points[p3*2]
  x4 = points[p4*2]
  y3 = points[p3*2+1]
  y4 = points[p4*2+1]
  m2 = (y4-y3)/(x4-x3)
  c2 = y3-m2*x3
  mt = m1-m2
  ct = c2-c1
  x = ct/mt
  y = x*m1+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630079321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, -6, -11, 1, -11, -16, -4, -5, 7, 12], [1, 2, -5, -4, 1, -6, -5, -7, -6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 684, 'const': 428, 'code+const': 1112}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x1,y1 = points[i*2],points[i*2+1]
  x2,y2 = points[j*2],points[j*2+1]
  x,y = x1,y2
  h = y2-y1
  w = x2-x1
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1,y1 = points[i*2],points[i*2+1]
  x2,y2 = points[j*2],points[j*2+1]
  x = (x2+x1)/2
  y = (y2+y1)/2
  return[x,y]
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1,y1 = points[i*2],points[i*2+1]
  x2,y2 = points[j*2],points[j*2+1]
  h = y2-y1
  w = x2-x1
  a = float(w*h)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1,y1 = points[i*2],points[i*2+1]
  x2,y2 = points[j*2],points[j*2+1]
  d = math.sqrt((x1-x2)**2+(y2-y1)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,y1 = points[p1*2],points[p1*2+1]
  x2,y2 = points[p2*2],points[p2*2+1]
  x3,y3 = points[p3*2],points[p3*2+1]
  x4,y4 = points[p4*2],points[p4*2+1]
  m1 = (y2-y1)/(x2-x1)
  a1 = m1
  b1 = -1
  c1 = m1*x1-y1
  m2 = (y4-y3)/(x4-x3)
  a2 = m2
  b2 = -1
  c2 = m2*x3-y3
  x = (b2*c1-c2*b1)/(a1*b2-a2*b1)
  y = (c1-a1*x)/b1
  return [x,y]
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631206921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, -6, -11, 1, -11, -16, -4, -5, 7, 12], [1, 2, -5, -4, 1, -6, -5, -7, -6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 584, 'const': 400, 'code+const': 984}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  x = x1
  y = y2
  w = x2-x1
  h = y2-y1
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[2*i] + points[2*j])/2
  y = (points[2*i+1] + points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  w = x2-x1
  h = y2-y1
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d =  (points[2*i]-points[2*j])**2 +  (points[2*i+1]-points[2*j+1])**2
  d = d**(1/2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
   x1 , y1 = points[2*p1], points[2*p1+1]
   x2 , y2 = points[2*p2], points[2*p2+1]
   x3 , y3 = points[2*p3], points[2*p3+1]
   x4 , y4 = points[2*p4], points[2*p4+1]
   slope1 = (y2-y1)/(x2-x1)
   slope2 =  (y4-y3)/(x4-x3)
   a = y1-slope1*x1
   b = y3-slope2*x3
   x= (b-a)/(slope1-slope2)
   y = slope1*x+a
   return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631212621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, -6, -11, 1, -11, -16, -4, -5, 7, 12], [1, 2, -5, -4, 1, -6, -5, -7, -6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 606, 'const': 400, 'code+const': 1006}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j): #1,3 /x2y2 x4y4 2,2 4,5
    x2 = points[i*2]
    y2 = points[(i*2)+1]
    x4 = points[(j*2)]
    y4 = points[((j*2)+1)]
    x = x2
    y = y4
    w = (x4-x2)
    h = (y4-y2)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j): # 0,2 / 1,1 2,2 x1,y1 x3,y3 
    x1 = points[i*2]
    y1 = points[(i*2)+1]   
    x3 = points[j*2]
    y3 = points[(j*2)+1]
    x  = (x1+x3)/2
    y  = (y1+y3)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j): #1,3 / 2,2 4,5 
    x2 = points[i*2]
    y2 = points[(i*2)+1]
    x4 = points[j*2]
    y4 = points[(j*2)+1]
    a =  (x4-x2)*(y4-y2)
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j): #1,2 / 2,2 3,3 
  x2 = points[i*2]
  y2 = points[(i*2)+1]
  x3 = points[j*2]
  y3 = points[(j*2)+1]
  d = math.sqrt((x3-x2)**2 +(y3-y2)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):  #5,6,1,2 / p1 p2 p3 p4 / 
  x1 = points[p1*2]
  y1 = points[(p1*2)+1]
  x2 = points[p2*2]
  y2 = points[(p2*2)+1]
  x3 = points[p3*2]
  y3 = points[(p3*2)+1]
  x4 = points[p4*2]
  y4 = points[(p4*2)+1]
  m1 = (y2-y1) / (x2-x1)
  m2 = (y4-y3) / (x4-x3)
  x = (m1*x1 - m2*x3 + y3-y1) / (m1-m2)
  y = m1* (x-x1) + y1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4
        # 0 0 1 1 2 2 3 3 4 4 5 5 6 6

6631218421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [15, -6, -11, -41, -11, -16, -54, -75, -67, 12], [51, 2, -5, 14, 1, -6, -4, -5, 7, 6, 12]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 702, 'const': 400, 'code+const': 1102}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = points[i*2]
  yi = points[i*2 +1]
  xj = points[j*2]
  yj = points[j*2 +1]
  Xpee = xi
  Ypee = yj
  ploy = (yj-yi)
  ploi = (xj-xi)
  p = [ploy , ploi]
  w = min(p)
  h = max(p)
  x = (Xpee)
  y = (Ypee)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[i*2]
  yi = points[i*2 +1]
  xj = points[j*2]
  yj = points[j*2 +1]
  x = (xi+xj)/2
  y = (yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = points[i*2]
  yi = points[i*2 +1]
  xj = points[j*2]
  yj = points[j*2 +1]
  Xpee = xi
  Ypee = yj
  ploy = (yj-yi)
  ploi = (xj-xi)
  p = [ploy , ploi]
  w = min(p)
  h = max(p)
  area = (w*h)
  a = (area)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  import math
  xi = points[i*2]
  yi = points[i*2 +1]
  xj = points[j*2]
  yj = points[j*2 +1]
  distance = math.sqrt((xj-xi)**2+(yj-yi)**2)
  d = float(distance)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xp1 = points[p1*2]
  yp1 = points[p1*2+1]
  xp2 = points[p2*2]
  yp2 = points[p2*2+1]
  xp3 = points[p3*2]
  yp3 = points[p3*2+1]
  xp4 = points[p4*2]
  yp4 = points[p4*2+1]
  m1 = (yp2-yp1)/(xp2-xp1)
  c1 = (yp1-m1*xp1)
  m2 = (yp4-yp3)/(xp4-xp3)
  c2 = (yp3-m2*xp3)
  x = (c2-c1)/(m1-m2)
  y = (m2*c1-m1*c2)/(m2-m1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631227021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, -6, -11, 1, -11, -16, -4, -5, 7, 12], [1, 2, -5, -4, 1, -6, -5, -7, -6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 584, 'const': 400, 'code+const': 984}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1 = points[2 * i]
    x2 = points[2 * j]
    y1 = points[2 * i + 1]
    y2 = points[2 * j + 1]
    x = x1
    y = y2
    w = x2 - x1
    h = y2 - y1
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
   x = (points[2 * i] + points[2 * j]) / 2
   y = (points[2 * i + 1] + points[2 * j + 1]) / 2
   return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
   x1 = points[2 * i]
   x2 = points[2 * j]
   y1 = points[2 * i + 1]
   y2 = points[2 * j + 1]
   w = x2 - x1
   h = y2 - y1
   a = h * w
   return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
   d = (points[2 * i] - points[2 * j]) **2 + (points[2 * i + 1] - points[2 * j + 1]) **2
   d = d ** (1 / 2)
   return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
   x1 , y1 = points[2 * p1], points[2 * p1 + 1]
   x2 , y2 = points[2 * p2], points[2 * p2 + 1]
   x3 , y3 = points[2 * p3], points[2 * p3 + 1]
   x4 , y4 = points[2 * p4], points[2 * p4 + 1]
   slope1 = (y2 - y1) / (x2 - x1)
   slope2 = (y4 - y3) / (x4 - x3)
   a = y1 - slope1 * x1
   c = y3 - slope2 * x3
   x = (c - a) / (slope1 - slope2)
   y = slope1 * x + a
   return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632042421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, -6, -11, 1, -11, -16, -4, -5, 7, 12], [1, 2, -5, -4, 1, -6, -5, -7, -6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 576, 'const': 400, 'code+const': 976}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  w = points[2*j] - points[2*i]
  h = points[2*j+1] - points[2*i+1]
  x = points[2*i]
  y = points[2*j+1]
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[2*i] + points[2*j])/2
  y = (points[2*i+1] + points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = points[2*j] - points[2*i]
  h = points[2*j+1] - points[2*i+1]
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  w = points[2*j] - points[2*i]
  h = points[2*j+1] - points[2*i+1]
  d = (w*w + h*h) ** 0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  m1 = (points[2*p2+1] - points[2*p1+1]) / (points[2*p2] - points[2*p1])
  m2 = (points[2*p4+1] - points[2*p3+1]) / (points[2*p4] - points[2*p3])
  c1 = points[2*p1+1] - (m1*points[2*p1])
  c2 = points[2*p3+1] - (m2*points[2*p3])
  x = (c2 - c1) / (m1 - m2)
  y = m1*x + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630085021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 06, 011, 1, 011, 016, 04, 05, 7, 12], [1, 2, 05, 04, 1, 06, 05, 07, 06, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.2
[5.0, 014.0, 063.025, 02.025, 012.0, 107.025, 024.075, 033.075, 048.075, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 734, 'const': 400, 'code+const': 1134}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x1=points[2*i]
    x2=points[2*j]
    y1=points[2*(i+1)-1]
    y2=points[2*(j+1)-1]
    x=min(x2,x1)
    y=max(y2,y1)
    w=abs(x2-x)
    h=abs(y-y1)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1=points[2*i]
  x2=points[2*j]
  y1=points[2*(i+1)-1]
  y2=points[2*(j+1)-1]
  x=(x1+x2)/2
  y=(y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1=points[2*i]
  x2=points[2*j]
  y1=points[2*(i+1)-1]
  y2=points[2*(j+1)-1]
  x=min(x2,x1)
  y=max(y2,y1)
  w=abs(x2-x)
  h=abs(y-y1)
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1=points[2*i]
  x2=points[2*j]
  y1=points[2*(i+1)-1]
  y2=points[2*(j+1)-1]
  x=(x2-x1)**2
  y=(y2-y1)**2
  d=math.sqrt(x+y)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1=points[2*p1]
  x2=points[2*p2]
  x3=points[2*p3]
  x4=points[2*p4]
  y1=points[2*(p1+1)-1]
  y2=points[2*(p2+1)-1]
  y3=points[2*(p3+1)-1]
  y4=points[2*(p4+1)-1]
  m1=(y2-y1)/(x2-x1)
  m2=(y4-y3)/(x4-x3)
  c1=y2-m1*x2
  c2=y3-m2*x3
  a1=-m1
  a2=-m2
  x=(c1-c2)/(a1-a2)
  y=(c1-(a1*x))
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631022721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.75
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [25, 16, 811, 71, 611, 136, 124, 25, 17, 412], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0
[25.241, 27.248, 10.12, 8.75, 64.0853, 142.9804, 17.73, 7.6611, 78.675, 69.592, 4.12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 858, 'const': 400, 'code+const': 1258}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
 x = int(min(float(points[2*i]), float(points[2*j])))
 y = int(max(float(points[2*i+1]), float(points[2*j+1])))
 w = int(abs(float(points[2*i])-float(points[(2*j)+1])))
 h = int(abs(float(points[2*i+1])-float(points[2*j+1])))
 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
 x = abs(float(points[2*i])-float(points[2*j])) / 2 + min(float(points[2*i]), float(points[2*j]))
 y = abs(float(points[2*i+1])-float(points[2*j+1])) / 2 + min(float(points[2*i+1]), float(points[2*j+1]))
 return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
 w = abs(float(points[2*i])-float(points[2*j]))
 h = abs(float(points[2*i+1])-float(points[2*j+1]))
 a = w*h
 return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
 w = abs(float(points[2*i])-float(points[2*j+1]))
 h = abs(float(points[2*i+1])-float(points[2*j+1]))
 d = math.sqrt((w**2)+(h**2))
 return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
 x1 = float(points[2*p1])
 x2 = float(points[2*p2])
 x3 = float(points[2*p3])
 x4 = float(points[2*p4])
 y1 = float(points[2*p1+1])
 y2 = float(points[2*p2+1])
 y3 = float(points[2*p3+1])
 y4 = float(points[2*p4+1])
 g1 = (y1-y2) / (x1-x2)
 g2 = (y3-y4) / (x3-x4)
 j1 = y1-(g1*x1)
 j2 = y3-(g2*x3)
 x = (j2-j1) / (g1-g2)
 y = (g1*x)+j1
 return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631537621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[94, -2, -7, 54, -2, -7, 5, -7, 5-2, 5-7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [05, 6, 11, 16, 4, 11, 16, 4, 165, 47, 412], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.3
[05.0, 214.0, 9063.725, 20.25, 12.0, 107.25, 24.75, 1233.75, 2948.275, 412.50]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 654, 'const': 400, 'code+const': 1054}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    xi = points[2 * 1]
    yi = points[2 * i + 1]
    xj = points[2 * j]
    yj = points[2 * j + 1]
    x = min(xi, xj)
    y = max(yi, yj)
    w = abs(xj - xi)
    h = abs(yj - yi)
    return [x, y, w, h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi = points[2 * i]
    yi = points[2 * i + 1]
    xj = points[2 * j]
    yj = points[2 * j + 1]
    x = (xi + xj) / 2
    y = (yi + yj) / 2
    return [x, y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    frame_data = frame(points, i, j)
    width = frame_data[2]
    height = frame_data[3]
    a = width * height
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi = points[2 * i]
    yi = points[2 * i + 1]
    xj = points[2 * j]
    yj = points[2 * j + 1]
    d = math.sqrt((xj - xi)**2 + (yj - yi)**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1, y1 = points[2 * p1], points[2 * p1 + 1]
    x2, y2 = points[2 * p2], points[2 * p2 + 1]
    x3, y3 = points[2 * p3], points[2 * p3 + 1]
    x4, y4 = points[2 * p4], points[2 * p4 + 1]
    det = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 -x4)
    x = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / det
    y = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / det
    return [x, y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632189021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[14, -2, -7, -34, -2, -7, -35, -7, -32, -7], [92, 43, 41, 51, 93, 92, 92, 3, 53, 5-3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.4
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 642, 'const': 400, 'code+const': 1042}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def middle(points,i,j):
    x1,y1=points[i*2:(i+1)*2]
    x2,y2=points[j*2:(j+1)*2]
    return [(x2+x1)/2,(y2+y1)/2]
def frame(points,i,j):
    x1,y1=points[i*2:(i+1)*2]
    x2,y2=points[j*2:(j+1)*2]
    return [min(x1,y1,x2,y2),max(x1,y1,x2,y2),abs(x2-x1),abs(y2-y1)]
def frame_area(points,i,j):
    x1,y1=points[i*2:(i+1)*2]
    x2,y2=points[j*2:(j+1)*2]
    return int(abs(x2-x1)*abs(y2-y1))
def distance(points,i,j):
    x1,y1=points[i*2:(i+1)*2]
    x2,y2=points[j*2:(j+1)*2]
    a=abs(x2-x1)
    b=abs(y2-y1)
    return math.sqrt(a**2+b**2)
def intersection(points,p1,p2,p3,p4):
    x1,y1=points[p1*2:(p1+1)*2]
    x2,y2=points[p2*2:(p2+1)*2]
    x3,y3=points[p3*2:(p3+1)*2]
    x4,y4=points[p4*2:(p4+1)*2]
    #หาความชัน
    m1=(y2-y1)/(x2-x1)
    m2=(y4-y3)/(x4-x3)
    #หาค่าคงที่สมการเส้นตรง
    c1=y1-(m1*x1)
    c2=y3-(m2*x3)
    #หา x,y
    x=(c2-c1)/(m1-m2)
    y=(((m2*c1)-(m1*c2))/(m2-m1))
    return [x,y]

6331501721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[17.859, 716.5581, 45.193, 17.1602, 02.9904, -534.143, 01.48, 4.476, 3.9422, 4.7134],
 [10.853, 7-2.5502, 41.109, 12.716, -0.9944, -56.1429, 0.4805, 40.457, 13.9403, 42.7193]]
bytecount: {'code': 684, 'const': 400, 'code+const': 1084}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    xi = points[2*i]
    yi = points[(2*i)+1]
    xj = points[2*j]
    yj = points[(2*j)+1]
    x = min(xi,xj)
    y = max(yi,yj)
    w = abs(xi-xj)
    h = abs(yi-yj)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi = points[2*i]
    yi = points[(2*i)+1]
    xj = points[2*j]
    yj = points[(2*j)+1]
    mid_x = (xi+xj)/2
    mid_y = (yi+yj)/2
    return [mid_x,mid_y]  # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi = points[2*i]
    yi = points[(2*i)+1]
    xj = points[2*j]
    yj = points[(2*j)+1]
    x = min(xi,xj)
    y = max(yi,yj)
    w = abs(xi-xj)
    h = abs(yi-yj)
    a = w * h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi = points[2*i]
    yi = points[(2*i)+1]
    xj = points[2*j]
    yj = points[(2*j)+1]
    x = min(xi,xj)
    y = max(yi,yj)
    w = abs(xi-xj)
    h = abs(yi-yj)
    d = (((xi-xj)**2)+((yi-yj)**2))**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    xp1 = points[2*p1]
    yp1 = points[2*p1+1]
    xp2 = points[2*p2]
    yp2 = points[(2*p2)+1]
    xp3 = points[2*p3]
    yp3 = points[(2*p3)+1]
    xp4 = points[2*p4]
    yp4 = points[2*p4+1]
    slope_p1p2 = (yp2-yp1)/(xp2-xp1)
    slope_p3p4 = (yp4-yp3)/(xp4-xp3)
    c1 = yp1-(slope_p1p2*xp1)
    c2 = yp3-(slope_p3p4*xp3)
    x = c1/(slope_p3p4-slope_p1p2)
    y = x
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6530377221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 920, 'const': 400, 'code+const': 1320}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x = abs(points[2*i]-points[2*j])
    y = abs(points[2*i+1]-points[2*j+1])
    return [min(points[2*i], points[2*j]), max(points[2*i+1], points[2*j+1]), x, y]
def middle(points,i,j):
    x = abs(points[2*i]+points[2*j])/2
    y = abs(points[2*i+1]+points[2*j+1])/2
    return [x, y]
def frame_area(points,i,j):
    x = frame(points,i,j)[2]
    y = frame(points,i,j)[3]
    return x*y
def distance(points,i,j):
    x = frame(points,i,j)[2]
    y = frame(points,i,j)[3]
    return (x**2+y**2)**0.5
def intersection(points,p1,p2,p3,p4):
    px = ((points[p1*2]*points[p2*2+1]-points[p1*2+1]*points[p2*2])*(points[p3*2]-points[p4*2])-(points[p1*2]-points[p2*2])*(points[p3*2]*points[p4*2+1]-points[p3*2+1]*points[p4*2]))/           ((points[p1*2]-points[p2*2])*(points[p3*2+1]-points[p4*2+1])-(points[p1*2+1]-points[p2*2+1])*(points[p3*2]-points[p4*2]))
    py = ((points[p1*2]*points[p2*2+1]-points[p1*2+1]*points[p2*2])*(points[p3*2+1]-points[p4*2+1])-(points[p1*2+1]-points[p2*2+1])*(points[p3*2]*points[p4*2+1]-points[p3*2+1]*points[p4*2]))/           ((points[p1*2]-points[p2*2])*(points[p3*2+1]-points[p4*2+1])-(points[p1*2+1]-points[p2*2+1])*(points[p3*2]-points[p4*2]))
    return [px, py]

6531506021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0TypeError('cannot unpack non-iterable NoneType object')
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 504, 'const': 416, 'code+const': 920}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
from math import sqrt
def frame(points,i,j):
    x1, y1 = points[i*2], points[i*2+1]
    x2, y2 = points[j*2], points[j*2+1]
    x = min(x1, x2)
    y = max(y1, y2)
    w = abs(x2 - x1)
    h = abs(y2 - y1)
    return [x, y, w, h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x = (points[i*2] + points[j*2]) / 2.0
    y = (points[i*2+1] + points[j*2+1]) / 2.0
    return [x, y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    _, _, w, h = frame(points,i,j)
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1, y1 = points[i*2], points[i*2+1]
    x2, y2 = points[j*2], points[j*2+1]
    d = sqrt((x2 - x1)**2 + (y2 - y1)**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1, y1 = points[p1*2], points[p1*2+1]
    x2, y2 = points[p2*2], points[p2*2+1]
    x3, y3 = points[p3*2], points[p3*2+1]
    x4, y4 = points[p4*2], points[p4*2+1]

6630010021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 598, 'const': 400, 'code+const': 998}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x = min(points[2*i],points[2*j])
  y = max(points[2*i+1],points[2*j+1])
  w = abs(points[2*i]-points[2*j])
  h = abs(points[2*i+1]-points[2*j+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = abs(points[2*i]+points[2*j])/2
  y = abs(points[2*i+1]+points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  l = frame(points,i,j)
  a = l[2]*l[3]
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  import math
  a1 = points[2*i]
  b1 = points[2*i+1]
  a2 = points[2*j]
  b2 = points[2*j+1]
  d = math.sqrt((a1-a2)**2 + (b1-b2)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  a1 = points[2*p1]
  b1 = points[2*p1+1]
  a2 = points[2*p2]
  b2 = points[2*p2+1]
  a3 = points[2*p3]
  b3 = points[2*p3+1]
  a4 = points[2*p4]
  b4 = points[2*p4+1]
  m1 = (b2-b1)/(a2-a1)
  c1 = b1-m1*a1
  m2 = (b4-b3)/(a4-a3) #p3,p4
  c2 = b3-m2*a3 # y = m2*x3 + c2
  x = (c2-c1)/(m1-m2)
  y = m1*x + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630014521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[7.89, 16.81, -05.1793, 7.6102, 12.1704, -1134.95, -43.0, -12.7548, 4.96, 3.622, 4.934],
 [0.6153, -2.8302, 1.09, 2.671, 5-0.1744, -56.295, 0.05, -60.757, -2.1, 93.603, -2.193]]
bytecount: {'code': 558, 'const': 400, 'code+const': 958}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def middle(points,i,j):
    xi = points[i*2]
    yi = points[(i*2)+1]
    xj = points[j*2]
    yj = points[(j*2)+1]
    x = (xi + xj)/2
    y = (yi + yj)/2
    return [x,y]
def frame(points,i,j):
    xi = points[i*2]
    yi = points[(i*2)+1]
    xj = points[j*2]
    yj = points[(j*2)+1]
    x = min([xi,xj])
    y = max([yi,yj])
    h = abs(yi-yj)
    w = abs(xi-xj)
    return [x,y,w,h]
def frame_area(points,i,j):
    a = frame(points,i,j)
    area = float(a[2]*a[3])
    return area
def distance(points,i,j):
    b = frame(points,i,j)
    d = float(math.sqrt(b[2]**2+b[3]**2))
    return d
def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2] ; y1 = points[(p1*2)+1]
    x2 = points[p2*2] ; y2 = points[(p2*2)+1]
    x3 = points[p3*2] ; y3 = points[(p3*2)+1]
    x4 = points[p4*2] ; y4 = points[(p4*2)+1]
#หาความชั้นของเส้นตรงแต่ละเส้น โดยให้ตัวแปร m เป็นตัวแทนความชั้นของแต่ละเส้น
    m1 = (y2 - y1)/(x2 - x1)
    m2 = (y4 - y3)/(y4 - y3)
#หาจุดตัดแกน y ให้ออกมาอยู่ในรูปของตัวแปร c ใช้จุดใดจุดหนึ่งของเส้นตรงเพื่อหาก็ได้
    c1 = y1 - m1*x1
    c2 = y3 - m2*x3
#สมการเส้นตรงที่ 1 ; y1 = m1*x1 + c1
#สมการเส้นตรงที่ 2 ; y3 = m2*x3 + c2
#หาจุด x โดยการให้ค่า y เท่ากันทั้ง 2 สมการ จากนั้นจึงแก้สมการหาค่า x
    x = -(c1 - c2)/(m1 - m2)
    y = m1*x + c1
    return [x,y]

6630044321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 782, 'const': 520, 'code+const': 1302}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  a=points[2*i:2*i+2:1]
  b=points[2*j:2*j+2:1]
  x=min(a[0],b[0])
  y=max(a[1],b[1])
  w=abs(a[0]-b[0])
  h=abs(a[1]-b[1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  a=points[2*i:2*i+2:1]
  b=points[2*j:2*j+2:1]
  x=abs((a[0]+b[0])/2)
  y=abs((a[1]+b[1])/2)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w=points[2*i:2*i+2:1]
  h=points[2*j:2*j+2:1]
  x=abs(w[0]-h[0])
  y=abs(w[1]-h[1])
  a=x*y
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  a=points[2*i:2*i+2:1]
  b=points[2*j:2*j+2:1]
  w=abs(a[0]-b[0])
  h=abs(a[1]-b[1])
  d=math.sqrt(w*w+h*h)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  a=points[2*p1:2*p1+2:1]
  b=points[2*p2:2*p2+2:1]
  c=points[2*p3:2*p3+2:1]
  d=points[2*p4:2*p4+2:1]
  m1=(b[1]-a[1])/(b[0]-a[0])
  m2=(d[1]-c[1])/(d[0]-c[0])
  x=(m1*a[0]-m2*c[0]+c[1]-a[1])/(m1-m2)
  y=m1*x-m1*a[0]+a[1]
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630049521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[6.5.0, 61.0, 1-1.05, 14.05, 113.05, 16.0, 47.0, 5-4.05, 71.05, -12.0],
 [1.05, 2.0, -1.5, -1.0, 42.05, -1.0, 6-0.05, 5.-0, 7.05, 60.0, 1-3.05]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 678, 'const': 416, 'code+const': 1094}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    return [min(points[2*i],points[2*j]),max(points[2*i+1],points[2*j+1]),int(abs(points[2*i]-points[2*j])),int(abs(points[2*i+1]-points[2*j+1]))]
def middle(points,i,j):
    return [float(abs(points[2*i]-points[2*j])),float(abs(points[2*i+1]-points[2*j+1]))]
def frame_area(points,i,j):
    return (float(abs(points[2*i]-points[2*j]))*float(abs(points[2*i+1]-points[2*j+1])))
def distance(points,i,j):
    return (float(abs(points[2*i]-points[2*j]))**2 + float(abs(points[2*i+1]-points[2*j+1]))**2)**.5
def intersection(points,p1,p2,p3,p4):
    # finding intersection points(ITSP) using determinants
    def ITSPbyDet(x1,y1,x2,y2,x3,y3,x4,y4):
        ITSPx= ((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
        ITSPy= ((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
        return [ITSPx,ITSPy]
    return ITSPbyDet(points[2*p1],points[2*p1+1],points[2*p2],points[2*p2+1],points[2*p3],points[2*p3+1],points[2*p4],points[2*p4+1])

6630062621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0
[35.16, 57.3928, 512.875, 84.532, 812.064, 617.5873, 67.11, 8.75, 109.926, 132.65, 5.104]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 630, 'const': 344, 'code+const': 974}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x = min(points[i+i],points[j+j])
  y = max(points[i+i+1],points[j+j+1])
  w = abs(points[i+i]-points[j+j])
  h = abs(points[i+i+1]-points[j+j+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[i+i]+points[j+j])/2
  y = (points[i+i+1]+points[j+j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs(points[i+i]-points[j+j])
  h = abs(points[i+i+1]-points[j+j+1])
  a = w * h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d = math.sqrt((points[i]-points[j])**2 + (points[j+j+1]-points[i+i+1])**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
 m1 = (points[p2+p2+1]-points[p1+p1+1])/(points[p2+p2]-points[p1+p1])
 m2 = (points[p4+p4+1]-points[p3+p3+1])/(points[p4+p4]-points[p3+p3])
 c1 = points[p2+p2+1] + (m1*points[p2+p2])*(-1)
 c2 = points[p4+p4+1] + (m2*points[p4+p4])*(-1)
 x = (c1-c2)/(m2-m1)
 y = m1*x + c1
 return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630071221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[-7.89, -16.81, -5.93, -7.02, -2.04, -34.43, -1.48, -4.6, -3.22, -4.34],
 [-180.753, -42.802, -31.5809, 32.8871, 3-0.144, -6.29, 0.505, 20.6157, -13.063, 2.3, 93.65]]
bytecount: {'code': 646, 'const': 400, 'code+const': 1046}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x2 = points[j * 2]
    x1 = points[i * 2]
    y2 = points[j * 2 + 1]
    y1 = points[i * 2 + 1]
    w = abs(x2 - x1)
    h = abs(y2 - y1)
    x = min(x2, x1)
    y = max(y2, y1)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x2 = points[j * 2]
    x1 = points[i * 2]
    y2 = points[j * 2 + 1]
    y1 = points[i * 2 + 1]
    x = (x2 + x1) / 2
    y = (y2 + y1) / 2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x2 = points[j * 2]
    x1 = points[i * 2]
    y2 = points[j * 2 + 1]
    y1 = points[i * 2 + 1]
    w = abs(x2 - x1)
    h = abs(y2 - y1)
    a = w * h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x2 = points[j * 2]
    x1 = points[i * 2]
    y2 = points[j * 2 + 1]
    y1 = points[i * 2 + 1]
    d = math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x4 = points[p4 * 2]
    x3 = points[p3 * 2]
    x2 = points[p2 * 2]
    x1 = points[p1 * 2]
    y4 = points[p4 * 2 + 1]
    y3 = points[p3 * 2 + 1]
    y2 = points[p2 * 2 + 1]
    y1 = points[p1 * 2 + 1]
    m1 = (y2 - y1) / (x2 - x1)
    m2 = (y4 - y3) / (x4 - x3)
    c1 = y1 - m1 * x1
    c2 = y3 - m2 * x3
    x = (c1 - c2) / (m1 - m2)
    y = m2 * x + c2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630073521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 584, 'const': 344, 'code+const': 928}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1 = points[2*i]
    y1 = points[2*i+1]
    x2 = points[2*j]
    y2 = points[2*j+1]
    x = min(x1,x2)
    y = max(y1,y2)
    w = abs(x1-x2)
    h = abs(y1-y2)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x1 = points[2*i]
    y1 = points[2*i+1]
    x2 = points[2*j]
    y2 = points[2*j+1]
    x = abs((x1+x2)/2)
    y = abs((y1+y2)/2)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x, y, w, h = frame(points,i,j)
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1 = points[2*i]
    y1 = points[2*i+1]
    x2 = points[2*j]
    y2 = points[2*j+1]
    d = ((x1-x2)**2+(y1-y2)**2)**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[2*p1]
    y1 = points[2*p1+1]
    x2 = points[2*p2]
    y2 = points[2*p2+1]
    x3 = points[2*p3]
    y3 = points[2*p3+1]
    x4 = points[2*p4]
    y4 = points[2*p4+1]
    m1 = (y2-y1)/(x2-x1)
    c1 = y1-m1*x1
    m2 = (y4-y3)/(x4-x3)
    c2 = y3-m2*x3
    x = (c2-c1)/(m1-m2)
    y = m1*x + c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630087321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[07.5389, -216.0281, 15.093, 2.71.02, -02.404, -634.2943, 01.0548, 04.576, 13.0322, 24.934],
 [70.8953, 16-2.8102, 51.093, 7.02.71, 2-0.044, -346.4329, 10.4805, 40.657, 13.2203, 42.934]]
bytecount: {'code': 860, 'const': 588, 'code+const': 1448}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points, i, j):
  pointx = points[0::2]
  pointy = points[1::2]
  x = min(pointx[i], pointx[j])
  y = max(pointy[i], pointy[j])
  w = abs(pointx[i] - pointx[j])
  h = abs(pointy[i] - pointy[j])
  return [
      x, y, w, h
  ]  # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points, i, j):
  pointx = points[0::2]
  pointy = points[1::2]
  #x = abs(float(pointx[i]-pointx[j]))
  #y = abs(float(pointy[i]-pointy[j]))
  x = float((pointx[i] + pointx[j]) / 2)
  y = float((pointy[i] + pointy[j]) / 2)
  return [x, y]  # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points, i, j):
  pointx = points[0::2]
  pointy = points[1::2]
  w = abs(pointx[i] - pointx[j])
  h = abs(pointy[i] - pointy[j])
  a = w * h
  return float(a)  # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points, i, j):
  pointx = points[0::2]
  pointy = points[1::2]
  d = math.dist([pointx[i], pointy[i]], [pointx[j], pointy[j]])
  return d  # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points, p1, p2, p3, p4):
  pointx = points[0::2]
  pointy = points[1::2]
  a = [pointx[p1], pointy[p1]]
  b = [pointx[p2], pointy[p2]]
  c = [pointx[p3], pointy[p3]]
  d = [pointx[p4], pointy[p4]]
  t = ((a[0] - c[0]) * (c[1] - d[1]) - (a[1] - c[1]) *
       (c[0] - d[0])) / ((a[0] - b[0]) * (c[1] - d[1]) - (a[1] - b[1]) *
                         (c[0] - d[0]))
  u = ((a[0] - c[0]) * (a[1] - b[1]) - (a[1] - c[1]) *
       (a[0] - b[0])) / ((a[0] - b[0]) * (c[1] - d[1]) - (a[1] - b[1]) *
                         (c[0] - d[0]))
  x = a[1] + t * (b[1] - a[1])
  y = a[0] + t * (b[0] - a[0])
  #return a[1] + t * (b[1] - a[1]), a[0] + t * (b[0] - a[0])
  return [x,
          y]  # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4
def det(a, b):
  return a[0] * b[1] - a[1] * b[0]

6630091821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0
[75.071, 97.928, 162.2675, 04.7153, 162.9704, 2317.373, 67.3611, 68.3675, 109.6192, 162.9704]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 702, 'const': 372, 'code+const': 1074}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x = int(min(points[i*2],points[j*2]))
    y = int(max(points[(i*2)+1],points[(j*2)+1]))
    w = int(max(points[i*2],points[j*2]) - x)
    h = int(y - min(points[(i*2)+1],points[(j*2)+1]))
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x = float((points[i*2]+points[j*2])/2)
    y = float((points[(i*2)+1]+points[(j*2)+1])/2)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    a = float((max(points[i*2],points[j*2]) - min(points[i*2],points[j*2]))*(max(points[(i*2)+1],points[(j*2)+1]) - min(points[(i*2)+1],points[(j*2)+1])))
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    d = math.sqrt(abs(points[i*2]-points[j*2])**2+abs(points[i*2]-points[j*2])**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2]
    y1 = points[(p1*2)+1]
    x2 = points[p2*2]
    y2 = points[(p2*2)+1]
    x3 = points[p3*2]
    y3 = points[(p3*2)+1]
    x4 = points[p4*2]
    y4 = points[(p4*2)+1]
    a1 = (y1-y2)/(x1-x2)
    a2 = (y3-y4)/(x3-x4)
    b1 = y1-x1*a1
    b2 = y3-x3*a2
    x = (b2-b1)/(a1-a2)
    y = a1*x+b1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4จุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630095321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, 61, 51, 3, 82, 72, 103, 93, -3],
 [5, -6, -11, 1, -11, -16, -4, -5, 7, 12], [1, 2, -5, -4, 1, -6, -5, -7, -6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 702, 'const': 400, 'code+const': 1102}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    xa = points[2*i] ; ya = points[2*i+1]
    xb = points[2*j] ; yb = points[2*j+1]
    x = xa
    y = ya+abs(yb-ya)
    w = xb-xa
    h = yb-ya
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xa = points[2*i] ; ya = points[2*i+1]
    xb = points[2*j] ; yb = points[2*j+1]
    x = float((xa+xb)/2)
    y = float((ya+yb)/2)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xa = points[2*i] ; ya = points[2*i+1]
    xb = points[2*j] ; yb = points[2*j+1]
    w = abs(xa-xb)
    h = abs(ya-yb)
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xa = points[2*i] ; ya = points[2*i+1]
    xb = points[2*j] ; yb = points[2*j+1]
    x = abs(xa-xb)
    y = abs(ya-yb)
    d = float(math.sqrt(x**2+y**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    xa = points[2*p1] ; ya = points[2*p1+1]
    xb = points[2*p2] ; yb = points[2*p2+1]
    xc = points[2*p3] ; yc = points[2*p3+1]
    xd = points[2*p4] ; yd = points[2*p4+1]
    m1 = (ya-yb)/(xa-xb)
    m2 = (yc-yd)/(xc-xd)
    c1 = (yb*xa-ya*xb)/(xa-xb)
    c2 = (yd*xc-yc*xd)/(xc-xd)
    x = (c2-c1)/(m1-m2)
    y = (m1*c2-m2*c1)/(m1-m2)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630098221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[-37.3189, 416.816, 85.493, 7.02, -12.404, -34.16, 5.5743, 31.468, 4.796, 3.0622, 4.8734],
 [30.753, -2.02, 1.609, 02.371, -10.34, 0.4, 1-6.7129, 10.05, -10.0857, 143.4403, -12.8693]]
bytecount: {'code': 710, 'const': 400, 'code+const': 1110}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = points[ i * 2 ]
  yi = points[ i * 2 + 1 ]
  xj = points[ j * 2 ]
  yj = points[ j * 2 + 1 ]
  x = min(xi,xj)
  y = max(yi,yj)
  w = abs(xi-xj)
  h = abs(yi-yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[ i * 2 ]
  yi = points[ i * 2 + 1 ]
  xj = points[ j * 2 ]
  yj = points[ j * 2 + 1 ]
  x = (xi+xj)/2
  y = (yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = points[ i * 2 ]
  yi = points[ i * 2 + 1 ]
  xj = points[ j * 2 ]
  yj = points[ j * 2 + 1 ]
  a = abs(xi-xj)*abs(yi-yj)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[ i * 2 ]
  yi = points[ i * 2 + 1 ]
  xj = points[ j * 2 ]
  yj = points[ j * 2 + 1 ]
  import math
  d = math.sqrt(((xi-xj)**2) + ((yi-yj)**2))
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xi = points[ p1 * 2 ]
  yi = points[ p1 * 2 + 1 ]
  xj = points[ p2 * 2 ]
  yj = points[ p2 * 2 + 1 ]
  xk = points[ p3 * 2 ]
  yk = points[ p3 * 2 + 1 ]
  xl = points[ p4 * 2 ]
  yl = points[ p4 * 2 + 1 ]
  x = ((xi*yj-yi*xj)*(xk-xl)-(xi-xj)*(xk*xl-yk*xl))/((xi-xj)*(yk-yl)-(yi-yj)*(xk-xl))
  y = ((xi*yj-yi*xj)*(yk-yl)-(yi-yj)*(xk*xl-yk*xl))/((xi-xj)*(yk-yl)-(yi-yj)*(xk-xl))
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631108021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [15, 26, 511, 1, 11, 16, 4, 5, 67, 12], [51, 62, 115, 4, 11, 16, 5, 7, 76, 12]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 736, 'const': 448, 'code+const': 1184}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = xi
  y = yj
  Q = ((x-xj)**2 + (y-yj)**2)**0.5
  Z = ((x-xi)**2 + (y-yi)**2)**0.5
  A = [Q,Z]
  w = int(min(A))
  h = int(max(A))
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x  = (xi+xj)/2
  y  = (yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = xi
  y = yj
  Q = ((x-xj)**2 + (y-yj)**2)**0.5
  Z = ((x-xi)**2 + (y-yi)**2)**0.5
  a = (Q*Z)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  d  = ((xi-xj)**2 + (yi-yj)**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x_p1 = points[2*p1]
  x_p2 = points[2*p2]
  x_p3 = points[2*p3]
  x_p4 = points[2*p4]
  y_p1 = points[2*p1+1]
  y_p2 = points[2*p2+1]
  y_p3 = points[2*p3+1]
  y_p4 = points[2*p4+1]
  m1 = (y_p2 - y_p1)/(x_p2 - x_p1)
  m2 = (y_p4 - y_p3)/(x_p4 - x_p3)
  c_line1 = y_p1 - m1*x_p1
  c_line2 = y_p3 - m2*x_p3
  x = (c_line2 - c_line1)/(m1-m2)
  y = (m2*c_line1 - m1*c_line2)/(m2-m1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631134321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0TypeError("type list doesn't define __round__ method")
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 652, 'const': 344, 'code+const': 996}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  xi,yi = points[i*2:(i+1)*2]
  xj,yj = points[j*2:(j+1)*2]
  x = min(xi,xj)
  y = max(yi,yj)
  w = abs(xi-xj)
  h = abs(yi-yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi,yi=points[i*2:(i+1)*2]
  xj,yj=points[j*2:(j+1)*2]
  x = (xi+xj)/2
  y = (yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x,y,w,h = frame(points,i,j)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi,yi=points[i*2:(i+1)*2]
  xj,yj=points[j*2:(j+1)*2]
  d = [math.sqrt((xi-xj)**2 + (yi-yj)**2)]
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,y1=points[p1*2:(p1+1)*2]
  x2,y2=points[p2*2:(p2+1)*2]
  x3,y3=points[p3*2:(p3+1)*2]
  x4,y4=points[p4*2:(p4+1)*2]
  a = ((x1*y2)-(y1*x2))*(x3-x4) - (x1-x2)*((x3*y4)-(y3*x4))
  b = ((x1*y2)-(y1*x2))*(y3-y4) - (y1-y2)*((x3*y4)-(y3*x4))
  c = (x1-x2)*(y3-y4)-(y1-y2)*(x3-x4)
  x = a/c
  y = b/c
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631139521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0
[75.071, 97.928, 162.2675, 04.7153, 162.9704, 2317.373, 67.3611, 68.3675, 109.6192, 162.9704]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 750, 'const': 400, 'code+const': 1150}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    xi, yi = points[i*2], points[i*2+1]
    xj, yj = points[j*2], points[j*2+1]
    x = int(min(xi,xj)) #ค่าแนวนอนของเลขซ้ายบน
    y = int(max(yi,yj)) #ค่าแนวตั้งของเลขซ้ายบน
    w = int(abs(max(xi,xj)-x))
    h = int(abs(min(yi,yj)-y))
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi, yi = points[i*2], points[i*2+1]
    xj, yj = points[j*2], points[j*2+1]
    x = float((xi+xj)/2)
    y = float((yi+yj)/2)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi, yi = points[i*2], points[i*2+1]
    xj, yj = points[j*2], points[j*2+1]
    a = float(max(xi,xj)-min(xi,xj)) #ขนาดแนวนอนของเฟรม
    b = float(max(yi,yj)-min(yi,yj)) #ขนาดแนวตั้งของเฟรม
    area = a*b
    return float(area) # เมื่อ area เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi, yi = points[i*2], points[i*2+1]
    xj, yj = points[j*2], points[j*2+1]
    a = abs(pow((xi-xj),2))  #pow=(**)
    b = abs(pow((xi-xj),2))
    d = math.sqrt(a+b)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1, y1 = points[p1*2], points[p1*2+1]
    x2, y2 = points[p2*2], points[p2*2+1]
    x3, y3 = points[p3*2], points[p3*2+1]
    x4, y4 = points[p4*2], points[p4*2+1]
    slo1 = (y1-y2)/(x1-x2)
    slo2 = (y3-y4)/(x3-x4)
    con1 = y1-x1*slo1
    con2 = y3-x3*slo2
    x = (con2-con1)/(slo1-slo2)
    y = slo1*x+con1
    return [x, y]# เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631213221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[3.0, 36.5, 01.0, 0-1.5, 64.05, 23.5, 31.0, -37.0, -24.5, 1.5, -51.0],
 [1.5, 2.0, -01.5, -31.0, 32.05, 0-1.0, -20.5, 3-0.5, -2.0, 4.0, 0-3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 566, 'const': 344, 'code+const': 910}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1=points[i*2]
  y1=points[j*2+1]
  x2=points[j*2]
  y2=points[i*2+1]
  x,y,w,h=min(x1,x2),max(y1,y2),abs(x1-x2),abs(y1-y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x,y=(points[i*2]+points[j*2+1])/2,(points[j*2]+points[i*2+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x,y,w,h=frame(points,i,j)
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1=points[i*2]
  y1=points[j*2+1]
  x2=points[j*2]
  y2=points[i*2+1]
  d=((x1-x2)**2+(y1-y2)**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  p1_x1=points[p1*2]
  p1_y1=points[p1*2+1]
  p1_x2=points[p2*2]
  p1_y2=points[p2*2+1]
  p2_x1=points[p3*2]
  p2_y1=points[p3*2+1]
  p2_x2=points[p4*2]
  p2_y2=points[p4*2+1]
  m=(p1_y2-p1_y1)/(p1_x2-p1_x1)
  a=p1_y1-m*p1_x1
  M=(p2_y2-p2_y1)/(p2_x2-p2_x1)
  A=p2_y1-M*p2_x1
  x=(A-a)/(m-M)
  y=m*x+a
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631216121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[3.0, 36.5, 01.0, 0-1.5, 64.05, 23.5, 31.0, -37.0, -24.5, 1.5, -51.0],
 [1.5, 2.0, -01.5, -31.0, 32.05, 0-1.0, -20.5, 3-0.5, -2.0, 4.0, 0-3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 566, 'const': 344, 'code+const': 910}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1 = points[i*2]
  y1 = points[j*2+1]
  x2 = points[j*2]
  y2 = points[i*2+1]
  x,y,w,h = min(x1,x2),max(y1,y2),abs(x1-x2),abs(y1-y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x,y = (points[i*2]+points[j*2+1])/2,(points[j*2]+points[i*2+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x,y,w,h = frame(points,i,j)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1 = points[i*2]
  y1 = points[j*2+1]
  x2 = points[j*2]
  y2 = points[i*2+1]
  d = ((x1-x2)**2+(y1-y2)**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  p1_x1 = points[p1*2]
  p1_y1 = points[p1*2+1]
  p1_x2 = points[p2*2]
  p1_y2 = points[p2*2+1]
  p2_x1 = points[p3*2]
  p2_y1 = points[p3*2+1]
  p2_x2 = points[p4*2]
  p2_y2 = points[p4*2+1]
  m1 = (p1_y2-p1_y1)/(p1_x2-p1_x1)
  b1 = p1_y1-m1*p1_x1
  m2 = (p2_y2-p2_y1)/(p2_x2-p2_x1)
  b2 = p2_y1-m2*p2_x1
  x = (b2-b1)/(m1-m2)
  y = m1*x+b1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631222921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[47.894, 916.581, 65.693, 47.802, -02.9204, -1134.5743, -1.348, 4.65, 3.4422, 4.348],
 [10.537, 0-2.052, 1.0.9, 12.6471, -10.644, -16.7129, -10.2705, 0.1457, 113.063, 12.6793]]
bytecount: {'code': 680, 'const': 424, 'code+const': 1104}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  points_x=[points[i*2],points[j*2]]
  points_y=[points[(i*2)+1],points[(j*2)+1]]
  max_x=max(points_x)
  min_x=min(points_x)
  max_y=max(points_y)
  min_y=min(points_y)
  x=min_x
  y=max_y
  w=abs(max_x-min_x)
  h=abs(max_y-min_y)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x=(points[i*2]+points[(j*2)])/2
  y=(points[(i*2)+1]+points[(j*2)+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  list=frame(points,i,j)
  a=abs(list[2]*list[3])
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  points_x=[points[i*2],points[j*2]]
  points_y=[points[(i*2)+1],points[(j*2)+1]]
  d=abs(((points_x[0]-points_x[1])**2+(points_y[0]-points_y[1])**2)**0.5)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1=points[p1*2]
  y1=points[(p1*2)+1]
  x2=points[p2*2]
  y2=points[(p2*2)+1]
  x3=points[p3*2]
  y3=points[(p3*2)+1]
  x4=points[p4*2]
  y4=points[(p4*2)+1]
  x=((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*y4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
  y=((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*y4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631228721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.0
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [15, 26, 511, 1, 11, 16, 4, 5, 67, 12], [51, 62, 115, 4, 11, 16, 5, 7, 76, 12]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 740, 'const': 448, 'code+const': 1188}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = xi
  y = yj
  l = (((x-xi)**2+(y-yi)**2))**0.5
  s = (((x-xj)**2+(y-yj)**2))**0.5
  b = [l,s]
  h = int(max(b))
  w = int(min(b))
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = (xi+xj)/2
  y = (yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = xi
  y = yj
  l = (((x-xi)**2+(y-yi)**2))**0.5
  s = (((x-xj)**2+(y-yj)**2))**0.5
  a = l*s
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  d = abs((((xi-xj)**2+(yi-yj)**2))**0.5)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xi = points[2*p1]
  yi = points[2*p1+1]
  xj = points[2*p2]
  yj = points[2*p2+1]
  xk = points[2*p3]
  yk = points[2*p3+1]
  xl = points[2*p4]
  yl = points[2*p4+1]
  m1 = ((yj-yi)/(xj-xi))
  m2 = ((yl-yk)/(xl-xk))
  c1 = yj-(m1*xj)
  c2 = yl-(m2*xl)
  x = (c2-c1)/(m1-m2)
  y = ((m2*c1)-(m1*c2))/(m2-m1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631314021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0
[5.1, 7.2.458, 312.075, 4.1253, 12.204, 3.61, 47.873, 37.161, 38.4675, 39.7492, 312.6104]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 704, 'const': 400, 'code+const': 1104}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi,yi = points[2*i],points[(2*i)+1]
  xj,yj = points[2*j],points[(2*j)+1]
  w = abs(xi-xj)
  h = abs(yi-yj)
  x = min(xi,xj)
  y = max(yi,yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x=(points[2*i]+points[2*j])/2
  y=(points[(2*i)+1]+points[(2*j)+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi,yi = points[2*i],points[(2*i)+1]
  xj,yj = points[2*j],points[(2*j)+1]
  a = abs(xi-xj) * abs(yi-yj)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi,yi = points[2*i],points[(2*i)+1]
  xj,yj = points[2*j],points[(2*j)+1]
  d = (abs(xi-xj) + abs(yi-yj))**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,y1 = points[2*p1],points[(2*p1)+1]
  x2,y2 = points[2*p2],points[(2*p2)+1]
  x3,y3 = points[2*p3],points[(2*p3)+1]
  x4,y4 = points[2*p4],points[(2*p4)+1]
  x = ((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4)) / ((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
  y = ((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4)) / ((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631316221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[6.5, 31.0, 5-1.5, 4.5, 53.5, 81.0, 7.0, -4.5, 31.5, 6-1.0],
 [1.5, 2.0, 2-1.5, 2-1.0, 2.5, 3-1.0, 2-0.5, 3-0.5, 30.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 790, 'const': 520, 'code+const': 1310}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  num1 = i * 2
  num2 = j * 2
  position1 = [points[num1], points[num1 + 1]]
  position2 = [points[num2], points[num2 + 1]]
  min_n = min(position1[0], position2[0])
  max_n = max(position1[1], position2[1])
  x = min_n
  y = max_n
  w = abs(position1[0] - position2[0])
  h = abs(position1[1] - position2[1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  num1 = i * 2
  num2 = j * 2
  position1 = [points[num1], points[num1 + 1]]
  position2 = [points[num2], points[num2 + 1]]
  x = (abs(position1[0]) + abs(position2[0]))/2
  y = (abs(position1[1]) + abs(position2[1]))/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  num1 = i * 2
  num2 = j * 2
  position1 = [points[num1], points[num1 + 1]]
  position2 = [points[num2], points[num2 + 1]]
  w = abs(position1[0] - position2[0])
  h = abs(position1[1] - position2[1])
  a = w*h
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  num1 = i * 2
  num2 = j * 2
  position1 = [points[num1], points[num1 + 1]]
  position2 = [points[num2], points[num2 + 1]]
  d = math.sqrt((position2[1] - position1[1])**2 + (position2[0] - position1[0])**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  num1 = p1 * 2
  num2 = p2 * 2
  num3 = p3 * 2
  num4 = p4 * 2
  position1 = [points[num1], points[num1 + 1]]
  position2 = [points[num2], points[num2 + 1]]
  x1 = position1[0]
  y1 = position1[1]
  m1 = (position2[1] - y1) /(position2[0] - x1)
  position3 = [points[num3], points[num3 + 1]]
  position4 = [points[num4], points[num4 + 1]]
  x2 = position3[0]
  y2 = position3[1]
  m2 = (position4[1] - y2) /(position4[0] - x2)
  x = ((m2*x2) - y2 - (m1*x1) + y1) / (m2-m1)
  y = (m1*(x - x1)) + y1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631472421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0
[75.071, 97.928, 162.2675, 04.7153, 162.9704, 2317.373, 67.3611, 68.3675, 109.6192, 162.9704]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 762, 'const': 372, 'code+const': 1134}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x=min(points[i*2],points[j*2])
  y=max(points[i*2+1],points[j*2+1])
  w=max(points[i*2],points[j*2])-min(points[i*2],points[j*2])
  h=max(points[i*2+1],points[j*2+1])-min(points[i*2+1],points[j*2+1])
  return[x,y,w,h]
def middle(points,i,j):
  x=(points[i*2]+points[j*2])/2
  y=(points[i*2+1]+points[j*2+1])/2
  return[x,y]
def frame_area(points,i,j):
  h=max(points[i*2],points[j*2])-min(points[i*2],points[j*2])
  w=max(points[i*2+1],points[j*2+1])-min(points[i*2+1],points[j*2+1])
  a=w*h
  return float(a)
def distance(points,i,j):
  d=math.sqrt((points[i*2]-points[j*2])**2+(points[i*2]-points[j*2])**2)
  return d
def intersection(points,p1,p2,p3,p4):
  p1_x=points[p1*2]
  p1_y=points[p1*2+1]
  p2_x=points[p2*2]
  p2_y=points[p2*2+1]
  p3_x=points[p3*2]
  p3_y=points[p3*2+1]
  p4_x=points[p4*2]
  p4_y=points[p4*2+1]
  a1=p2_y-p1_y
  b1=p1_x-p2_x
  c1=a1*p1_x+b1*p1_y
  a2=p4_y-p3_y
  b2=p3_x-p4_x
  c2=a2*p3_x+b2*p3_y
  det=a1*b2-a2*b1
  x=(b2*c1-b1*c2)/det
  y=(a1*c2-a2*c1)/det
  return [x,y]

6631507821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5.0, 6.0, 11.0, 1.0, 11.0, 16.0, 4.0, 5.0, 7.0, 12.0],
 [1.0, 2.0, 5.0, 4.0, 1.0, 6.0, 5.0, 7.0, 6.0, 1.0]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[07.5389, -216.0281, 15.093, 2.71.02, -02.404, -634.2943, 01.0548, 04.576, 13.0322, 24.934],
 [70.8953, 16-2.8102, 51.093, 7.02.71, 2-0.044, -346.4329, 10.4805, 40.657, 13.2203, 42.934]]
bytecount: {'code': 648, 'const': 544, 'code+const': 1192}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x = points[0::2]
    y = points[1::2]
    xmin = min([x[i],x[j]])
    ymax = max([y[i],y[j]])
    w = ((x[i]-x[j])**2+(y[i]-y[i])**2)**0.5
    h = ((x[i]-x[i])**2+(y[i]-y[j])**2)**0.5
    return [xmin,ymax,abs(w),abs(h)]
def middle(points,i,j):
    x = points[0::2]
    y = points[1::2]
    return [(x[i]+x[j])/2,(y[i]+y[j])/2]
def frame_area(points,i,j):
    frame(points,i,j)
    a = frame(points,i,j)[2]*frame(points,i,j)[3]
    return float(a)
def distance(points,i,j):
    x = points[0::2]
    y = points[1::2]
    d = ((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5
    return d
def intersection(points,p1,p2,p3,p4):
    x = points[0::2]
    y = points[1::2]
    a1 = x[p2]-x[p1]
    b1 = y[p1]-y[p2]
    d1 = (y[p1]*x[p2])-(x[p1]*y[p2])
    a2 = x[p4]-x[p3]
    b2 = y[p3]-y[p4]
    d2 = (y[p3]*x[p4])-(x[p3]*y[p4])
    detA = (a1*b2)-(a2*b1)
    interx = ((d1*b2)-(d2*b1))/detA
    intery = ((a1*d2)-(a2*d1))/detA
    return [interx,intery]

6631510621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0IndexError('list index out of range')
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.3504]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 618, 'const': 344, 'code+const': 962}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
     xi,yi=points[i*2: (i+1)*2]
     xj,yj=points[j*2: (j+1)*2]
     framex=min(xi,yi)
     framey=min(yi,yj)
     framewidth=abs(xi-xj)
     frameheight=abs(yi-yj)
     return [min(xi,xj), max(yi,yj), abs(xi-xj), abs(yi-yj)]
def middle(points,i,j):
     xi,yi=points[i*2:(i+1)*2]
     xj,yj=points[j*2:(j+1)*2]
     middlex=(xi+xj)/2
     middley=(yi+yj)/2
     return [middlex, middley]
def frame_area(points,i,j):
     framex, framey, framewidth, frameheight=frame(points,i,j)
     return float(framewidth*frameheight)
def distance(points,i,j):
    xi,yi=points[i*2], points[(i+1)*2]
    xj,yj=points[j*2], points[(j+1)*2]
    d=math.sqrt((xi-xj)**2+(yi-yj)**2)
    return d
def intersection(points,p1,p2,p3,p4):
     x1,y1=points[p1*2:(p1+1)*2]
     x2,y2=points[p2*2:(p2+1)*2]
     x3,y3=points[p3*2:(p3+1)*2]
     x4,y4=points[p4*2:(p4+1)*2]
     m1=(y2-y1)/(x2-x1)
     c1=y1-m1*x1
     m2=(y4-y3)/(x4-x3)
     c2=y3-m2*x3
     x=(c2-c1)/(m1-m2)
     y=m1*x+c1
     return [x,y]

6631542721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0
[25.021, 497.1628, 1352.675, 204.253, 1442.04, 2175.5173, 367.411, 598.785, 709.3592, 1442.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 644, 'const': 400, 'code+const': 1044}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  (x1,y1)=points[2*i:2*(i+1)]
  (x2,y2)=points[2*j:2*(j+1)]
  return[min(x1,x2),max(y1,y2),abs(x2-x1),abs(y2-y1)]
def middle(points,i,j):
  (x1,y1)=points[2*i:2*(i+1)]
  (x2,y2)=points[2*j:2*(j+1)]
  [x,y]=[(x1+x2)/2,(y1+y2)/2]
  return[x,y]
def frame_area(points,i,j):
  (x1,y1)=points[2*i:2*(i+1)]
  (x2,y2)=points[2*j:2*(j+1)]
  w,h=[abs(x2-x1),abs(y2-y1)]
  return w*h
def distance(points,i,j):
  (x1,y1)=points[2*i:2*(i+1)]
  (x2,y2)=points[2*j:2*(j+1)]
  [Y]=[(y2-y1)**2]
  [X]=[(x2-x1)**2]
  return((X**2)+(Y**2))**0.5
def intersection(points,p1,p2,p3,p4):
  (x1,y1)=points[p1*2:(p1+1)*2]
  (x2,y2)=points[p2*2:(p2+1)*2]
  (x3,y3)=points[p3*2:(p3+1)*2]
  (x4,y4)=points[p4*2:(p4+1)*2]
  [m1]=[(y2-y1)/(x2-x1)]
  [m2]=[(y4-y3)/(x4-x3)]
  c1=y1-(m1*x1)
  c2=y3-(m2*x3)
     #y-(m2*x)=c2
     #y-(m1*x)=c1
     #(-m2*x)+(m1*x)=c2-c1
     #x(m1-m2)=c2-c1
  x=(c2-c1)/(m1-m2)
  y=m1*x+c1
  return[x,y]

6631702821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.0NameError("name 'points' is not defined")
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 594, 'const': 344, 'code+const': 938}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    xi=points[i*2]
    xj=points[j*2]
    yi=points[(i*2)+1]
    yj=points[(j*2)+1]
    a=min(xi,xj)
    b=max(yi,yj)
    c=max(xi,xj)-min(xi,xj)
    d=max(yi,yj)-min(yi,yj)
    return[a,b,c,d]
def middle(points,i,j):
    xi=points[i*2]
    xj=points[j*2]
    yi=points[(i*2)+1]
    yj=points[(j*2)+1]
    xmid=(xi+xj)/2
    ymid=(yi+yj)/2
    return[xmid,ymid]
def frame_area(point,i,j):
    A,B,C,D=frame(points,i,j)
    return C*D
def distance(points,i,j):
    xi=points[i*2]
    xj=points[j*2]
    yi=points[(i*2)+1]
    yj=points[(j*2)+1]
    return math.sqrt((xi-xj)**2+(yi-yj)**2)
def intersection(points,p1,p2,p3,p4):
    xp1=points[p1*2]
    xp2=points[p2*2]
    xp3=points[p3*2]
    xp4=points[p4*2]
    yp1=points[(p1*2)+1]
    yp2=points[(p2*2)+1]
    yp3=points[(p3*2)+1]
    yp4=points[(p4*2)+1]
    m12=(yp2-yp1)/(xp2-xp1)
    m34=(yp4-yp3)/(xp4-xp3)
    c12=yp1-m12*xp1
    c34=yp3-m34*xp3
    x=(c34-c12)/(m12-m34)
    y=m12*x+c12
    return[x,y]

6632109921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 678, 'const': 608, 'code+const': 1286}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def getPoint(points, idx):
  return [points[idx * 2], points[idx * 2 + 1]]
def getSlope(a, b):
  return (b[1] - a[1]) / (b[0] - a[0])
def frame(points,i,j):
  first_point = getPoint(points, i)
  second_point = getPoint(points, j)
  x = min(first_point[0], second_point[0])
  y = max(first_point[1], second_point[1])
  w = abs(first_point[0] - second_point[0])
  h = abs(first_point[1] - second_point[1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  first_point = getPoint(points, i)
  second_point = getPoint(points, j)
  return [abs(first_point[0] + second_point[0]) / 2, abs(first_point[1] + second_point[1]) / 2] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  frame_data = frame(points, i, j)
  return float(frame_data[2] * frame_data[3]) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  first_point = getPoint(points, i)
  second_point = getPoint(points, j)
  return (abs(first_point[0] - second_point[0]) ** 2 + abs(first_point[1] - second_point[1]) ** 2)**0.5 # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  # y = mx + c
  # c = y - mx
  # -mx + y - c = 0
  l1_1 = getPoint(points, p1)
  l1_2 = getPoint(points, p2)
  m1 = getSlope(l1_1, l1_2)
  l1 = [-m1, 1, -(l1_1[1] - m1 * l1_1[0])]
  l2_1 = getPoint(points, p3)
  l2_2 = getPoint(points, p4)
  m2 = getSlope(l2_1, l2_2)
  l2 = [-m2, 1, -(l2_1[1] - m2 * l2_1[0])]
  x = (l1[1] * l2[2] - l2[1] * l1[2]) / (l1[0] * l2[1] - l2[0] * l1[1])
  y = (l2[0] * l1[2] - l1[0] * l2[2]) / (l1[0] * l2[1] - l2[0] * l1[1])
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632147721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0UnboundLocalError("local variable 'b1' referenced before assignment")
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 654, 'const': 344, 'code+const': 998}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x = min(points[2*i], points[2*j])
  y = max(points[2*i+1], points[2*j+1])
  w = max(points[2*i], points[2*j]) - x
  h = y - min(points[2*i+1], points[2*j+1])
  return [x,y,w,h]
def middle(points,i,j):
  x = (points[2*i]+points[2*j])/2
  y = (points[2*i+1]+points[2*j+1])/2
  return [x, y]
def frame_area(points,i,j):
  x, y, w, h = frame(points, i, j)
  a = w*h
  return float(a)
def distance(points,i,j):
  dx = abs(points[2*i] - points[2*j])
  dy = abs(points[2*i+1] - points[2*j+1])
  d = math.sqrt(dx**2 + dy**2)
  return d
def intersection(points,p1,p2,p3,p4):
  #a1x + b1y = c1
  a1, b1, c1 = points[2*p1+1] - points[2*p2+1], points[2*p2] - points[2*p1], b1*points[2*p1+1] + a1*points[2*p1]
  a2, b2, c2 = points[2*p3+1] - points[2*p4+1], points[2*p4] - points[2*p3], b2*points[2*p3+1] + a2*points[2*p3]
  det = a1*b2 - a2*b1
  x = (b2*c1 - b1*c2)/det
  y = (a1*c2 - a2*c1)/det
  return [x,y]

6632170021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle0.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 598, 'const': 400, 'code+const': 998}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x = min(points[2*i],points[2*j])
  y = max(points[2*i+1],points[2*j+1])
  w = abs(points[2*i]-points[2*j])
  h = abs(points[2*i+1]-points[2*j+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = abs(points[2*i]+points[2*j])/2
  y = abs(points[2*i+1]+points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  l = frame(points,i,j)
  a = l[2]*l[3]
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  import math
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  d = math.sqrt((x1-x2)**2 + (y1-y2)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[2*p1]
  y1 = points[2*p1+1]
  x2 = points[2*p2]
  y2 = points[2*p2+1]
  x3 = points[2*p3]
  y3 = points[2*p3+1]
  x4 = points[2*p4]
  y4 = points[2*p4+1]
  m1 = (y2-y1)/(x2-x1) #p1,p2
  c1 = y1-m1*x1 # y = m1*x1 + c1
  m2 = (y4-y3)/(x4-x3) #p3,p4
  c2 = y3-m2*x3 # y = m2*x3 + c2
  x = (c2-c1)/(m1-m2)
  y = m1*x + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632171721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance0.0
[5.391, 7.0728, 142.375, 74.523, 132.042, 217.732, 7.113.29, 48.745, 79.592, 12.6504]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 936, 'const': 472, 'code+const': 1408}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
   p1 = points[i*2],points[i*2+1]
   p2 = points[j*2],points[j*2+1]
   x = min(p1[0],p2[0])
   y = max(p1[1],p2[1])
   w = abs(p1[0]-p2[0])
   h = abs(p1[1]-p2[1])
   return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  p1 = points[i*2],points[i*2+1]
  p2 = points[j*2],points[j*2+1]
  x = (float(p1[0])+float(p2[0]))/2
  y = (float(p1[1])+float(p2[1]))/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    a = float(frame(points,i,j)[2]*frame(points,i,j)[3])
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    p1 = points[i*2], points[i*2+1]
    p2 = points[j*2], points[j*2+1]
    d = ((float(points[i*2])-float(points[j*2]))**2+(float(points[i*2])-float(points[j*2+1]))**2)**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    a = points[p1 * 2], points[p1 * 2 + 1]
    b = points[p2 * 2], points[p2 * 2 + 1]
    c = points[p3 * 2], points[p3 * 2 + 1]
    d = points[p4 * 2], points[p4 * 2 + 1]
    x = ((a[0]*b[1]-a[1]*b[0])*(c[0]-d[0])-(a[0]-b[0])*(c[0]*d[1]-c[1]*d[0]))/((a[0]-b[0])*(c[1]-d[1])-(a[1]-b[1])*(c[0]-d[0]))
    y = ((a[0]*b[1]-a[1]*b[0])*(c[1]-d[1])-(a[1]-b[1])*(c[0]*d[1]-c[1]*d[0]))/((a[0]-b[0])*(c[1]-d[1])-(a[1]-b[1])*(c[0]-d[0]))
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632234621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.0
[[07.5389, -216.0281, 15.093, 2.71.02, -02.404, -634.2943, 01.0548, 04.576, 13.0322, 24.934],
 [70.8953, 16-2.8102, 51.093, 7.02.71, 2-0.044, -346.4329, 10.4805, 40.657, 13.2203, 42.934]]
bytecount: {'code': 682, 'const': 400, 'code+const': 1082}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x = min(points[2*i],points[2*j])
  y = max(points[2*i+1],points[2*j+1])
  w = abs(points[2*i]-points[2*j])
  h = abs(points[2*i+1]-points[2*j+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  return [(points[2*i]+points[2*j])/2,(points[2*i+1]+points[2*j+1])/2] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs(points[2*i]-points[2*j])
  h = abs(points[2*i+1]-points[2*j+1])
  return float(w*h) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  w = abs(points[2*i]-points[2*j])
  h = abs(points[2*i+1]-points[2*j+1])
  return math.sqrt(w**2+h**2) # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4) :
  x1 = points[2 * p1 + 1]
  x2 = points[2 * p2 + 1]
  y1 = points[2 * p1]
  y2 = points[2 * p2]
  x3 = points[2 * p3 + 1]
  x4 = points[2 * p4 + 1]
  y3 = points[2 * p3]
  y4 = points[2 * p4]
  a1 = y1 - y2
  b1 = x2 - x1
  c1 = x1 * (y2 - y1) - y1 * (x2 - x1)
  a2 = y3 - y4
  b2 = x4 - x3
  c2 = x3 * (y4 - y3) - y3 * (x4 - x3)
  x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)
  y = (a2 * c1 - a1 * c2) / (a1 * b2 - a2 * b1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631002121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [1.05, 0.06, 5.011, 0.01, 0.011, 16.0, 4.0, 5.0, 0.07, 1.02],
 [5.01, 6.324555320336759, 11.05, 4.123105625617661, 11.045361017187261, 16.0, 5.0, 7.0,
  9.2195444572928876, 12.0]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.6
[5.0, 014.0, 63.25, 02.025, 012.0, 107.25, 24.75, 33.75, 048.075, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 664, 'const': 368, 'code+const': 1032}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1 = points[2*i]
    y1 = points[2*i + 1]
    x2 = points[2*j]
    y2 = points[2*j + 1]
    corner_x = min(x1, x2)
    corner_y = max(y1, y2)
    lenght1 = (((corner_x - x1)**2 +(corner_y - y1)**2)**0.5)
    lenght2 = (((corner_x - x2)**2 +(corner_y - y2)**2)**0.5)
    width = min(lenght1, lenght2)
    height = max(lenght1, lenght2)
    return [corner_x, corner_y, width, height]
def middle(points,i,j):
    mid_x = (points[2*i] + points[2*j]) / 2
    mid_y = (points[2*i + 1] + points[2*j + 1]) / 2
    return [mid_x, mid_y]
def frame_area(points,i,j):
    x, y, w, h = frame(points, i, j)
    return float(w * h)
def distance(points,i,j):
    return (((points[2*i] - points[2*j])**2 +(points[2*i +1] - points[2*j +1])**2)**0.5)
def intersection(points,p1,p2,p3,p4):
    x1 = points[2*p1]
    x2 = points[2*p2]
    x3 = points[2*p3]
    x4 = points[2*p4]
    y1 = points[2*p1 + 1]
    y2 = points[2*p2 + 1]
    y3 = points[2*p3 + 1]
    y4 = points[2*p4 + 1]
    px= ( (x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4) ) / ( (x1-x2)*(y3-y4)-(y1-y2)*(x3-x4) )
    py= ( (x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4) ) / ( (x1-x2)*(y3-y4)-(y1-y2)*(x3-x4) )
    return [px, py]

6631010121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, -6, -11, 1, -11, -16, -4, -5, 7, 12], [1, 2, -5, -4, 1, -6, -5, -7, -6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 794, 'const': 400, 'code+const': 1194}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points, i, j):
    a1 = 2 * i
    a2 = 2 * i + 1
    b1 = 2 * j
    b2 = 2 * j + 1
    x1 = points[a1]
    y1 = points[a2]
    x2 = points[b1]
    y2 = points[b2]
    x = min(x1, x2)
    y = max(y1, y2)
    w = x2 - x1
    h = y2 - y1
    return [x, y, w, h]  # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points, i, j):
    a1 = 2 * i
    a2 = 2 * i + 1
    b1 = 2 * j
    b2 = 2 * j + 1
    x1 = points[a1]
    y1 = points[a2]
    x2 = points[b1]
    y2 = points[b2]
    x = (x1 + x2) / 2
    y = (y1 + y2) / 2
    return [x, y]  # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points, i, j):
    a1 = 2 * i
    a2 = 2 * i + 1
    b1 = 2 * j
    b2 = 2 * j + 1
    x1 = points[a1]
    y1 = points[a2]
    x2 = points[b1]
    y2 = points[b2]
    a = (x2 - x1) * (y2 - y1)
    return float(a)  # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points, i, j):
    a1 = 2 * i
    a2 = 2 * i + 1
    b1 = 2 * j
    b2 = 2 * j + 1
    x1 = points[a1]
    y1 = points[a2]
    x2 = points[b1]
    y2 = points[b2]
    d = math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
    return d  # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points, p1, p2, p3, p4):
    a1 = 2 * p1
    a2 = 2 * p1 + 1
    b1 = 2 * p2
    b2 = 2 * p2 + 1
    c1 = 2 * p3
    c2 = 2 * p3 + 1
    d1 = 2 * p4
    d2 = 2 * p4 + 1
    x1 = points[a1]
    y1 = points[a2]
    x2 = points[b1]
    y2 = points[b2]
    x3 = points[c1]
    y3 = points[c2]
    x4 = points[d1]
    y4 = points[d2]
    x = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / (
                (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4))
    y = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / (
                (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4))
    return [x, y]  # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630043721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.2
[5.0, 124.0, 5563.025, 42.025, 112.0, 96107.025, 204.075, 33.75.0, 428.075, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 674, 'const': 400, 'code+const': 1074}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  xi=points[2*i]
  yi=points[2*i+1]
  xj=points[2*j]
  yj=points[2*j+1]
  x=min(xi,xj)
  y=max(yi,yj)
  w=abs(int(xi)-int(xj))
  h=abs(int(yi)-int(yj))
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi=points[2*i]
  yi=points[2*i+1]
  xj=points[2*j]
  yj=points[2*j+1]
  x=(xi+xj)/2
  y=(yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi=points[2*i]
  yi=points[2*i+1]
  xj=points[2*j]
  yj=points[2*j+1]
  w=abs(int(xi)-int(xj))
  h=abs(int(yi)-int(yj))
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi=points[2*i]
  yi=points[2*i+1]
  xj=points[2*j]
  yj=points[2*j+1]
  d=math.sqrt(((xi-xj)**2)+((yi-yj)**2))
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1=points[2*p1]
  y1=points[2*p1+1]
  x2=points[2*p2]
  y2=points[2*p2+1]
  x3=points[2*p3]
  y3=points[2*p3+1]
  x4=points[2*p4]
  y4=points[2*p4+1]
  m1=(y2-y1)/(x2-x1)
  m2=(y4-y3)/(x4-x3)
  x=(y3-y1+m1*x1-m2*x3)/(m1-m2)
  y=m1*(x-x1)+y1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631364321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.4
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 764, 'const': 400, 'code+const': 1164}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x = min(points[i*2], points[j*2])
  y = max(points[i*2 + 1], points[j*2 + 1])
  w = abs(x - max(points[i*2], points[j*2]))
  h = abs(y - min(points[i*2 + 1], points[j*2 + 1]))
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  [x1, y1] = [points[i*2], points[i*2 + 1]]
  [x2, y2] = [points[j*2], points[j*2 + 1]]
  [x, y] = [(x1+x2)/2, (y1+y2)/2]
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs(points[j*2] - points[i*2])
  h = abs(points[j*2 + 1] - points[i*2 + 1])
  a = int(w*h)
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  [x1, y1] = [points[i*2], points[i*2 + 1]]
  [x2, y2] = [points[j*2], points[j*2 + 1]]
  d = ((x2-x1)**2 + (y2-y1)**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  [x1, y1] = [points[p1*2], points[p1*2 + 1]]
  [x2, y2] = [points[p2*2], points[p2*2 + 1]]
  [x3, y3] = [points[p3*2], points[p3*2 + 1]]
  [x4, y4] = [points[p4*2], points[p4*2 + 1]]
  x = ((y3*x4 - y4*x3)*(x2-x1) - (y1*x2 - y2*x1)*(x4-x3)) / ((y2-y1)*(x4-x3) - (y4-y3)*(x2-x1))
  y = ((y3*x4 - y4*x3)*(y2-y1) - (y1*x2 - y2*x1)*(y4-y3)) / ((y2-y1)*(x4-x3) - (y4-y3)*(x2-x1))
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6530403921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 612, 'const': 520, 'code+const': 1132}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  Lx = points[0::2]
  Ly = points[1::2]
  x1 = Lx[i]
  x2 = Lx[j]
  y1 = Ly[i]
  y2 = Ly[j]
  w = abs(x2-x1)
  h = abs(y2-y1)
  x = x1
  y = y2
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  Lx = points[0::2]
  Ly = points[1::2]
  x1 = Lx[i]
  x2 = Lx[j]
  y1 = Ly[i]
  y2 = Ly[j]
  x = (x1+x2)/2
  y = (y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  Lx = points[0::2]
  Ly = points[1::2]
  x1 = Lx[i]
  x2 = Lx[j]
  y1 = Ly[i]
  y2 = Ly[j]
  w = abs(x2-x1)
  h = abs(y2-y1)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  Lx = points[0::2]
  Ly = points[1::2]
  x1 = Lx[i]
  x2 = Lx[j]
  y1 = Ly[i]
  y2 = Ly[j]
  d = (((x2-x1)**2)+((y2-y1)**2))**(1/2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  Lx = points[0::2]
  Ly = points[1::2]
  x1 = Lx[p1]
  x2 = Lx[p2]
  x3 = Lx[p3]
  x4 = Lx[p4]
  y1 = Ly[p1]
  y2 = Ly[p2]
  y3 = Ly[p3]
  y4 = Ly[p4]
  m1 = (y2-y1)/(x2-x1)
  m2 = (y4-y3)/(x4-x3)
  x = (m1*x1-y1-m2*x3+y3)/(m1-m2)
  y = m1*(x-x1)+y1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6531809221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 612, 'const': 400, 'code+const': 1012}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  lx=points[::2]
  ly=points[1::2]
  x1=lx[i]
  y1=ly[i]
  x2=lx[j]
  y2=ly[j]
  w=abs(x2-x1)
  h=abs(y2-y1)
  x=x1
  y=y2
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  lx=points[::2]
  ly=points[1::2]
  x1=lx[i]
  y1=ly[i]
  x2=lx[j]
  y2=ly[j]
  x=(x1+x2)/2
  y=(y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  lx=points[::2]
  ly=points[1::2]
  x1=lx[i]
  y1=ly[i]
  x2=lx[j]
  y2=ly[j]
  w=abs(x2-x1)
  h=abs(y2-y1)
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  lx=points[::2]
  ly=points[1::2]
  x1=lx[i]
  y1=ly[i]
  x2=lx[j]
  y2=ly[j]
  d=(((x2-x1)**2)+((y2-y1)**2))**(1/2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  lx=points[::2]
  ly=points[1::2]
  x1=lx[p1]
  x2=lx[p2]
  x3=lx[p3]
  x4=lx[p4]
  y1=ly[p1]
  y2=ly[p2]
  y3=ly[p3]
  y4=ly[p4]
  m1=(y2-y1)/(x2-x1)
  m2=(y4-y3)/(x4-x3)
  x=(m1*x1-y1-m2*x3+y3)/(m1-m2)
  y=m1*(x-x1)+y1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6532069321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [15, 26, 511, 1, 11, 16, 4, 5, 67, 12], [51, 62, 115, 4, 11, 16, 5, 7, 76, 12]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 900, 'const': 520, 'code+const': 1420}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  a=points[i*2],points[(i*2)+1]
  b=points[(j*2)],points[(j*2)+1]
  c=int(max(a[0],b[0])-min(a[0],b[0]))
  d=int(max(a[1],b[1])-min(a[1],b[1]))
  x=int(max(a[0],b[0]))-c
  y=int(max(a[1],b[1]))
  w=min(c,d)
  h=max(c,d)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  a=points[i*2],points[(i*2)+1]
  b=points[(j*2)],points[(j*2)+1]
  x=(a[0]+b[0])/2
  y=(a[1]+b[1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  a1=points[i*2],points[(i*2)+1]
  b1=points[(j*2)],points[(j*2)+1]
  c=float(max(a1[0],b1[0])-min(a1[0],b1[0]))
  d=float(max(a1[1],b1[1])-min(a1[1],b1[1]))
  a=float(c*d)
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
   a=points[i*2],points[(i*2)+1]
   b=points[(j*2)],points[(j*2)+1]
   d= float( (((abs(a[0]-b[0]))**2)+((abs(a[1]-b[1]))**2))**0.5 )
   return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  a=points[p1*2],points[(p1*2)+1]
  b=points[p2*2],points[(p2*2)+1]
  c=points[p3*2],points[(p3*2)+1]
  d=points[p4*2],points[(p4*2)+1]
  a1=a[1]-b[1]
  a2=a[0]-b[0]
  m1=a1/a2
  b1=c[1]-d[1]
  b2=c[0]-d[0]
  m2=b1/b2
  c1=a[1]-(m1*a[0])
  c2=c[1]-(m2*c[0])
  x=(c2-c1)/(m1-m2)
  y=(m1*x)+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630023121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[14, 1-2, 1-7, 14, -2, 2-7, 25, -27, -2, -7], [92, 3, -41, 51, 3, -42, 52, -43, 53, 5-3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 762, 'const': 520, 'code+const': 1282}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  a,b = [points[i*2],points[(i*2)+1]],[points[j*2],points[(j*2)+1]]
  x,y = min(a),max(b)
  w = abs(a[0]-b[0])
  h = abs(a[1]-b[1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  a,b = [points[i*2],points[(i*2)+1]],[points[j*2],points[(j*2)+1]]
  x,y = (a[0]+b[0])/2,(a[1]+b[1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  m,n = [points[i*2],points[(i*2)+1]],[points[j*2],points[(j*2)+1]]
  a = abs((m[0]-n[0])*(m[1]-n[1]))
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  m,n = [points[i*2],points[(i*2)+1]],[points[j*2],points[(j*2)+1]]
  d = math.sqrt(((m[0]-n[0])**2)+((m[1]-n[1])**2))
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  m,n,o,p = [points[p1*2],points[(p1*2)+1]],[points[p2*2],points[(p2*2)+1]],[points[p3*2],points[(p3*2)+1]],[points[p4*2],points[(p4*2)+1]]
  m1,m2 = (m[1]-n[1])/(m[0]-n[0]),(o[1]-p[1])/(o[0]-p[0])
  c1,c2 = m[1]-m1*(m[0]),o[1]-m2*(o[0])
  x = (c2-c1)/(m1-m2)
  y = m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630056921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [05, 06, 011, 01, 011, 016, 04, 05, 07, 012],
 [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 604, 'const': 400, 'code+const': 1004}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1=points[i*2]
  y1=points[i*2+1]
  x2=points[i*2]
  y2=points[j*2+1]
  return [min(x1,x2),max(y1,y2),abs(x1-x2),abs(y1-y2)]
def middle(points,i,j):
  x1=points[i*2]
  y1=points[i*2+1]
  x2=points[j*2]
  y2=points[j*2+1]
  return[(x1+x2)/2,(y1+y2)/2]
def frame_area(points,i,j):
  x1=points[i*2]
  y1=points[i*2+1]
  x2=points[j*2]
  y2=points[j*2+1]
  return float(abs(x1-x2)*abs(y1-y2))
def distance(points,i,j):
  x1=points[i*2]
  y1=points[i*2+1]
  x2=points[j*2]
  y2=points[j*2+1]
  return((x2-x1)**2+(y2-y1)**2)**0.5
def intersection(points,p1,p2,p3,p4):
  x1=points[p1*2]
  y1=points[p1*2+1]
  x2=points[p2*2]
  y2=points[p2*2+1]
  x3=points[p3*2]
  y3=points[p3*2+1]
  x4=points[p4*2]
  y4=points[p4*2+1]
  slope1=(y2-y1)/(x2-x1)
  c1=y2-slope1*x2
  slope2=(y4-y3)/(x4-x3)
  c2=y4-slope2*x4
  x=(c2-c1)/(slope1-slope2)
  y=(slope2*c1-slope1*c2)/(slope2-slope1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630065521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 606, 'const': 400, 'code+const': 1006}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x=points[2*i]
  y=points[2*j+1]
  w=abs(points[2*j]-points[2*i])
  h=abs(points[2*j+1]-points[2*i+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x=(points[2*j]+points[2*i])/2
  y=(points[2*j+1]+points[2*i+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w=abs(points[2*j]-points[2*i])
  h=abs(points[2*j+1]-points[2*i+1])
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x=points[2*j]-points[2*i]
  y=points[2*j+1]-points[2*i+1]
  d=math.sqrt(x**2+y**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  m1=(points[2*p2+1]-points[2*p1+1])/(points[2*p2]-points[2*p1])
  m2=(points[2*p4+1]-points[2*p3+1])/(points[2*p4]-points[2*p3])
  c1=points[2*p1+1]-m1*points[2*p1]
  c2=points[2*p3+1]-m2*points[2*p3]
  x=(c2 - c1)/(m1 - m2)
  y=m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630083821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [15, 26, 511, 1, 11, 16, 4, 5, 67, 12], [51, 62, 115, 4, 11, 16, 5, 7, 76, 12]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 770, 'const': 400, 'code+const': 1170}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x = min(points[2*i],points[2*j])
  y = max(points[2*i+1],points[2*j+1])
  w = min((abs(points[2*i]-points[2*j])),(abs(points[2*i+1]-points[2*j+1])))
  h = max((abs(points[2*i]-points[2*j])),(abs(points[2*i+1]-points[2*j+1])))
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[2*i]+points[2*j])/2
  y = (points[2*i+1]+points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = min((abs(points[2*i]-points[2*j])),(abs(points[2*i+1]-points[2*j+1])))
  h = max((abs(points[2*i]-points[2*j])),(abs(points[2*i+1]-points[2*j+1])))
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  a = (points[2*i]-points[2*j])**2
  b = (points[2*i+1]-points[2*j+1])**2
  d = math.sqrt(a+b)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1=points[2*p1]
  y1=points[2*p1+1]
  x2=points[2*p2]
  y2=points[2*p2+1]
  x3=points[2*p3]
  y3=points[2*p3+1]
  x4=points[2*p4]
  y4=points[2*p4+1]
  m1 = (y1-y2)/(x1-x2)
  m2 = (y3-y4)/(x3-x4)
  c1 = y1- m1*x1
  c2 = y3- m2*x3
  x0 = (c2-c1)/(m1-m2)
  x = x0
  y = (m1*x0) +c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630090121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 666, 'const': 400, 'code+const': 1066}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x1=points[2*i]
    y1=points[2*i+1]
    x2=points[2*j]
    y2=points[2*j+1]
    x=x1
    y=y1+(y2-y1)
    w=abs(x2-x1)
    h=abs(y2-y1)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x1=points[2*i]
    y1=points[2*i+1]
    x2=points[2*j]
    y2=points[2*j+1]
    x=(x1+x2)/2
    y=(y1+y2)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x1=points[2*i]
    y1=points[2*i+1]
    x2=points[2*j]
    y2=points[2*j+1]
    w=abs(x2-x1)
    h=abs(y2-y1)
    a=w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1=points[2*i]
    y1=points[2*i+1]
    x2=points[2*j]
    y2=points[2*j+1]
    dx=x2-x1
    dy=y2-y1
    d=math.sqrt((dx**2)+(dy**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1=points[p1*2]
    y1=points[p1*2+1]
    x2=points[p2*2]
    y2=points[p2*2+1]
    x3=points[p3*2]
    y3=points[p3*2+1]
    x4=points[p4*2]
    y4=points[p4*2+1]
    m1=(y2-y1)/(x2-x1)
    m2=(y4-y3)/(x4-x3)
    y = (m1*m2*x3-m1*m2*x1+m2*y1-m1*y3)/(m2-m1)
    x = ((y-y3)+(m2*x3))/m2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630096021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4.0, 4.0-2, 4.0-7, 4.0, 9.0-2, 9.0-7, 9.05, -2.07, -2.0, -7.0],
 [2.0, 3.0, -4.01, -3.01, 3.0, -4.02, -3.02, -4.03, -3.0, -3.0],
 [5.0, 6.0, 11.0, 1.0, 11.0, 16.0, 4.0, 5.0, 7.0, 12.0],
 [1.0, 2.0, 5.0, 4.0, 1.0, 6.0, 5.0, 7.0, 6.0, 1.0]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 744, 'const': 400, 'code+const': 1144}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x_1=float(points[2*i])
  x_2=float(points[2*j])
  y_1=float(points[2*i+1])
  y_2=float(points[2*j+1])
  x=x_1
  y=y_2
  w=abs(x_1-x_2)
  h=abs(y_1-y_2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x_1=float(points[2*i])
  x_2=float(points[2*j])
  y_1=float(points[2*i+1])
  y_2=float(points[2*j+1])
  x=(x_1+x_2)/2
  y=(y_1+y_2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x_1=float(points[2*i])
  x_2=float(points[2*j])
  y_1=float(points[2*i+1])
  y_2=float(points[2*j+1])
  x=x_1
  y=y_2
  w=abs(x_1-x_2)
  h=abs(y_1-y_2)
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x_1=float(points[2*i])
  x_2=float(points[2*j])
  y_1=float(points[2*i+1])
  y_2=float(points[2*j+1])
  d=(((x_1-x_2)**2)+((y_1-y_2)**2))**(1/2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x_1=float(points[2*p1])
  x_2=float(points[2*p2])
  x_3=float(points[2*p3])
  x_4=float(points[2*p4])
  y_1=float(points[2*p1+1])
  y_2=float(points[2*p2+1])
  y_3=float(points[2*p3+1])
  y_4=float(points[2*p4+1])
  m_1=(y_1-y_2)/(x_1-x_2)
  m_2=(y_3-y_4)/(x_3-x_4)
  x=(m_1*x_1-m_2*x_3+y_3-y_1)/(m_1-m_2)
  y=((x_3-x_1)*(m_2)*(m_1)-(m_1*y_3)+(m_2*y_1))/(m_2-m_1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630097621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[14, 1-2, 1-7, 14, -2, 2-7, 25, -27, -2, -7], [92, 3, -41, 51, 3, -42, 52, -43, 53, 5-3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 576, 'const': 344, 'code+const': 920}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    k1 = points[i*2]
    o1 = points[1+(i*2)]
    k2 = points[j*2]
    o2 = points[1+(j*2)]
    x = min(k1,o1)
    y = max(k2,o2)
    w = abs(k1-k2)
    h = abs(o1-o2)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    k1 = points[i*2]
    o1 = points[1+(i*2)]
    k2 = points[j*2]
    o2 = points[1+(j*2)]
    x = (k1+k2)/2
    y = (o1+o2)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x,y,w,h = frame(points,i,j)
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    k1 = points[i*2]
    o1 = points[1+(i*2)]
    k2 = points[j*2]
    o2 = points[1+(j*2)]
    d = ((k2-k1)**2+(o2-o1)**2)**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    k1 = points[p1*2]
    o1 = points[p1*2 + 1]
    k2 = points[p2*2]
    o2 = points[p2*2 + 1]
    k3 = points[p3*2]
    o3 = points[p3*2 + 1]
    k4 = points[p4*2]
    o4 = points[p4*2 + 1]
    a1 = (o2-o1) / (k2-k1)
    b1 = o1-a1*k1
    a2 = (o4-o3) / (k4-k3)
    b2 = o3-a2*k3
    x = (b2-b1) / (a1-a2)
    y = a1*x+b1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4
#by6630097621

6631112521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 606, 'const': 400, 'code+const': 1006}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x=points[2*i]
  y=points[(2*j)+1]
  w=abs(points[(2*i)]-points[(2*j)])
  h=abs(points[((2*i)+1)]-points[((2*j)+1)])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x=((points[2*i]+points[2*j])/2)
  y=((points[(2*i)+1]+points[(2*j)+1])/2)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w=abs(points[(2*i)]-points[(2*j)])
  h=abs(points[((2*i)+1)]-points[((2*j)+1)])
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi=(points[2*i])
  yi=(points[(2*i)+1])
  xj=(points[2*j])
  yj=(points[(2*j)+1])
  d=math.sqrt(((xi-xj)**2)+((yi-yj)**2))
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xp1=(points[p1*2])
  yp1=(points[(p1*2)+1])
  xp2=(points[p2*2])
  yp2=(points[(p2*2)+1])
  xp3=(points[p3*2])
  yp3=(points[(p3*2)+1])
  xp4=(points[p4*2])
  yp4=(points[(p4*2)+1])
  m1=(yp2-yp1)/(xp2-xp1)
  m2=(yp4-yp3)/(xp4-xp3)
  c1=yp1-(m1*xp1)
  c2=yp3-(m2*xp3)
  x=(c1-c2)/(m2-m1)
  y=(m1*x)+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631219021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [15, 26, 511, 1, 11, 16, 4, 5, 67, 12], [51, 62, 115, 4, 11, 16, 5, 7, 76, 12]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 738, 'const': 400, 'code+const': 1138}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  i < j
  xi = points[ 2*i ]
  yi = points[ 2*i + 1 ]
  xj = points[ 2*j ]
  yj = points[ 2*j + 1 ]
  xm = xi
  ym = yj
  d1 = abs( yi - ym )
  d2 = abs( xm - xj )
  d = [ d1 , d2 ]
  saifa_x = [ xi , xj , xm ]
  saifa_y = [ yi , yj , ym ]
  x = min( saifa_x )
  y = max( saifa_y )
  w = min( d )
  h = max( d )
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[ 2*i ]
  yi = points[ 2*i + 1 ]
  xj = points [ 2*j ]
  yj = points[ 2*j + 1 ]
  x = (xi + xj) / 2
  y = (yi + yj) / 2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  i < j
  xi = points[ 2*i ]
  yi = points[ 2*i + 1 ]
  xj = points[ 2*j ]
  yj = points[ 2*j + 1 ]
  xm = xi
  ym = yj
  d1 = abs( yi - ym )
  d2 = abs( xm - xj )
  a = d1 * d2
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[ 2*i ]
  yi = points[ 2*i + 1 ]
  xj = points[ 2*j ]
  yj = points[ 2*j + 1 ]
  x = ( xi - xj )**2
  y = ( yi - yj )**2
  d = math.sqrt( x + y )
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[ p1*2 ]
  y1 = points[ p1*2 + 1 ]
  x2 = points[ p2*2 ]
  y2 = points[ p2*2 + 1 ]
  x3 = points[ p3*2 ]
  y3 = points[ p3*2 + 1 ]
  x4 = points[ p4*2 ]
  y4 = points[ p4*2 + 1 ]
  mi = ( y2 - y1 ) / ( x2 - x1 )
  mf = ( y4 - y3 ) / ( x4 - x3 )
  ci = y1 - mi * x1
  cf = y3 - mf * x3
  x = ( cf - ci ) / ( mi - mf )
  y = (( ci * mf ) - ( cf * mi )) / ( mf - mi )
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631305321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection0.5
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [1.86, -40.534, 4-2.042, 81.6709, -2.371, -110.434, -6.2.089, 70.2805, 70.957, 13.03, 2.093]]
bytecount: {'code': 692, 'const': 424, 'code+const': 1116}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x = min(points[(2*i)] , points[(2*j)])
    y = max(points[(2*i)+1] , points[(2*j)+1])
    w = abs(points[(2*i)] - points[(2*j)])
    h = abs(points[(2*i)+1] - points[(2*j)+1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x = (points[(2*i)] + points[(2*j)])/2
    y = (points[(2*i)+1] + points[(2*j)+1])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    w = abs(points[(2*i)] - points[(2*j)])
    h = abs(points[(2*i)+1] - points[(2*j)+1])
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    delta_x = (points[(2*i)] - points[(2*j)])**2
    delta_y = (points[(2*i)+1] - points[(2*j)+1])**2
    d = (delta_x + delta_y)**(1/2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    m1 = (points[(2*p2)+1] - points[(2*p1)+1]) / (points[2*p2] - points[2*p1])
    m2 = (points[(2*p4)+1] - points[(2*p3)+1]) / (points[2*p4] - points[2*p3])
    x = ((points[2*p3]*m2) - (points[2*p1]*m1) + points[(2*p1)+1] - points[(2*p3)+1]) / (m2 - m1)
    y = ((m1*m2)*(points[2*p3] - points[2*p1]) - (m1*points[(2*p3)*1]) + (m2*points[(2*p1)+1])) / (m2-m1)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631456421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 654, 'const': 400, 'code+const': 1054}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x1 = points[i * 2]
  y1 = points[i * 2 + 1]
  x2 = points[j * 2]
  y2 = points[j * 2 + 1]
  x = x1
  y = y2
  w = abs(x2 - x1)
  h = abs(y2 - y1)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1 = points[i * 2]
  y1 = points[i * 2 + 1]
  x2 = points[j * 2]
  y2 = points[j * 2 + 1]
  x = (x1 + x2) / 2
  y = (y1 + y2) / 2
  return [x, y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1 = points[i * 2]
  y1 = points[i * 2 + 1]
  x2 = points[j * 2]
  y2 = points[j * 2 + 1]
  w = abs(x2 - x1)
  h = abs(y2 - y1)
  a = w * h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1 = points[i * 2]
  y1 = points[i * 2 + 1]
  x2 = points[j * 2]
  y2 = points[j * 2 + 1]
  w = abs(x2 - x1)
  h = abs(y2 - y1)
  d = math.sqrt(pow(w,2)+pow(h,2))
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[p1 * 2]
  y1 = points[p1 * 2 + 1]
  x2 = points[p2 * 2]
  y2 = points[p2 * 2 + 1]
  x3 = points[p3 * 2]
  y3 = points[p3 * 2 + 1]
  x4 = points[p4 * 2]
  y4 = points[p4 * 2 + 1]
  # y = mx + c
  m1 = (y2 - y1)/(x2 - x1)
  m2 = (y4 - y3)/(x4 - x3)
  in1 = y1 - m1 * x1
  in2 = y3 - m2 * x3
  x = (in2 - in1) / (m1 - m2)
  y = m1 * x + in1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631466721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [15, 26, 511, 1, 11, 16, 4, 5, 67, 12], [51, 62, 115, 4, 11, 16, 5, 7, 76, 12]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 618, 'const': 400, 'code+const': 1018}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  xi = points[i*2]
  yi = points[i*2+1]
  xj = points[j*2]
  yj = points[j*2+1]
  x = min(xi,xj)
  y = max(yi,yj)
  wh = [abs(xi-xj),abs(yi-yj)]
  w = min(wh)
  h = max(wh)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[i*2]
  yi = points[i*2+1]
  xj = points[j*2]
  yj = points[j*2+1]
  x = (xi+xj)/2
  y = (yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  fr = frame(points,i,j)
  a = fr[2]*fr[3]
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[i*2]
  yi = points[i*2+1]
  xj = points[j*2]
  yj = points[j*2+1]
  d = math.sqrt((xi-xj)**2+(yi-yj)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xi = points[p1*2]
  yi = points[p1*2+1]
  xj = points[p2*2]
  yj = points[p2*2+1]
  xk = points[p3*2]
  yk = points[p3*2+1]
  xl = points[p4*2]
  yl = points[p4*2+1]
  mij = (yi-yj)/(xi-xj)
  mkl = (yk-yl)/(xk-xl) #หาความชันของเส้นตรงแต่ละเส้น
  cij = yi-(mij*xi)
  ckl = yk-(mkl*xk) #หาจุดตัดแกน y ของเส้นตรงแต่ละเส้น
  x = (ckl-cij)/(mij-mkl)
  y = ((mkl*cij)-(mij*ckl))/(mkl-mij)
  #ย้ายข้างสมการเส้นตรงเพื่อหาพิกัด(x,y)ของจุดตัดของเส้นตรง2เส้น
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631502621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[14, 1-2, 1-7, 14, -2, 2-7, 25, -27, -2, -7], [92, 3, -41, 51, 3, -42, 52, -43, 53, 5-3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 712, 'const': 400, 'code+const': 1112}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x_i,y_i=points[i*2],points[(i*2)+1]
  x_j,y_j=points[j*2],points[(j*2)+1]
  x=min(points[i*2],points[(i*2)+1])
  y=max(points[j*2],points[(j*2)+1])
  w=abs(x_i-x_j)
  h=abs(y_i-y_j)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x_i,y_i=points[i*2],points[(i*2)+1]
  x_j,y_j=points[j*2],points[(j*2)+1]
  x=(x_i+x_j)/2
  y=(y_i+y_j)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x_i,y_i=points[i*2],points[(i*2)+1]
  x_j,y_j=points[j*2],points[(j*2)+1]
  ความกว้าง=abs(x_i-x_j)
  ความสูง=abs(y_i-y_j)
  a=ความกว้าง*ความสูง
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x_i,y_i=points[i*2],points[(i*2)+1]
  x_j,y_j=points[j*2],points[(j*2)+1]
  ด้าน1= abs(x_i-x_j)
  ด้าน2= abs(y_i-y_j)
  d=(((ด้าน1)**2)+((ด้าน2)**2))**(1/2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x_p1,y_p1=points[p1*2],points[(p1*2)+1]
  x_p2,y_p2=points[p2*2],points[(p2*2)+1]
  x_p3,y_p3=points[p3*2],points[(p3*2)+1]
  x_p4,y_p4=points[p4*2],points[(p4*2)+1]
  ความชัน1=(y_p2-y_p1)/(x_p2-x_p1)
  ความชัน2=(y_p4-y_p3)/(x_p4-x_p3)
  จุดตัดเเกนy1=y_p1-ความชัน1*x_p1
  จุดตัดเเกนy2=y_p3-ความชัน2*x_p3
  x=(จุดตัดเเกนy2-จุดตัดเเกนy1)/(ความชัน1-ความชัน2)
  y=ความชัน1*x+จุดตัดเเกนy1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631506121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 636, 'const': 424, 'code+const': 1060}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  value_x = points[::2]
  x1 = value_x[i]
  x2 = value_x[j]
  value_y = points[1::2]
  y1 = value_y[i]
  y2 = value_y[j]
  x = x1
  y = y2
  w = abs(x1-x2)
  h = abs(y1-y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  value_x = points[::2]
  x1 = value_x[i]
  x2 = value_x[j]
  value_y = points[1::2]
  y1 = value_y[i]
  y2 = value_y[j]
  x = (x1+x2)/2
  y = (y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  value_x = points[::2]
  x1 = value_x[i]
  x2 = value_x[j]
  value_y = points[1::2]
  y1 = value_y[i]
  y2 = value_y[j]
  w = abs(x1-x2)
  h = abs(y1-y2)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  value_x = points[::2]
  x1 = value_x[i]
  x2 = value_x[j]
  value_y = points[1::2]
  y1 = value_y[i]
  y2 = value_y[j]
  a = (x1-x2)**2
  b = (y1-y2)**2
  c = a+b
  d = (c)**(1/2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  value_x = points[::2]
  x1 = value_x[p1]
  x2 = value_x[p2]
  x3 = value_x[p3]
  x4 = value_x[p4]
  value_y = points[1::2]
  y1 = value_y[p1]
  y2 = value_y[p2]
  y3 = value_y[p3]
  y4 = value_y[p4]
  m1 = (y1-y2)/(x1-x2)
  m2 = (y3-y4)/(x3-x4)
  c1 = y1-(m1*x1)
  c2 = y3-(m2*x3)
  x = (c2-c1)/(m1-m2)
  y = (m1*x)+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631517021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [15, 26, 511, 1, 11, 16, 4, 5, 67, 12], [51, 62, 115, 4, 11, 16, 5, 7, 76, 12]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 712, 'const': 400, 'code+const': 1112}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    xi = points[2*i]
    yi = points[(2*i)+1]
    xj = points[2*j]
    yj = points[(2*j)+1]
    x = min(xi , xj)
    y = max(yi , yj)
    wide =  min(abs(xi - xj) , abs(yi - yj))
    length = max(abs(xi - xj) , abs(yi - yj))
    return [x , y, wide, length] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi = points[2*i]
    yi = points[(2*i)+1]
    xj = points[2*j]
    yj = points[(2*j)+1]
    Ai = [xi,yi]
    Bi = [xj,yj]
    find_middle = [ (xi+xj)/2 , (yi + yj) / 2 ]
    #print(Ai)
    #print(Bi)
    #print(find_middle)
    return find_middle
    #return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi = points[2*i]
    yi = points[(2*i)+1]
    xj = points[2*j]
    yj = points[(2*j)+1]
    wide =  min(abs(xi - xj) , abs(yi - yj))
    length = max(abs(xi - xj) , abs(yi - yj))
    a = wide * length
    return float(a)# เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi = points[2*i]
    yi = points[(2*i)+1]
    xj = points[2*j]
    yj = points[(2*j)+1]
    d = (((xi-xj)**2)+((yi-yj)**2))**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    xp1 = points[2*p1]
    yp1 = points[(2*p1)+1]
    xp2 = points[2*p2]
    yp2 = points[(2*p2)+1]
    a12 = (yp2 - yp1 ) / (xp2 - xp1)
    xp3 = points[2*p3]
    yp3 = points[(2*p3)+1]
    xp4 = points[2*p4]
    yp4 = points[(2*p4)+1]
    a34 = (yp4 - yp3) / (xp4 - xp3)
    #print(a12 , a34)
    b12 = (yp1 - (a12*xp1)) #p1p2
    b34 = (yp3 - (a34*xp3)) #p3p4
    #print(a12 ,a34)
    #print(b12, b34)
    x = (b12 - b34)/(a34 - a12)
    y = ((b12 * a34) - (b34*a12))/(a34-a12)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631536021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.5
[[4, 4-2, 4-7, 4, 9-2, 9-7, 95, -27, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 678, 'const': 400, 'code+const': 1078}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    x = x1
    y = y2
    w = abs(x2-x1)
    h = abs(y2-y1)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    x = (x1+x2)/2
    y = (y1+y2)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    w = abs(x2-x1)
    h = abs(y2-y1)
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    w = abs(x2-x1)
    h = abs(y2-y1)
    d = math.sqrt((w**2)+(h**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2]
    y1 = points[p1*2+1]
    x2 = points[p2*2]
    y2 = points[p2*2+1]
    x3 = points[p3*2]
    y3 = points[p3*2+1]
    x4 = points[p4*2]
    y4 = points[p4*2+1]
    m1 = (y2-y1)/(x2-x1)
    m2 = (y4-y3)/(x4-x3)
    x = ((m1*x1)-(m2*x3)+y3-y1)/(m1-m2)
    y = ((m2*y1)-(m1*y3)+(m1*m2*x3)-(m2*m1*x1))/(m2-m1)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632220821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area0.6
[5.0, -14.0, 63.25, -2.25, -12.0, 107.25, 24.75, 33.75, -48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 626, 'const': 400, 'code+const': 1026}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x1=points[2*i]
    y1=points[2*i+1]
    x2=points[2*j]
    y2=points[2*j+1]
    x = min(x1,x2)
    y = max(y1,y2)
    w = abs(x1-x2)
    h = abs(y1-y2)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x1=points[2*i]
    y1=points[2*i+1]
    x2=points[2*j]
    y2=points[2*j+1]
    x=(x1+x2)/2
    y=(y1+y2)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x1=points[2*i]
    y1=points[2*i+1]
    x2=points[2*j]
    y2=points[2*j+1]
    a=(x1-x2)*(y1-y2)
    return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1=points[2*i]
    y1=points[2*i+1]
    x2=points[2*j]
    y2=points[2*j+1]
    d=math.sqrt(((x2-x1)**2)+((y2-y1)**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1=points[2*p1]
    y1=points[2*p1+1]
    x2=points[2*p2]
    y2=points[2*p2+1]
    x3=points[2*p3]
    y3=points[2*p3+1]
    x4=points[2*p4]
    y4=points[2*p4+1]
    m1 = (y1-y2)/(x1-x2)
    m2 = (y3-y4)/(x3-x4)
    c1 = y1-x1*m1
    c2 = y3-x3*m2
    x = (c2-c1)/(m1-m2)
    y = m1*x+c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630027721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.75
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 658, 'const': 520, 'code+const': 1178}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    A = points[0::2]
    B = points[1::2]
    x = min(A[i],A[j])
    y = max(B[j],B[j])
    w = abs(A[i]-A[j])
    h = abs(B[i]-B[j])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    A = points[0::2]
    B = points[1::2]
    x = (A[i]+A[j])/2
    y = (B[i]+B[j])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    A = points[0::2]
    B = points[1::2]
    w = abs(A[i]-A[j])
    h = abs(B[i]-B[j])
    a = (w*h)
    return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    A = points[0::2]
    B = points[1::2]
    w = abs(A[i]-A[j])
    h = abs(B[i]-B[j])
    d = math.sqrt((w**2)+(h**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    A = points[0::2]
    B = points[1::2]
    dot1 = [A[p1],B[p1]]
    dot2 = [A[p2],B[p2]]
    dot3 = [A[p3],B[p3]]
    dot4 = [A[p4],B[p4]]
    m1 = (dot1[1]-dot2[1])/(dot1[0]-dot2[0])
    m2 = (dot3[1]-dot4[1])/(dot3[0]-dot4[0])
    x = (dot4[1]-dot2[1]-m2*dot4[0]+m1*dot2[0])/(m1-m2)
    y = (m2*(x-dot4[0]))+dot4[1]
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632237521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame0.75
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, -41, -31, 3, -42, -32, -43, -3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 636, 'const': 400, 'code+const': 1036}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x = min(points[2*i],points[2*j])
  y = max(points[2*j+1],points[2*j+1])
  w=abs(points[2*i]-points[2*j])
  h = abs(points[2*i+1]-points[2*j+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x=(points[2*i]+points[2*j])/2
  y=(points[2*i+1]+points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w=abs(points[2*i]-points[2*j])
  h = abs(points[2*i+1]-points[2*j+1])
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d = ((points[2*i]-points[2*j])**2+(points[2*i+1]-points[2*j+1])**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1=points[2*p1]
  y1=points[2*p1+1]
  x2=points[2*p2]
  y2=points[2*p2+1]
  x3=points[2*p3]
  y3=points[2*p3+1]
  x4=points[2*p4]
  y4=points[2*p4+1]
  m1=(y2-y1)/(x2-x1)
  m2=(y4-y3)/(x4-x3)
  x=(y3-y1+m1*x1-m2*x3)/(m1-m2)
  y=(m1*m2*x3-m1*m2*x1+m2*y1-m1*y3)/(m2-m1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6330070321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 874, 'const': 424, 'code+const': 1298}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x=min(points[2*i],points[2*j])
  y=max(points[2*i+1],points[2*j+1])
  w=max(points[2*i],points[2*j])-min(points[2*i],points[2*j])
  h=max(points[2*i+1],points[2*j+1])-min(points[2*i+1],points[2*j+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x=(points[2*i]+points[2*j])/2
  y=(points[2*i+1]+points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w=max(points[2*i],points[2*j])-min(points[2*i],points[2*j])
  h=max(points[2*i+1],points[2*j+1])-min(points[2*i+1],points[2*j+1])
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  dx = points[2*i]-points[2*j]
  dy = points[2*i+1]-points[2*j+1]
  d = math.sqrt((dx)**2+(dy)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
#x1=point1[0],x2=point2[0],x3=point3[0],x4=point4[0],y1=point1[1],y2=point2[1],y3=point3[1],y4=point4[1]
  point1=[points[2*p1],points[2*p1+1]]
  point2=[points[2*p2],points[2*p2+1]]
  point3=[points[2*p3],points[2*p3+1]]
  point4=[points[2*p4],points[2*p4+1]]
  front=(point1[0]*point2[1]-point1[1]*point2[0])
  back=(point3[0]*point4[1]-point3[1]*point4[0])
  denom=((point1[0]-point2[0])*(point3[1]-point4[1])-(point1[1]-point2[1])*(point3[0]-point4[0]))
  x=(front*(point3[0]-point4[0])-back*(point1[0]-point2[0]))/denom
  y=(front*(point3[1]-point4[1])-back*(point1[1]-point2[1]))/denom
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6330128121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4.0, -2.0, -7.0, 4.0, -2.0, -7.0, 5.0, -7.0, -2.0, -7.0],
 [2.0, 3.0, 1.0, 1.0, 3.0, 2.0, 2.0, 3.0, 3.0, -3.0],
 [5.0, 6.0, 11.0, 1.0, 11.0, 16.0, 4.0, 5.0, 7.0, 12.0],
 [1.0, 2.0, 5.0, 4.0, 1.0, 6.0, 5.0, 7.0, 6.0, 1.0]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 770, 'const': 400, 'code+const': 1170}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    xi=float(points[2*i])
    yi=float(points[(2*i)+1])
    xj=float(points[(2*j)])
    yj=float(points[(2*j)+1])
    x=min(xi,xj)
    y=max(yi,yj)
    wide=abs(xi-xj)
    lenght=abs(yi-yj)
    return [x,y,wide,lenght]
def middle(points,i,j):
    xi=float(points[2*i])
    yi=float(points[(2*i)+1])
    xj=float(points[(2*j)])
    yj=float(points[(2*j)+1])
    x= (xi+xj)/2
    y= (yi+yj)/2
    m= [x]+[y]
    return(m)
def frame_area(points,i,j):
    xi=float(points[2*i])
    yi=float(points[(2*i)+1])
    xj=float(points[(2*j)])
    yj=float(points[(2*j)+1])
    x=min(xi,xj)
    y=max(yi,yj)
    wide=abs(xi-xj)
    lenght=abs(yi-yj)
    area=wide*lenght
    return area
def distance(points,i,j):
    import math
    xi=float(points[2*i])
    yi=float(points[(2*i)+1])
    xj=float(points[(2*j)])
    yj=float(points[(2*j)+1])
    dis= math.sqrt(math.pow(xi-xj,2)+math.pow(yi-yj,2))
    return dis
def intersection(points,p1,p2,p3,p4):
    x1=float(points[2*p1])
    y1=float(points[2*p1+1])
    x2=float(points[2*p2])
    y2=float(points[2*p2+1])
    x3=float(points[2*p3])
    y3=float(points[2*p3+1])
    x4=float(points[2*p4])
    y4=float(points[2*p4+1])
#หาเส้นตรงต่อ
    #เส้นที่1
    m1=(y2-y1)/(x2-x1)
    c1=y1-(m1*x1)
   #เส้นที่2
    m2=(y4-y3)/(x4-x3)
    c2=y4-(m2*x4)
    x=(c2-c1)/(m1-m2)
    y=(m2*x)+c2
    return x, y

6331518421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 744, 'const': 520, 'code+const': 1264}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    a = [points[2*i],points[2*j]]  # x1 x2
    b = [points[2*i+1],points[2*j+1]] # y1 y2
    x = min(a)
    y = max(b)
    w = abs(a[0]-a[1])
    h = abs(b[0]-b[1])
    return [x,y,w,h]
def middle(points,i,j):
    a = [points[2*i],points[2*i+1]] # x1 y1
    b = [points[2*j],points[2*j+1]] # x2  y2
    x = (a[0]+b[0])/2
    y = (a[1]+b[1])/2
    return [x,y]
def frame_area(points,i,j):
    a = [points[2*i],points[2*j]]  # x1 x2
    b = [points[2*i+1],points[2*j+1]] # y1 y2
    w = abs(a[0]-a[1])
    h = abs(b[0]-b[1])
    a = w*h
    return float(a)
def distance(points,i,j):
    a = [points[2*i],points[2*i+1]] # x1 y1
    b = [points[2*j],points[2*j+1]]  # x2 y2
    d = ((a[0]-b[0])**2+(a[1]-b[1])**2)**0.5
    return d
def intersection(points,p1,p2,p3,p4):
    a = [points[2*p1],points[2*p1+1]] # x1 y1
    b = [points[2*p2],points[2*p2+1]]  # x2 y2
    c = [points[2*p3],points[2*p3+1]] # x1 y1
    d = [points[2*p4],points[2*p4+1]]  # x2 y2
    m1 = (b[1]-a[1])/(b[0]-a[0])
    m2 = (d[1]-c[1])/(d[0]-c[0])
    x  = (c[1]-a[1]+a[0]*m1-c[0]*m2)/(m1-m2)
    y  = m1*(x-a[0])+a[1]
    return [x,y]

6530110021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 700, 'const': 424, 'code+const': 1124}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x_i = points[2*i]
  x_j = points[2*j]
  y_i = points[2*i+1]
  y_j = points[2*j+1]
  x_min = min(x_i , x_j)
  x_max = max(x_i , x_j)
  y_min = min(y_i , y_j)
  y_max = max(y_i , y_j)
  x  = x_min
  y = y_max
  w = x_max - x_min
  h = y_max - y_min
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x_i = points[2*i]
  x_j = points[2*j]
  y_i = points[2*i+1]
  y_j = points[2*j+1]
  x =  (x_i+x_j)/2
  y =  (y_i+y_j)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x_i = points[2*i]
  x_j = points[2*j]
  y_i = points[2*i+1]
  y_j = points[2*j+1]
  x_min = min(x_i , x_j)
  x_max = max(x_i , x_j)
  y_min = min(y_i , y_j)
  y_max = max(y_i , y_j)
  w = x_max - x_min
  h = y_max - y_min
  a = (w*h)*1.0
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x_i = points[2*i]
  x_j = points[2*j]
  y_i = points[2*i+1]
  y_j = points[2*j+1]
  x    = abs(x_i - x_j)
  y    = abs (y_i - y_j)
  d   = (x**2 + y**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x_p1 = points[2*p1]
  x_p2 = points[2*p2]
  x_p3 = points[2*p3]
  x_p4 = points[2*p4]
  y_p1 = points[2*p1 +1]
  y_p2 = points[2*p2 +1]
  y_p3 = points[2*p3 +1]
  y_p4 = points[2*p4 +1]
  m_1  = (y_p1 - y_p2)/(x_p1 - x_p2)
  m_2  = (y_p3 - y_p4)/(x_p3 - x_p4)
  c_1  = y_p1 - m_1*x_p1
  c_2  = y_p3 - m_2*x_p3
  x = (c_2 - c_1) / (m_1 - m_2)
  y = m_1 * x + c_1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6530145021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 632, 'const': 400, 'code+const': 1032}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1 = points[i*2]
    y1 = points[(i*2)+1]
    x2 = points[j*2]
    y2 = points[(j*2)+1]
    x = min(x1,x2)
    y = max(y1,y2)
    w = abs(x2-x1)
    h = abs(y2-y1)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x1 = points[i*2]
    y1 = points[(i*2)+1]
    x2 = points[j*2]
    y2 = points[(j*2)+1]
    x = (x1+x2)/2
    y = (y1+y2)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x1 = points[i*2]
    y1 = points[(i*2)+1]
    x2 = points[j*2]
    y2 = points[(j*2)+1]
    w = abs(x2-x1)
    h = abs(y2-y1)
    a = w*h
    return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1 = points[i*2]
    y1 = points[(i*2)+1]
    x2 = points[j*2]
    y2 = points[(j*2)+1]
    x = (x1-x2)
    y = (y1-y2)
    d = ((x**2)+(y**2))**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2]
    y1 = points[(p1*2)+1]
    x2 = points[p2*2]
    y2 = points[(p2*2)+1]
    x3 = points[p3*2]
    y3 = points[(p3*2)+1]
    x4 = points[p4*2]
    y4 = points[(p4*2)+1]
    m1 = (y1-y2)/(x1-x2)
    m2 = (y3-y4)/(x3-x4)
    x = ((x1*m1)-(x3*m2)+y3-y1)/(m1-m2)
    y = (m2*(x-x3))+y3
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6530157521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4.0, -2.0, -7.0, 4.0, -2.0, -7.0, 5.0, -7.0, -2.0, -7.0],
 [2.0, 3.0, 1.0, 1.0, 3.0, 2.0, 2.0, 3.0, 3.0, -3.0],
 [5.0, 6.0, 11.0, 1.0, 11.0, 16.0, 4.0, 5.0, 7.0, 12.0],
 [1.0, 2.0, 5.0, 4.0, 1.0, 6.0, 5.0, 7.0, 6.0, 1.0]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 648, 'const': 400, 'code+const': 1048}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1 = float(points[(i*2)])
    y1 = float(points[(i*2)+1])
    x2 = float(points[(j*2)])
    y2 = float(points[(j*2)+1])
    x = min(x1,x2)
    y = max(y1,y2)
    w = abs(x1-x2)
    h = abs(y2-y1)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x1 = float(points[(i*2)])
    y1 = float(points[(i*2)+1])
    x2 = float(points[(j*2)])
    y2 = float(points[(j*2)+1])
    x = (x1+x2)/2
    y = (y1+y2)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x = frame(points,i,j)
    a = x[2]*x[3]
    return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1 = float(points[(i*2)])
    y1 = float(points[(i*2)+1])
    x2 = float(points[(j*2)])
    y2 = float(points[(j*2)+1])
    d = (((x1-x2)**2)+((y1-y2)**2))**(0.5)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = float(points[(p1*2)])
    y1 = float(points[(p1*2)+1])
    x2 = float(points[(p2*2)])
    y2 = float(points[(p2*2)+1])
    x3 = float(points[p3*2])
    y3 = float(points[(p3*2)+1])
    x4 = float(points[p4*2])
    y4 = float(points[(p4*2)+1])
    m1 = (y2-y1)/(x2-x1)
    m2 = (y4-y3)/(x4-x3)
    x = (x1*m1-x3*m2+y3-y1)/(m1-m2)
    y = m1*(x-x1)+y1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6530334221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 576, 'const': 400, 'code+const': 976}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  listx=points[::2]
  listy=points[1::2]
  x1=listx[i]
  y1=listy[i]
  x2=listx[j]
  y2=listy[j]
  xl=[x1,x2]
  yl=[y1,y2]
  x=min(xl)
  y=max(yl)
  w=abs(x2-x1)
  h=abs(y2-y1)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  listx=points[::2]
  listy=points[1::2]
  x1=listx[i]
  y1=listy[i]
  x2=listx[j]
  y2=listy[j]
  x=(x1+x2)/2
  y=(y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  a=frame(points,i,j)[2]*frame(points,i,j)[3]
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  listx=points[::2]
  listy=points[1::2]
  x1=listx[i]
  y1=listy[i]
  x2=listx[j]
  y2=listy[j]
  d=((x2-x1)**2+(y2-y1)**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  listx=points[::2]
  listy=points[1::2]
  x1=listx[p1]
  y1=listy[p1]
  x2=listx[p2]
  y2=listy[p2]
  x3=listx[p3]
  y3=listy[p3]
  x4=listx[p4]
  y4=listy[p4]
  m1=(y2-y1)/(x2-x1)
  m2=(y4-y3)/(x4-x3)
  x=(m1*x1-y1-m2*x3+y3)/(m1-m2)
  y=m1*(x-x1)+y1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6530427021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 660, 'const': 520, 'code+const': 1180}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    xx = points[0::2]
    yy = points[1::2]
    x = min(xx[i],xx[j])
    y = max(yy[i],yy[j])
    w = abs(xx[j]-xx[i])
    h = abs(yy[j]-yy[i])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xx = points[0::2]
    yy = points[1::2]
    x = (xx[j]+xx[i])/2
    y = (yy[j]+yy[i])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xx = points[0::2]
    yy = points[1::2]
    w = abs(xx[j]-xx[i])
    h = abs(yy[j]-yy[i])
    a = w*h
    return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x = points[0::2]
    y = points[1::2]
    dx = x[i]-x[j]
    dy = y[i]-y[j]
    d = (dx**2+dy**2)**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    xx = points[0::2]
    yy = points[1::2]
    x1 = xx[p1]
    x2 = xx[p2]
    x3 = xx[p3]
    x4 = xx[p4]
    y1 = yy[p1]
    y2 = yy[p2]
    y3 = yy[p3]
    y4 = yy[p4]
    x = ((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
    y = ((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6530433721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 552, 'const': 400, 'code+const': 952}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x = min(points[i*2],points[j*2])
    y = max(points[i*2+1],points[j*2+1])
    w = abs(points[i*2]-points[j*2])
    h = abs(points[i*2+1]-points[j*2+1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x = (points[i*2]+points[j*2])/2
    y = (points[i*2+1]+points[j*2+1])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    n = frame(points,i,j)
    a = n[2]*n[3]
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    n = frame(points,i,j)
    d = ((n[2]**2)+(n[3]**2))**(1/2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    # หาความชัน
    m1 = (points[p1*2+1]-points[p2*2+1])/(points[p1*2]-points[p2*2])
    m2 = (points[p3*2+1]-points[p4*2+1])/(points[p3*2]-points[p4*2])
    # หา c ในสมการเส้นตรง y = mx + c
    c1 = points[p1*2+1]-m1*points[p1*2]
    c2 = points[p3*2+1]-m2*points[p3*2]
    # หาค่า x ที่จุดตัด (x และ y ในทั้งสองสมการเท่ากัน)
    x = (c2-c1)/(m1-m2)
    # แทนค่า x ที่ได้จากขั้นตอนที่แล้วในสมการเส้นตรงเพื่อหาค่า y
    y = m1*x+c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6531001421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 632, 'const': 520, 'code+const': 1152}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xpo = points[0::2]
  ypo = points[1::2]
  w = abs(xpo[i]-xpo[j])#wide
  h = abs(ypo[i]-ypo[j])#height
  x = min(xpo[i],xpo[j])
  y = max(ypo[i],ypo[j])
  #x = xpo[i]#x1
  #y = ypo[j]#y2
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):#จุดกลางX,y
  xpo = points[0::2]
  ypo = points[1::2]
  x = (float(xpo[i])+float(xpo[j]))/2
  y = (float(ypo[i])+float(ypo[j]))/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xpo = points[0::2]
  ypo = points[1::2]
  wf = abs(float(xpo[i])-float(xpo[j]))
  hf = abs(float(ypo[i])-float(ypo[j]))
  a = wf*hf
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xpo = points[0::2]
  ypo = points[1::2]
  xd = abs(xpo[i]-xpo[j])
  yd = abs(ypo[i]-ypo[j])
  d = ((xd**2)+(yd**2))**(0.5)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xpo = points[0::2] #list position x
  ypo = points[1::2] #list position y
  x1,y1 = xpo[p1],ypo[p1]#x1,y1
  x2,y2 = xpo[p2],ypo[p2]#x2,y2
  x3,y3 = xpo[p3],ypo[p3]#x3,y3
  x4,y4 = xpo[p4],ypo[p4]#x4,y4
  m1 = (y2 - y1)/(x2-x1) #slope1
  m2 = (y4 - y3)/((x4-x3)) #slope2
  #y = mx+c
  c1 = y1-m1*x1 #c1 ตัด แกนy
  c2 = y3-m2*x3 #c2 ตัด แกนy
  #y1 = y3
  x = (c2-c1)/(m1-m2) #หา x ตัดกัน
  y = m1*x + c1 #แทนกลับหา y
  return [x,y]
#  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4ompiler (interpreter) to run Python online.
# Write Python 3 code in this online editor and run it.

6531006621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 660, 'const': 400, 'code+const': 1060}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  a=points[::2]
  b=points[1::2]
  w=abs((a[i])-(a[j]))
  h=abs((b[i])-(b[j]))
  x=(min((a[i]),(a[j])))
  y=(max((b[i]),(b[j])))
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  a=points[::2]
  b=points[1::2]
  x=(max((a[i]),(a[j]))+min((a[i]),(a[j])))/2
  y=(max((b[i]),(b[j]))+min((b[i]),(b[j])))/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  a=points[::2]
  b=points[1::2]
  x=abs(max((a[i]),(a[j]))-min((a[i]),(a[j])))
  y=abs(max((b[i]),(b[j]))-min((b[i]),(b[j])))
  a=float(x*y)
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  a=points[::2]
  b=points[1::2]
  w=abs((a[i])-(a[j]))
  h=abs((b[i])-(b[j]))
  d=(w**2+h**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  a=points[::2]
  b=points[1::2]
  m1=(b[p2]-(b[p1]))/(a[p2]-a[p1])
  m2=(b[p4]-(b[p3]))/(a[p4]-a[p3])
  b1=b[p1]-(m1*a[p1])
  b2=b[p3]-(m2*a[p3])
  x = (b2 - b1) / (m1 - m2)
  y = m1 * x + b1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส

6531009521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 680, 'const': 520, 'code+const': 1200}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  s=points[0:len(points):2]
  k=points[1:len(points):2]
  w=abs(s[i]-s[j])
  h=abs(k[i]-k[j])
  x=min(s[i],s[j])
  y=max(k[i],k[j])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  s=points[0:len(points):2]
  k=points[1:len(points):2]
  x=(s[i]+s[j])/2
  y=(k[i]+k[j])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  s=points[0:len(points):2]
  k=points[1:len(points):2]
  w=abs(s[i]-s[j])
  h=abs(k[i]-k[j])
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  s=points[0:len(points):2]
  k=points[1:len(points):2]
  x=s[i]-s[j]
  y=k[i]-k[j]
  d=(x**2+y**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  s=points[0:len(points):2]
  k=points[1:len(points):2]
  o=[s[p1],k[p1],s[p2],k[p2],s[p3],k[p3],s[p4],k[p4]]
  dy1=k[p1]-k[p2]
  dx1=s[p1]-s[p2]
  m1=dy1/dx1
  dy2=k[p3]-k[p4]
  dx2=s[p3]-s[p4]
  m2=dy2/dx2
  c1=k[p1]-(m1*s[p1])
  c2=k[p3]-(m2*s[p3])
  x=(c2-c1)/(m1-m2)
  y=m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6531025521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 660, 'const': 344, 'code+const': 1004}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  a = min(points[2*i],points[2*j])
  b = min(points[2*i+1],points[2*j+1])
  c = max(points[2*i],points[2*j])
  d = max(points[2*i+1],points[2*j+1])
  w = c-a
  h = d-b
  x = a
  y = b + h
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = float((points[2*i] + points[2*j])/2)
  y = float((points[2*i+1] + points[2*j+1])/2)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x,y,w,h = frame(points,i,j)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  import math
  x,y,w,h = frame(points,i,j)
  d = math.sqrt(((w)**2)+((h)**2))
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = float(points[2*p1])
  y1 = float(points[2*p1+1])
  x2 = float(points[2*p2])
  y2 = float(points[2*p2+1])
  x3 = float(points[2*p3])
  y3 = float(points[2*p3+1])
  x4 = float(points[2*p4])
  y4 = float(points[2*p4+1])
  a1 = y2 - y1
  b1 = x1 - x2
  c1 = a1*(x1) + b1*(y1)
  a2 = y4 - y3
  b2 = x3 - x4
  c2 = a2*(x3) + b2*(y3)
  determinant = a1*b2 - a2*b1
  x = (b2*c1 - b1*c2)/determinant
  y = (a1*c2 - a2*c1)/determinant
  return [x,round(y,15)] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6531502521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 612, 'const': 344, 'code+const': 956}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = points[i*2]
  yi = points[i*2+1]
  xj = points[j*2]
  yj = points[j*2+1]
  w = abs(xj - xi)
  h = abs(yj - yi)
  x = min(xi, xj)
  y = max(yi, yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[i*2]
  yi = points[i*2+1]
  xj = points[j*2]
  yj = points[j*2+1]
  dx = xi + xj
  dy = yi + yj
  [x,y] = [float(dx/2),float(dy/2)]
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  [x,y,w,h] = frame(points,i,j)
  a = float(w*h)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[i*2]
  yi = points[i*2+1]
  xj = points[j*2]
  yj = points[j*2+1]
  d = float(((xi-xj)**2+(yi-yj)**2)**0.5)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xp1 = points[p1*2]
  yp1 = points[p1*2+1]
  xp2 = points[p2*2]
  yp2 = points[p2*2+1]
  xp3 = points[p3*2]
  yp3 = points[p3*2+1]
  xp4 = points[p4*2]
  yp4 = points[p4*2+1]
  m1 = (yp1-yp2)/(xp1-xp2)
  m2 = (yp3-yp4)/(xp3-xp4)
  c1 = yp1 - m1*xp1
  c2 = yp3 - m2*xp3
  x = float((c1 - c2)/(m2 - m1))
  y = float(m1*x + c1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6531503121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4.0, -2.0, -7.0, 4.0, -2.0, -7.0, 5.0, -7.0, -2.0, -7.0],
 [2.0, 3.0, 1.0, 1.0, 3.0, 2.0, 2.0, 3.0, 3.0, -3.0],
 [5.0, 6.0, 11.0, 1.0, 11.0, 16.0, 4.0, 5.0, 7.0, 12.0],
 [1.0, 2.0, 5.0, 4.0, 1.0, 6.0, 5.0, 7.0, 6.0, 1.0]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 636, 'const': 520, 'code+const': 1156}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  p=points[0:len(points):2]
  n=points[1:len(points):2]
  x= float(min(p[i],p[j]))
  y= float(max(n[i],n[j]))
  w= float(abs(p[j]-p[i]))
  h= float(abs(n[j]-n[i]))
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  p=points[0:len(points):2]
  n=points[1:len(points):2]
  x= float((p[i]+p[j])/2)
  y= float((n[i]+n[j])/2)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  p=points[0:len(points):2]
  n=points[1:len(points):2]
  w= abs(p[j]-p[i])
  h= abs(n[j]-n[i])
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  p=points[0:len(points):2]
  n=points[1:len(points):2]
  d=(((p[i]-p[j])**2)+((n[i]-n[j])**2))**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  p=points[0:len(points):2]
  n=points[1:len(points):2]
  m1= (n[p2]-n[p1])/(p[p2]-p[p1])
  m2= (n[p4]-n[p3])/(p[p4]-p[p3])
  c1=n[p1]-(m1*p[p1])
  c2=n[p3]-(m2*p[p3])
  x=float((c2-c1)/(m1-m2))
  y=float((m1*x)+c1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6531505421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 844, 'const': 544, 'code+const': 1388}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x= points[0::2]
  y = points[1::2]
  frame1 = [x[i]] + [y[i]]
  frame2 = [x[j]] + [y[j]]
  a = min(frame1[0],frame2[0])
  b = max(frame1[1],frame2[1])
  c = abs(frame1[0]-frame2[0])
  d = abs(frame1[1]-frame2[1])
  e  = [a,b,c,d]
  return [a,b,c,d] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x= points[0::2]
  y = points[1::2]
  middle1 = [x[i]] + [y[i]]
  middle2 = [x[j]] + [y[j]]
  a = float((middle1[0]+middle2[0])/2)
  b = float((middle1[1]+middle2[1])/2)
  return [a,b] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x= points[0::2]
  y = points[1::2]
  frame1 = [x[i]] + [y[i]]
  frame2 = [x[j]] + [y[j]]
  c = abs(frame1[0]-frame2[0])
  d = abs(frame1[1]-frame2[1])
  a = abs(c*d)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x= points[0::2]
  y = points[1::2]
  distance1 = [x[i]] + [y[i]]
  distance2 = [x[j]] + [y[j]]
  d = (abs((distance1[0]-distance2[0])**2)+abs((distance1[1]-distance2[1]))**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x= points[0::2]
  y = points[1::2]
  a = [x[p1]] + [y[p1]]
  b = [x[p2]] + [y[p2]]
  c = [x[p3]] + [y[p3]]
  d = [x[p4]] + [y[p4]]
  m1 = (b[1]-a[1])/(b[0]-a[0])
  m2 = (d[1]-c[1])/(d[0]-c[0])
  c1 = (a[1]-(m1*(a[0])))
  c2 = (c[1]-(m2*(c[0])))
  realx = (c2-c1)/(m1-m2)
  realy = (realx*m1)+c1
  return [realx,realy] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6531519221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 660, 'const': 368, 'code+const': 1028}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: [[('If', 30)]]
def middle(points, i, j):
    x0, y0 = points[2*i], points[2*i+1]
    x1, y1 = points[2*j], points[2*j+1]
    x = (x0 + x1) / 2
    y = (y0 + y1) / 2
    return [x,y]
def frame(points, i, j):
    x0, y0 = points[2*i], points[2*i+1]
    x1, y1 = points[2*j], points[2*j+1]
    x = min(x0, x1)
    y = max(y0, y1)
    w = abs(x0 - x1)
    h = abs(y0 - y1)
    return [x,y,w,h]
def frame_area(points, i, j):
    x,y,w,h = frame(points, i, j)
    a = w*h
    return float(a)
def distance(points, i, j):
    x0, y0 = points[2*i], points[2*i+1]
    x1, y1 = points[2*j], points[2*j+1]
    d = ((x1 - x0)**2 + (y1 - y0)**2)**0.5
    return d
def intersection(points, p1, p2, p3, p4):
    x1, y1 = points[2*p1], points[2*p1+1]
    x2, y2 = points[2*p2], points[2*p2+1]
    x3, y3 = points[2*p3], points[2*p3+1]
    x4, y4 = points[2*p4], points[2*p4+1]
    denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)
    if denominator == 0:
        return None
    x = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / denominator
    y = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / denominator
    return [x,y]

6531523721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 662, 'const': 344, 'code+const': 1006}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x0, y0 = points[i * 2], points[i * 2 + 1]
  x1, y1 = points[j * 2], points[j * 2 + 1]
  x = min(x0, x1)
  y = max(y0, y1)
  w = abs(x1 - x0)
  h = abs(y1 - y0)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x0, y0, x1, y1 = points[i * 2], points[i * 2 + 1], points[j * 2], points[j * 2 + 1]
  x = (x0 + x1) / 2
  y = (y0 + y1) / 2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  left, top, width, height = frame(points, i, j)
  a = width * height
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x0, y0, x1, y1 = points[i * 2], points[i * 2 + 1], points[j * 2], points[j * 2 + 1]
  d = math.sqrt((x1 - x0)**2 + (y1 - y0)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points, p1, p2, p3, p4):
  x1, y1 = points[p1 * 2], points[p1 * 2 + 1]
  x2, y2 = points[p2 * 2], points[p2 * 2 + 1]
  x3, y3 = points[p3 * 2], points[p3 * 2 + 1]
  x4, y4 = points[p4 * 2], points[p4 * 2 + 1]
  denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)
  x = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / denominator
  y = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / denominator
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6532030821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 656, 'const': 400, 'code+const': 1056}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  w = abs(points[2*j] - points[2*i])
  h = abs(points[2*i+1] - points[2*j+1])
  x = min(points[2*j], points[2*i])
  y = max(points[2*i+1], points[2*j+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1,x2 = points[2*j], points[2*i]
  y1,y2 = points[2*i+1], points[2*j+1]
  x = (x1+x2)/2
  y = (y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs(points[2*j] - points[2*i])
  h = abs(points[2*i+1] - points[2*j+1])
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1,x2 = points[2*j], points[2*i]
  y1,y2 = points[2*i+1], points[2*j+1]
  d = ((x1-x2)**2 + (y1-y2)**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,x2,x3,x4 = points[2*p1], points[2*p2], points[2*p3], points[2*p4]
  y1,y2,y3,y4 = points[2*p1+1], points[2*p2+1], points[2*p3+1], points[2*p4+1]
  slope1 = (y2-y1)/(x2-x1)
  slope2 = (y3-y4)/(x3-x4)
  inter1 = y1-slope1*x1
  inter2 = y3-slope2*x3
  x = (inter1-inter2)/(slope2-slope1)
  y = slope1*x + inter1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6532075021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 580, 'const': 344, 'code+const': 924}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x = min(points[i+i], points[j+j])
  max_x = max(points[i+i], points[j+j])
  y = max(points[i+i+1], points[j+j+1])
  miny = min(points[i+i+1], points[j+j+1])
  w = max_x - x
  h = y - miny
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[i+i]+points[j+j])/2
  y = (points[i+i+1]+points[j+j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  b = frame(points,i,j)
  a = b[2]*b[3]
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d = ((points[i+i]-points[j+j])**2+(points[i+i+1]-points[j+j+1])**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xc = points[p1+p1]
  xd = points[p2+p2]
  xa = points[p3+p3]
  xb = points[p4+p4]
  yc = points[p1+p1+1]
  yd = points[p2+p2+1]
  ya = points[p3+p3+1]
  yb = points[p4+p4+1]
  m_1 = (yc-yd) / (xc-xd)
  m_2 = (ya-yb) / (xa-xb)
  b1 = yc - (m_1*xc)
  b2 = ya - (m_2*xa)
  m1 = (b1-b2) / (m_2-m_1)
  m2 = (m_1*m1)+b1
  return [m1,m2]
  #return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6532098521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 636, 'const': 400, 'code+const': 1036}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x = min(points[2*i],points[2*j])
    y = max(points[2*i+1],points[2*j+1])
    w = abs(points[2*i]-points[2*j])
    h = abs(points[2*i+1]-points[2*j+1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x= (points[2*i]+points[2*j])/2
    y= (points[2*i+1]+points[2*j+1])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    w = frame(points,i,j)[2]
    h = frame(points,i,j)[3]
    a = w*h
    return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x = frame(points,i,j)
    d = (x[2]**2+x[3]**2)**(1/2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1,y1= points[2*p1],points[2*p1+1]
    x2,y2= points[2*p2],points[2*p2+1]
    x3,y3= points[2*p3],points[2*p3+1]
    x4,y4= points[2*p4],points[2*p4+1]
    x = ((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
    y = ((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630001321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 584, 'const': 400, 'code+const': 984}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  return [min(points[i*2],points[j*2]),max(points[i*2+1],points[j*2+1]),abs(points[i*2]-points[j*2]),abs(points[i*2+1]-points[j*2+1])] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  return [(points[i*2]+points[j*2])/2,(points[i*2+1]+points[j*2+1])/2] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  a=abs(points[i*2]-points[j*2])*abs(points[i*2+1]-points[j*2+1])
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d=((points[i*2]-points[j*2])**2+(points[i*2+1]-points[j*2+1])**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  m1=(points[p1*2+1]-points[p2*2+1])/(points[p1*2]-points[p2*2])
  m2=(points[p3*2+1]-points[p4*2+1])/(points[p3*2]-points[p4*2])
  c1=points[p1*2+1]-m1*points[p1*2]
  c2=points[p3*2+1]-m2*points[p3*2]
  x=(c2-c1)/(m1-m2)
  y=m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630002021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 642, 'const': 400, 'code+const': 1042}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x = min(points[i*2],points[j*2])
  y = max(points[(i*2)+1],points[j*2+1])
  w = abs(points[i*2]-points[j*2])
  h = abs(points[i*2+1]-points[j*2+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[i*2]+points[j*2])/2
  y = (points[(i*2)+1]+points[(j*2)+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs(points[j*2]-points[i*2])
  h = abs(points[j*2+1]-points[i*2+1])
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d = math.sqrt((points[i*2]-points[j*2])**2+(points[i*2+1]-points[j*2+1])**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  m_1 = (points[p2*2+1]-points[p1*2+1])/(points[p2*2]-points[p1*2])
  m_2 = (points[p4*2+1]-points[p3*2+1])/(points[p4*2]-points[p3*2])
  c_1 = points[p1*2+1]-m_1*points[p1*2]
  c_2 = points[p3*2+1]-m_2*points[p3*2]
  x = (c_2-c_1)/(m_1-m_2)
  y = (m_2*c_1-m_1*c_2)/(m_2-m_1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630004221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 730, 'const': 400, 'code+const': 1130}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    #define points
    xi = points[2*i]
    yi = points[(2*i)+1]
    xj = points[2*j]
    yj = points[(2*j)+1]
    #x
    xl = [xi, xj]
    x= min(xl)
    #y
    yl = [yi, yj]
    y = max(yl)
    #w
    w = abs(xi - xj)
    #h
    h = abs(yi - yj)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    #define point
      xi = points[2*i]
      yi = points[(2*i)+1]
      xj = points[2*j]
      yj = points[(2*j)+1]
    #find middle
      x = (xi+xj)/2
      y = (yi+yj)/2
      return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    #define points
    xi = points[2*i]
    yi = points[(2*i)+1]
    xj = points[2*j]
    yj = points[(2*j)+1]
    #w
    w = abs(xi - xj)
    #h
    h = abs(yi - yj)
    #a
    a = w*h
    return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    #define points
    xi = points[2*i]
    yi = points[(2*i)+1]
    xj = points[2*j]
    yj = points[(2*j)+1]
    #d
    d = math.sqrt(math.pow((xi - xj), 2) + math.pow((yi - yj), 2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    #define points of line 1
        #p1
    x1 = points[p1*2]
    y1 = points[(p1*2)+1]
        #p2
    x2 = points[p2*2]
    y2 = points[(p2*2)+1]
    #define points of line 2
        #p3
    x3 = points[p3*2]
    y3 = points[(p3*2)+1]
        #p4
    x4 = points[p4*2]
    y4 = points[(p4*2)+1]
    #define line 1
    slope1 = (y2-y1)/(x2-x1)
    const1 = y1-(slope1*x1)     #รูปทั่วไป; -mx+y-c = 0
    a1 = -slope1
    b1 = 1
    c1 = -const1
    #define line 2
    slope2 = (y4-y3)/(x4-x3)
    const2 = y3-(slope2*x3)     #รูปทั่วไป; -mx+y-c = 0
    a2 = -slope2
    b2 = 1
    c2 = -const2
    #หาจุดตัด
    x = ((b1*c2)-(b2*c1))/((a1*b2)-(a2*b1))
    y= ((a2*c1)-(a1*c2))/((a1*b2)-(a2*b1))
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630006521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 800, 'const': 520, 'code+const': 1320}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    a = points[2*i:2*i+2]
    b = points[2*j:2*j+2]
    return [min(a[0], b[0]), max(a[1], b[1]), abs(a[0] - b[0]), abs(a[1] - b[1])]
def middle(points,i,j):
    a = points[2*i:2*i+2]
    b = points[2*j:2*j+2]
    return [((int(a[0]) + int(b[0]))/2), ((int(a[1]) + int(b[1]))/2)]
def frame_area(points,i,j):
    a = points[2*i:2*i+2]
    b = points[2*j:2*j+2]
    return abs(a[0] - b[0])*abs(a[1] - b[1])
def distance(points,i,j):
    a = points[2*i:2*i+2]
    b = points[2*j:2*j+2]
    return ((a[0] - b[0])**2 + (a[1] - b[1])**2)**(1/2)
def intersection(points,p1,p2,p3,p4):
    a = points[2*p1:2*p1+2]
    b = points[2*p2:2*p2+2]
    c = points[2*p3:2*p3+2]
    d = points[2*p4:2*p4+2]
    eq1 = (a[1] - b[1], -(a[0] - b[0]), a[0]*b[1] - b[0]*a[1])
    eq2 = (c[1] - d[1], -(c[0] - d[0]), c[0]*d[1] - d[0]*c[1])
    return [(eq1[1]*eq2[2] - eq2[1]*eq1[2])/(eq1[0]*eq2[1] - eq2[0]*eq1[1]),      (eq2[0]*eq1[2] - eq1[0]*eq2[2])/(eq1[0]*eq2[1] - eq2[0]*eq1[1])]

6630007121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 718, 'const': 400, 'code+const': 1118}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
   xi = points[i*2]
   xj = points[j*2]
   yi = points[(i*2)+1]
   yj = points[(j*2)+1]
   x = min(xi,xj)
   y = max(yi,yj)
   w = max(xi,xj)-x
   h = y-min(yi,yj)
   return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
   xi = points[i*2]
   xj = points[j*2]
   yi = points[(i*2)+1]
   yj = points[(j*2)+1]
   x = (xi+xj)/2
   y = (yi+yj)/2
   return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi = points[i*2]
    xj = points[j*2]
    yi = points[(i*2)+1]
    yj = points[(j*2)+1]
    x = min(xi,xj)
    y = max(yi,yj)
    w = max(xi,xj)-x
    h = y-min(yi,yj)
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi = points[i*2]
    xj = points[j*2]
    yi = points[(i*2)+1]
    yj = points[(j*2)+1]
    b1 = (xj-xi)**2
    b2 = (yj-yi)**2
    d = math.sqrt(b1+b2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2]
    x2 = points[p2*2]
    x3 = points[p3*2]
    x4 = points[p4*2]
    y1 = points[(p1*2)+1]
    y2 = points[(p2*2)+1]
    y3 = points[(p3*2)+1]
    y4 = points[(p4*2)+1]
    den = ((x1-x2)*(y3-y4))-((y1-y2)*(x3-x4))
    nu1 = (x1*y2)-(y1*x2)
    nu2 = (x3*y4)-(y3*x4)
    x = ((nu1*(x3-x4))-(nu2*(x1-x2)))/den
    y = ((nu1*(y3-y4))-(nu2*(y1-y2)))/den
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630008821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 540, 'const': 344, 'code+const': 884}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  a_1,b_1 = points[i*2:(i+1)*2]
  a_2,b_2 = points[j*2:(j+1)*2]
  return [min(a_1,a_2),max(b_1,b_2),abs(a_1-a_2),abs(b_1-b_2)]
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  a_1,b_1 = points[i*2:(i+1)*2]
  a_2,b_2 = points[j*2:(j+1)*2]
  return [(a_1+a_2)/2,(b_1+b_2)/2]
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x,y,w,h = frame(points,i,j)
  return w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  a_1,b_1 = points[i*2:(i+1)*2]
  a_2,b_2 = points[j*2:(j+1)*2]
  return ((a_1-a_2)**2+(b_1-b_2)**2)**(1/2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  a_1,b_1  = points[p1*2:(p1+1)*2]
  a_2,b_2  = points[p2*2:(p2+1)*2]
  a_3,b_3  = points[p3*2:(p3+1)*2]
  a_4,b_4  = points[p4*2:(p4+1)*2]
  m_1      = (b_2-b_1)/(a_2-a_1)
  c_1      = b_1-m_1*a_1
  m_2      = (b_4-b_3)/(a_4-a_3)
  c_2      = b_3-m_2*a_3
  x        = (c_2-c_1)/(m_1-m_2)
  y        = m_1*x+c_1
  return [x,y]
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630013921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 644, 'const': 400, 'code+const': 1044}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = min(xi,xj)
  y = max(yi,yj)
  w = abs(xi-xj)
  h = abs(yi-yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = (xj+xi)/2
  y = (yj+yi)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  a = abs(xi-xj)*abs(yi-yj)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  d = (((abs(xi-xj)**2)+(abs(yi-yj)**2))**0.5)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xp1 = points[2*p1]
  yp1 = points[2*p1+1]
  xp2 = points[2*p2]
  yp2 = points[2*p2+1]
  xp3 = points[2*p3]
  yp3 = points[2*p3+1]
  xp4 = points[2*p4]
  yp4 = points[2*p4+1]
  m1 = (yp2-yp1)/(xp2-xp1)
  m2 = (yp4-yp3)/(xp4-xp3)
  c1 = yp1-(m1*xp1)
  c2 = yp3-(m2*xp3)
  x = (c2-c1)/(m1-m2)
  y = ((m2*c1)-(m1*c2))/(m2-m1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630015121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 786, 'const': 400, 'code+const': 1186}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    xi,yi = points[2*i],points[2*i+1]
    xj,yj = points[2*j],points[2*j+1]
    x = min(xi,xj)
    x_max = max(xi,xj)
    y_min = min(yi,yj)
    y = max(yi,yj)
    w = x_max-x
    h = y-y_min
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi,yi = points[2*i],points[2*i+1]
    xj,yj = points[2*j],points[2*j+1]
    x = (xi+xj)/2
    y = (yi+yj)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi, yi = points[2*i], points[2*i+1]
    xj, yj = points[2*j], points[2*j+1]
    x_min = min(xi, xj)
    x_max = max(xi, xj)
    y_min = min(yi, yj)
    y_max = max(yi, yj)
    w = x_max - x_min
    h = y_max - y_min
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi, yi = points[2*i], points[2*i+1]
    xj, yj = points[2*j], points[2*j+1]
    import math
    d = math.sqrt((xi-xj)**2 + (yi-yj)**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1,y1 = points[2*p1],points[2*p1+1]
    x2,y2 = points[2*p2],points[2*p2+1]
    x3,y3 = points[2*p3],points[2*p3+1]
    x4,y4 = points[2*p4],points[2*p4+1]
    x = ((x1*y2-x2*y1)*(x3-x4)-(x1-x2)*(x3*y4-x4*y3))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
    y = ((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-x4*y3))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630016821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 652, 'const': 424, 'code+const': 1076}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x = min(points[2*i],points[2*j])
  y = max(points[2*j+1],points[2*i+1])
  w = abs(points[2*i] - points[2*j])
  h = abs(points[2*i+1] - points[2*j+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[2*i] + points[2*j])/2
  y = (points[2*i+1] + points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs(points[2*i] - points[2*j])
  h = abs(points[2*i+1] - points[2*j+1])
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x = (abs(points[2*i] - points[2*j]))**2
  y = (abs(points[2*i+1] - points[2*j+1]))**2
  d = (x+y)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  m1 = (points[2*p1+1] - points[2*p2+1])/(points[2*p1] - points[2*p2])
  m2 = (points[2*p3+1] - points[2*p4+1])/(points[2*p3] - points[2*p4])
  c1 = points[2*p1+1]-m1*points[2*p1]
  c2 = points[2*p3+1]-m2*points[2*p3]
  x = (c1-c2)/(m2-m1)
  y = (m2*c1-m1*c2)/(m2-m1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630017421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 628, 'const': 400, 'code+const': 1028}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def middle(points,i,j):
    x1=points[2*i]
    y1=points[(2*i)+1]
    x2=points[2*j]
    y2=points[(2*j)+1]
    x=(x1+x2)/2
    y=(y1+y2)/2
    return [x,y]
def frame(points,i,j):
      x1=points[2*i]
      y1=points[(2*i)+1]
      x2=points[2*j]
      y2=points[(2*j)+1]
      w=abs(x2-x1)
      h=abs(y2-y1)
      x=min(x1,x2)
      y=max(y1,y2)
      return [x,y,w,h]
def frame_area(points,i,j):
      x1=points[2*i]
      y1=points[(2*i)+1]
      x2=points[2*j]
      y2=points[(2*j)+1]
      w=abs(x2-x1)
      h=abs(y2-y1)
      a=w*h
      return float(a)
def distance(points,i,j):
    x1=points[2*i]
    y1=points[(2*i)+1]
    x2=points[2*j]
    y2=points[(2*j)+1]
    d=((x1-x2)**2+(y1-y2)**2)**0.5
    return d
def intersection(points,p1,p2,p3,p4):
    x1=points[2*p1]
    y1=points[(2*p1)+1]
    x2=points[2*p2]
    y2=points[(2*p2)+1]
    x3=points[2*p3]
    y3=points[(2*p3)+1]
    x4=points[2*p4]
    y4=points[(2*p4)+1]
    mp12=(y2-y1)/(x2-x1)
    mp34=(y4-y3)/(x4-x3)
    x=((mp12*x1-mp34*x3)+(y3-y1))/(mp12-mp34)
    y=mp12*(x-x1)+y1
    return [x,y]

6630021921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 642, 'const': 400, 'code+const': 1042}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  x = min(x1,x2)
  y = max(y1,y2)
  w = abs(x2-x1)
  h = abs(y2-y1)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  x  = (x1+x2)/2
  y  = (y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  w = abs(x2-x1)
  h = abs(y2-y1)
  area = w*h
  return area # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  d = math.sqrt((x1-x2)**2+(y1-y2)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[2*p1]
  y1 = points[2*p1+1]
  x2 = points[2*p2]
  y2 = points[2*p2+1]
  x3 = points[2*p3]
  y3 = points[2*p3+1]
  x4 = points[2*p4]
  y4 = points[2*p4+1]
  m1 = (y2-y1)/(x2-x1)
  m2 = (y4-y3)/(x4-x3)
  x  = (m1*x1-m2*x3+y3-y1)/(m1-m2)
  y  = m1*x-m1*x1+y1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630022521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 642, 'const': 400, 'code+const': 1042}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x0=points[2*i]
  y0=points[(2*i)+1]
  x1=points[2*j]
  y1=points[(2*j)+1]
  w=abs(x1-x0)
  h=abs(y1-y0)
  return [min(x0,x1),max(y0,y1),w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x0=points[2*i]
  y0=points[(2*i)+1]
  x1=points[2*j]
  y1=points[(2*j)+1]
  return [(x0+x1)/2,(y0+y1)/2] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x0=points[2*i] ; y0=points[(2*i)+1]
  x1=points[2*j] ; y1=points[(2*j)+1]
  w=abs(x1-x0)
  h=abs(y1-y0)
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x0=points[2*i]
  y0=points[(2*i)+1]
  x1=points[2*j]
  y1=points[(2*j)+1]
  d =math.sqrt((x1-x0)**2 + (y1-y0)**2)
  return float(d) # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1=points[2*p1] ; y1=points[(2*p1)+1]
  x2=points[2*p2] ; y2=points[(2*p2)+1]
  x3=points[2*p3] ; y3=points[(2*p3)+1]
  x4=points[2*p4] ; y4=points[(2*p4)+1]
  m1=float((y2-y1)/(x2-x1)) #m1คือความชันเส้นที่หนึ่ง
  m2=float((y4-y3)/(x4-x3)) #m2 คือความชันของเส้นที่สอง
  #Y = MX + C คือสมการเส้นตรง
  c1 = y1 - (m1*x1) #มาจากy1 = m1*x1 + c1
  c2 = y3 - (m2*x3) #มาจากy3 = m2*x3 + c2
  x = (c2-c1)/(m1-m2)#จุดตัดคือมีค่าx,yเท่ากันดังนั้น m1*x+c1 = m2*x+c2
  y = (m1*x) + c1 #แทนค่าxที่หาได้ในสมการ เพื่อหาy
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630028321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 584, 'const': 424, 'code+const': 1008}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x1 = points[2*i]
    y1 = points[2*i+1]
    x2 = points[2*j]
    y2 = points[2*j+1]
    x = min(x1,x2)
    y = max(y1,y2)
    w = abs(x1-x2)
    h = abs(y1-y2)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x1 = points[2*i]
    y1 = points[2*i+1]
    x2 = points[2*j]
    y2 = points[2*j+1]
    x=((x1+x2)/2)
    y=((y1+y2)/2)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    p = frame(points,i,j)
    a = p[2]*p[3]
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1 = points[2*i]
    y1 = points[2*i+1]
    x2 = points[2*j]
    y2 = points[2*j+1]
    d = (((x1-x2)**2)+((y1-y2)**2))**(0.5)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    xp1 = points[2*p1]
    yp1 = points[2*p1+1]
    xp2 = points[2*p2]
    yp2 = points[2*p2+1]
    xp3 = points[2*p3]
    yp3 = points[2*p3+1]
    xp4 = points[2*p4]
    yp4 = points[2*p4+1]
    m1=(yp1-yp2)/(xp1-xp2)
    m2=(yp3-yp4)/(xp3-xp4)
    c1=yp1-m1*xp1
    c2=yp3-m2*xp3
    x=(c2-c1)/(m1-m2)
    y=m1*x+c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630030521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 650, 'const': 400, 'code+const': 1050}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  A = points[i*2]
  B = points[i*2+1]
  C = points[j*2]
  D = points[j*2+1]
  x = min(A,C)
  y = max(B,D)
  w = abs(A-C)
  h = abs(B-D)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  A = points[i*2]
  B = points[i*2+1]
  C = points[j*2]
  D = points[2*j+1]
  x = ((A+C)/2)
  y = ((B+D)/2)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  A = points[i*2]
  B = points[i*2+1]
  C = points[j*2]
  D = points[j*2+1]
  w = abs(A-C)
  h = abs(B-D)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  A = points[i*2]
  B = points[i*2+1]
  C = points[j*2]
  D = points[j*2+1]
  E = ((A-C)**2+(B-D)**2)
  d = math.sqrt(E)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  A = points[p1*2]
  B = points[p1*2+1]
  C = points[p2*2]
  D = points[p2*2+1]
  E = points[p3*2]
  F = points[p3*2+1]
  G = points[p4*2]
  H = points[p4*2+1]
  m1 = (B-D)/(A-C)
  m2 = (H-F)/(G-E)
  x = (m2*E-m1*A+B-F)/(m2-m1)
  y = m2*x-m2*E+F
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630032821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 620, 'const': 450, 'code+const': 1070}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x=min(points[i*2],points[j*2])
  y=max(points[i*2+1],points[j*2+1])
  w=abs(points[i*2]-points[j*2])
  h=abs(points[i*2+1]-points[j*2+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x=(points[i*2]+points[j*2])/2
  y=(points[i*2+1]+points[j*2+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  a=abs(points[i*2]-points[j*2])*abs(points[i*2+1]-points[j*2+1])
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d=((points[i*2]-points[j*2])**2 + (points[i*2+1]-points[j*2+1])**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  a=points[p1*2]
  b=points[p2*2]
  c=points[p3*2]
  d=points[p4*2]
  e=points[p1*2+1]
  f=points[p2*2+1]
  g=points[p3*2+1]
  h=points[p4*2+1]
  m1=(e-f)/(a-b)
  m2=(g-h)/(c-d)
  k=e-(m1*a)
  l=g-(m2*c)
  x=(l-k)/(m1-m2)
  y=(m1*x)+k
  z=(str(x))+ ' ' +str(y)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630034021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4.0, -2.0, -7.0, 4.0, -2.0, -7.0, 5.0, -7.0, -2.0, -7.0],
 [2.0, 3.0, 1.0, 1.0, 3.0, 2.0, 2.0, 3.0, 3.0, -3.0],
 [5.0, 6.0, 11.0, 1.0, 11.0, 16.0, 4.0, 5.0, 7.0, 12.0],
 [1.0, 2.0, 5.0, 4.0, 1.0, 6.0, 5.0, 7.0, 6.0, 1.0]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 772, 'const': 400, 'code+const': 1172}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    xi = float(points[i*2]) ; yi = float(points[i*2+1])
    xj = float(points[j*2]) ; yj = float(points[j*2+1])
    x = min(xi,xj)
    y = max(yi,yj)
    w = abs(xi-xj)
    h = abs(yi-yj)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi = float(points[i*2]) ; yi = float(points[i*2+1])
    xj = float(points[j*2]) ; yj = float(points[j*2+1])
    x = (xi+xj)/2
    y = (yi+yj)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi = float(points[i*2]) ; yi = float(points[i*2+1])
    xj = float(points[j*2]) ; yj = float(points[j*2+1])
    w = abs(xi-xj)
    h = abs(yi-yj)
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi = float(points[i*2]) ; yi = float(points[i*2+1])
    xj = float(points[j*2]) ; yj = float(points[j*2+1])
    d = math.sqrt(((xi-xj)**2)+((yi-yj)**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = float(points[p1*2]) ; y1 = float(points[p1*2+1])
    x2 = float(points[p2*2]) ; y2 = float(points[p2*2+1])
    x3 = float(points[p3*2]) ; y3 = float(points[p3*2+1])
    x4 = float(points[p4*2]) ; y4 = float(points[p4*2+1])
    m1 = (y2-y1)/(x2-x1)
    m2 = (y3-y4)/(x3-x4)
    x = (-y1+y3+(m1*x1)-(m2*x3))/(m1-m2)
    y = ((m1*x)+(m2*x)+((-m1*x1)-(m2*x3))-(-y1-y3))/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630036321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 642, 'const': 400, 'code+const': 1042}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x0 = points[2*i]
    y0 = points[2*i+1]
    x1 = points[2*j]
    y1 = points[2*j+1]
    x = min(x0,x1)
    y = max(y0,y1)
    w = abs(x1-x0)
    h = abs(y1-y0)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x0 = points[2*i]
    y0 = points[2*i+1]
    x1 = points[2*j]
    y1 = points[2*j+1]
    # จุดกึ่งกลางหาจากการหารผลบวกพิกัด x ด้วย 2 และการหารผลบวกพิกัด y ด้วย 2
    x = (x0+x1)/2
    y = (y0+y1)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x0 = points[2*i]
    y0 = points[2*i+1]
    x1 = points[2*j]
    y1 = points[2*j+1]
    w = abs(x1-x0)
    h = abs(y1-y0)
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x0 = points[2*i]
    y0 = points[2*i+1]
    x1 = points[2*j]
    y1 = points[2*j+1]
    d = math.sqrt(((x1-x0)**2)+((y1-y0)**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x0 = points[2*p1]
    y0 = points[2*p1+1]
    x1 = points[2*p2]
    y1 = points[2*p2+1]
    x2 = points[2*p3]
    y2 = points[2*p3+1]
    x3 = points[2*p4]
    y3 = points[2*p4+1]
    #สร้างสมการเส้นตรงที่ 1; จากจุด p1 กับจุด p2, m1 คือความชันของสมการ1
    #สร้างสมการเส้นตรงที่ 2; จากจุด p3 กับจุด p4, m2 คือความชันของสมการ2
    #ให้รูปแบบสมการเป็น y-y1 = m(x-x1)
    m1 = (y1-y0)/(x1-x0)
    m2 = (y3-y2)/(x3-x2)
    x = ((m1*x0)-(m2*x2)+y2-y0)/(m1-m2)
    y = (m1*(x-x0))+y0
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630038621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 644, 'const': 400, 'code+const': 1044}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  ix=points[i*2]
  iy=points[(i*2)+1]
  jx=points[j*2]
  jy=points[(j*2)+1]
  x = min(ix,jx)
  y = max(iy,jy)
  w = abs(ix-jx)
  h = abs(iy-jy)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  ix=points[i*2]
  iy=points[(i*2)+1]
  jx=points[j*2]
  jy=points[(j*2)+1]
  x= (ix + jx)/2
  y= (iy + jy)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  ix=points[i*2]
  iy=points[(i*2)+1]
  jx=points[j*2]
  jy=points[(j*2)+1]
  w = abs(ix-jx)
  h = abs(iy-jy)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  ix=points[i*2]
  iy=points[(i*2)+1]
  jx=points[j*2]
  jy=points[(j*2)+1]
  w = abs(ix-jx)
  h = abs(iy-jy)
  d = (w**2+h**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  px1=points[p1*2]
  py1=points[(p1*2)+1]
  px2=points[p2*2]
  py2=points[(p2*2)+1]
  px3=points[p3*2]
  py3=points[(p3*2)+1]
  px4=points[p4*2]
  py4=points[(p4*2)+1]
  m1 = (py2-py1)/(px2-px1)
  m2 = (py4-py3)/(px4-px3)
  x = (m1*px1 - py1 - m2*px3 +py3)/(m1 - m2)
  y = m1*(x-px1) + py1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630039221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 670, 'const': 400, 'code+const': 1070}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x = min(points[i*2],points[j*2])
  y = max(points[i*2+1],points[j*2+1])
  w = abs(points[i*2] - points[j*2])
  h = abs(points[i*2+1] - points[j*2+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1 = points[i*2]
  y1 = points[(i*2)+1]
  x2 = points[(j*2)]
  y2 = points[(j*2)+1]
  x = ((x1+x2)/2)
  y = ((y1+y2)/2)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x = points[i*2] #2
  x_y = points[(i*2)+1] #2
  y_x = points[(j*2)] #4
  y = points[(j*2)+1] #5
  w = abs(y_x - x)
  h = abs(y - x_y)
  a = w * h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1 = points[i*2]
  y1 = points[(i*2)+1]
  x2 = points[(j*2)]
  y2 = points[(j*2)+1]
  d = math.sqrt((x1-x2)**2 + (y1-y2)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[p1*2] #1
  y1 = points[(p1*2)+1] #5
  x2 = points[(p2*2)] #3
  y2 = points[(p2*2)+1] #1
  x3 = points[p3*2] #2
  y3 = points[(p3*2)+1] #2
  x4 = points[(p4*2)] #3
  y4 = points[(p4*2)+1] #3
  m12 = (y2-y1)/(x2-x1) #-2
  m34 = (y4-y3)/(x4-x3) #1
  c1 = y1 - m12*x1 #7
  c2 = y3 - m34*x3 #0
  x = (c2-c1)/(m12-m34)
  y = m12*x + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630045021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 568, 'const': 344, 'code+const': 912}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1 = points[2*i]
    y1 = points[2*i+1]
    x2 = points[2*j]
    y2 = points[2*j+1]
    return [min(x1,x2),max(y1,y2),abs(x1-x2),abs(y1-y2)]
def middle(points,i,j):
    x1 = points[2*i]
    y1 = points[2*i+1]
    x2 = points[2*j]
    y2 = points[2*j+1]
    return [(x1+x2)/2,(y1+y2)/2]
def frame_area(points,i,j):
    x,y,w,h = frame(points,i,j)
    return float(w*h)
def distance(points,i,j):
    x1 = points[2*i]
    y1 = points[2*i+1]
    x2 = points[2*j]
    y2 = points[2*j+1]
    return (abs(x1-x2)**2 + abs(y1-y2)**2)**.5
def intersection(points,p1,p2,p3,p4):
    x1,y1 = points[p1*2:p1*2+1+1]
    x2,y2 = points[p2*2:p2*2+1+1]
    x3,y3 = points[p3*2:p3*2+1+1]
    x4,y4 = points[p4*2:p4*2+1+1]
    m1 = (y2-y1)/(x2-x1)
    m2 = (y4-y3)/(x4-x3)
    c1 = y1 - (m1*x1)
    c2 = y3 - (m2*x3)
    x = (c2-c1)/(m1-m2)
    y = m1*x + c1
    return [x,y]

6630048921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4.0, -2.0, -7.0, 4.0, -2.0, -7.0, 5.0, -7.0, -2.0, -7.0],
 [2.0, 3.0, 1.0, 1.0, 3.0, 2.0, 2.0, 3.0, 3.0, -3.0],
 [5.0, 6.0, 11.0, 1.0, 11.0, 16.0, 4.0, 5.0, 7.0, 12.0],
 [1.0, 2.0, 5.0, 4.0, 1.0, 6.0, 5.0, 7.0, 6.0, 1.0]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 812, 'const': 400, 'code+const': 1212}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x1,y1 = float(points[i*2]),float(points[i*2+1])
  x2,y2 = float(points[j*2]),float(points[j*2+1])
  x = min(x1,x2)
  y = max(y1,y2)
  w = max(x1,x2)-min(x1,x2) #ใช้ abs()แทนได้
  h = max(y1,y2)-min(y1,y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1,y1 = float(points[i*2]),float(points[i*2+1])
  x2,y2 = float(points[j*2]),float(points[j*2+1])
  x,y = (x1+x2)/2,(y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1,y1 = float(points[i*2]),float(points[i*2+1])
  x2,y2 = float(points[j*2]),float(points[j*2+1])
  a = (max(x1,x2)-min(x1,x2))*(max(y1,y2)-min(y1,y2))
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1,y1 = float(points[i*2]),float(points[i*2+1])
  x2,y2 = float(points[j*2]),float(points[j*2+1])
  d = math.sqrt((max(x1,x2)-min(x1,x2))**2+(max(y1,y2)-min(y1,y2))**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,y1 = float(points[p1*2]),float(points[p1*2+1])
  x2,y2 = float(points[p2*2]),float(points[p2*2+1])
  x3,y3 = float(points[p3*2]),float(points[p3*2+1])
  x4,y4 = float(points[p4*2]),float(points[p4*2+1])
  m1 = (y2-y1)/(x2-x1) ; m2 = (y4-y3)/(x4-x3)
  x = (m2*x3-m1*x1+y1-y3)/(m2-m1) # m2 != m1 เพราะจะทำให้ขนานหรือตัดกันหลายจุด(จากโจทย์)
  #y = (y3/m2-y1/m1+x1-x3)/(1/m2-1/m1)
  y = m1*(x-x1)+y1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630050021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 666, 'const': 400, 'code+const': 1066}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x = points[::2]
    y = points[1::2]
    x1 = x[i]
    y1 = y[i]
    x2 = x[j]
    y2 = y[j]
    x = min(x1,x2)
    y = max(y1,y2)
    w = abs(x2-x1)
    h = abs(y2-y1)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x = points[::2]
    y = points[1::2]
    x1 = x[i]
    y1 = y[i]
    x2 = x[j]
    y2 = y[j]
    x = float((x1+x2)/2)
    y = float((y1+y2)/2)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x = points[::2]
    y = points[1::2]
    x1 = x[i]
    y1 = y[i]
    x2 = x[j]
    y2 = y[j]
    w = abs(x2-x1)
    h = abs(y2-y1)
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x = points[::2]
    y = points[1::2]
    x1 = x[i]
    y1 = y[i]
    x2 = x[j]
    y2 = y[j]
    a = abs(x1-x2)
    b = abs(y1-y2)
    d = math.sqrt(a**2+b**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x = points[::2]
    y = points[1::2]
    x1 = x[p1]
    y1 = y[p1]
    x2 = x[p2]
    y2 = y[p2]
    x3 = x[p3]
    y3 = y[p3]
    x4 = x[p4]
    y4 = y[p4]
    m1 = (y2-y1)/(x2-x1)
    c1 = y1-m1*x1
    m2 = (y4-y3)/(x4-x3)
    c2 = y4-m2*x4
    x = (c2-c1)/(m1-m2)
    y = m2*x+c2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630051721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 722, 'const': 452, 'code+const': 1174}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    pointx=[points[i*2],points[j*2]]
    pointy=[points[(i*2)+1],points[(j*2)+1]]
    w=max(pointx)-min(pointx)
    h=max(pointy)-min(pointy)
    x=max(pointx)-w
    y=min(pointy)+h
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x=(points[i*2]+points[j*2])/2
    y=(points[(i*2)+1]+points[(j*2)+1])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    pointx=[points[i*2],points[j*2]]
    pointy=[points[(i*2)+1],points[(j*2)+1]]
    w=max(pointx)-min(pointx)
    h=max(pointy)-min(pointy)
    a=w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    pointx=[points[i*2],points[j*2]]
    pointy=[points[(i*2)+1],points[(j*2)+1]]
    w=max(pointx)-min(pointx)
    h=max(pointy)-min(pointy)
    d=math.sqrt(w**2+h**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    pointx=[points[p1*2],points[p2*2],points[p3*2],points[p4*2]]
    pointy=[points[(p1*2)+1],points[(p2*2)+1],points[(p3*2)+1],points[(p4*2)+1]]
    m1=(pointy[1]-pointy[0])/(pointx[1]-pointx[0])
    m2=(pointy[3]-pointy[2])/(pointx[3]-pointx[2])
    x=(((m1*pointx[0])-pointy[0])-((m2*pointx[2])-pointy[2]))/(m1-m2)
    y=(m1*x)-(m1*pointx[0])+pointy[0]
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630052321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 774, 'const': 520, 'code+const': 1294}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j): # i = 3, j = 2
  # [1,1,2,2,3,3,4,5,7,8,1,5,3,1]
  p1 = [points[i*2],points[i*2 + 1]]
  p2 = [points[j*2],points[j*2 + 1]]
  w = abs(p1[0]-p2[0])
  h = abs(p1[1]-p2[1])
  x = min(p1[0],p2[0])
  y = max(p1[1],p2[1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  p1 = [points[i*2],points[i*2 + 1]]
  p2 = [points[j*2],points[j*2 + 1]]
  x = (p1[0] + p2[0]) / 2
  y = (p1[1] + p2[1]) / 2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  p1 = [points[i*2],points[i*2 + 1]]
  p2 = [points[j*2],points[j*2 + 1]]
  w = abs(p1[0]-p2[0])
  h = abs(p1[1]-p2[1])
  a = w * h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  p1 = [points[i*2],points[i*2 + 1]]
  p2 = [points[j*2],points[j*2 + 1]]
  d= math.sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  a1 = [points[p1*2],points[p1*2 + 1]]
  a2 = [points[p2*2],points[p2*2 + 1]]
  a3 = [points[p3*2],points[p3*2 + 1]]
  a4 = [points[p4*2],points[p4*2 + 1]]
  # line 1
  m1 = (a2[1] - a1[1]) / (a2[0] - a1[0])
  c1 = a1[1] - (m1 * a1[0])
  # line 2
  m2 = (a4[1] - a3[1]) / (a4[0] - a3[0])
  c2 = a3[1] - (m2 * a3[0])
  # y = mx + c
  # m1x + c1 = m2x + c2
  # m1x - m2x = c2 - c1
  # x(m1 - m2) = c2 - c1
  # x = (c2 - c1)/(m1 - m2)
  x = (c2 - c1) / (m1 - m2)
  y = m1 * x + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630054621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 766, 'const': 520, 'code+const': 1286}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points, i, j):
    p1 = [points[i*2], points[(i*2)+1]]
    p2 = [points[j*2], points[(j*2)+1]]
    x = min(p1[0], p2[0])
    y = max(p1[1], p2[1])
    w = abs(p1[0]-p2[0])
    h = abs(p1[1]-p2[1])
    return [x, y, w, h]  # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points, i, j):
    p1 = [points[i*2], points[(i*2)+1]]
    p2 = [points[j*2], points[(j*2)+1]]
    x = (p1[0]+p2[0])/2
    y = (p1[1]+p2[1])/2
    return [x, y]  # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points, i, j):
    p1 = [points[i*2], points[(i*2)+1]]
    p2 = [points[j*2], points[(j*2)+1]]
    a = abs(p1[0]-p2[0])*abs(p1[1]-p2[1])
    return float(a)  # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points, i, j):
    p1 = [points[i*2], points[(i*2)+1]]
    p2 = [points[j*2], points[(j*2)+1]]
    d = math.sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)
    return d  # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points, p1, p2, p3, p4): # points=[1,1,2,2,3,3,4,5,7,8,1,5,3,1]
    pt1 = [points[p1*2], points[(p1*2)+1]]
    pt2 = [points[p2*2], points[(p2*2)+1]]
    pt3 = [points[p3*2], points[(p3*2)+1]]
    pt4 = [points[p4*2], points[(p4*2)+1]]
    m12 = (pt1[1]-pt2[1])/(pt1[0]-pt2[0]) #line1
    m34 = (pt3[1]-pt4[1])/(pt3[0]-pt4[0]) #line2
    a = pt1[1]-(m12*pt1[0]) #line1
    b = pt3[1]-(m34*pt3[0]) #line2
    x = (b-a)/(m12-m34)
    y = (m12*x)+a
    return [x, y]  # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4
# 6630054621

6630055221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 582, 'const': 424, 'code+const': 1006}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x = [points[2*i],points[2*j]]
    y= [points[(2*i)+1],points[(2*j)+1]]
    width = max(x) - min(x)
    height = max(y) - min(y)
    return(min(x),max(y),width,height)
def middle(points,i,j):
    x = (points[2*i] + points[2*j])/2
    y = (points[(2*i)+1] + points[(2*j)+1])/2
    return [x,y]
def frame_area(points,i,j):
    a = frame(points,i,j)
    area = a[2] *a[3]
    return  float(area)
def distance(points,i,j):
    distance = ((points[2*i]-points[2*j])**2) + ((points[(2*i)+1]- points[(2*j)+1])**2)
    distance = distance**0.5
    return distance
def intersection(points,p1,p2,p3,p4):
    m1 = (points[(2*p1)+1] -points[(2*p2)+1]) / ((points[(2*p1)] -points[(2*p2)]) )
    m2 = (points[(2*p3)+1] -points[(2*p4)+1]) / ((points[(2*p3)] -points[(2*p4)]) )
    x = (-m1 * points[2*p1]) + points[(2*p1)+1]+ (m2*points[2*p3]) - points[(2*p3)+1]
    x = x /(m2-m1)
    y = (m1*(x - points[2*p1])) + points[(2*p1)+1]
    return[x,y]

6630059821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 638, 'const': 344, 'code+const': 982}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
   x = min(points[i+i],points[j+j])
   y = max(points[i+i+1],points[j+j+1])
   w = abs(points[j+j]-points[i+i])
   h = abs(points[j+j+1]-points[i+i+1])
   return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
   x = (points[i+i]+points[j+j])/2
   y = (points[i+i+1]+points[j+j+1])/2
   return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
   w = abs(points[j+j]-points[i+i])
   h = abs(points[j+j+1]-points[i+i+1])
   a = w*h
   return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d = math.sqrt((points[j+j]-points[i+i])**2 + (points[j+j+1]-points[i+i+1])**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
   m1 = (points[p2+p2+1]-points[p1+p1+1])/(points[p2+p2]-points[p1+p1])
   m2 = (points[p4+p4+1]-points[p3+p3+1])/(points[p4+p4]-points[p3+p3])
   c1 = (-1)*m1*points[p2+p2]+points[p2+p2+1]
   c2 = (-1)*m2*points[p4+p4]+points[p4+p4+1]
   x = (c1-c2)/(m2-m1)
   y = m1*x+c1
   return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630060321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 918, 'const': 472, 'code+const': 1390}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  p1 = [2*i,2*i+1]
  p2 = [2*j,2*j+1]
  x = min(points[p1[0]],points[p2[0]])
  y = max(points[p1[1]],points[p2[1]])
  w = max(points[p1[0]],points[p2[0]])-min(points[p1[0]],points[p2[0]])
  h = max(points[p1[1]],points[p2[1]])-min(points[p1[1]],points[p2[1]])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  p1 = [2*i,2*i+1]
  p2 = [2*j,2*j+1]
  x = (points[p1[0]]+points[p2[0]])/2
  y = (points[p1[1]]+points[p2[1]])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  p1 = [2*i,2*i+1]
  p2 = [2*j,2*j+1]
  w = max(points[p1[0]],points[p2[0]])-min(points[p1[0]],points[p2[0]])
  h = max(points[p1[1]],points[p2[1]])-min(points[p1[1]],points[p2[1]])
  a = float(w*h)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  p1 = [2*i,2*i+1]
  p2 = [2*j,2*j+1]
  d = (points[p2[0]]-points[p1[0]])**2+(points[p2[1]]-points[p1[1]])**2
  d = math.sqrt(d)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  c2x = points[p3*2]-points[p4*2]
  c3x = points[p1*2]-points[p2*2]
  c2y = points[p3*2+1]-points[p4*2+1]
  c3y = points[p1*2+1]-points[p2*2+1]
  d = c3x*c2y-c3y*c2x
  r1 = (points[p1*2]*points[p2*2+1])-(points[p1*2+1]*points[p2*2])
  r3 = (points[p3*2]*points[p4*2+1])-(points[p3*2+1]*points[p4*2])
  x = (r1*c2x-c3x*r3)/d
  y = (r1*c2y-c3y*r3)/d
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630064921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 754, 'const': 520, 'code+const': 1274}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    order = []
    for z in range(0, len(points), 2):
        x = points[z]
        y = points[z + 1]
        order.append((x, y))
    x1, y1 = order[i]
    x2, y2 = order[j]
    x = min(x1, x2)  # upper_left_x
    y = max(y1, y2)  # upper_left_y
    w = abs(x2 - x1)  # width
    h = abs(y2 - y1)  # height
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    order = []
    for z in range(0, len(points), 2):
        x = points[z]
        y = points[z + 1]
        order.append((x, y))
    x1, y1 = order[i]
    x2, y2 = order[j]
    x = (x1 + x2) / 2
    y = (y1 + y2) / 2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    order = []
    for z in range(0, len(points), 2):
        x = points[z]
        y = points[z + 1]
        order.append((x, y))
    x1, y1 = order[i]
    x2, y2 = order[j]
    w = abs(x2 - x1)  # width
    h = abs(y2 - y1)  # height
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    order = []
    for z in range(0, len(points), 2):
        x = points[z]
        y = points[z + 1]
        order.append((x, y))
    x1, y1 = order[i]
    x2, y2 = order[j]
    d = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    order = []
    for z in range(0, len(points), 2):
        x = points[z]
        y = points[z + 1]
        order.append((x, y))
    x1, y1 = order[p1]  # line_a_first
    x2, y2 = order[p2]  # line_a_Second
    x3, y3 = order[p3]  # line_b_first
    x4, y4 = order[p4]  # line_b_Second
    m1 = (y2 - y1) / (x2 - x1)  # slope_line_a
    m2 = (y4 - y3) / (x4 - x3)  # slope_line_b
    c1 = y1 - m1 * x1  # line_a
    c2 = y3 - m2 * x3  # line_b
    x = (c2 - c1) / (m1 - m2)  # intersection_x
    y = (m1 * x) + c1  # intersection_y
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630066121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 850, 'const': 400, 'code+const': 1250}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x = int(min(float(points[2*i]), float(points[2*j])))
  y = int(max(float(points[2*i+1]), float(points[2*j+1])))
  w = int(abs(float(points[2*i])-float(points[2*j])))
  h = int(abs(float(points[2*i+1])-float(points[2*j+1])))
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = abs(float(points[2*i])-float(points[2*j])) / 2 + min(float(points[2*i]), float(points[2*j]))
  y = abs(float(points[2*i+1])-float(points[2*j+1])) / 2 + min(float(points[2*i+1]), float(points[2*j+1]))
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs(float(points[2*i])-float(points[2*j]))
  h = abs(float(points[2*i+1])-float(points[2*j+1]))
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  w = abs(float(points[2*i])-float(points[2*j]))
  h = abs(float(points[2*i+1])-float(points[2*j+1]))
  d = math.sqrt(w**2+h**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = float(points[2*p1]) ; y1 = float(points[2*p1+1])
  x2 = float(points[2*p2]) ; y2 = float(points[2*p2+1])
  x3 = float(points[2*p3]) ; y3 = float(points[2*p3+1])
  x4 = float(points[2*p4]) ; y4 = float(points[2*p4+1])
  m1 = (y1-y2) / (x1-x2)
  m2 = (y3-y4)/ (x3-x4)
  c1 = y1 - m1*x1
  c2 = y3 - m2*x3
  x = (c2-c1) / (m1-m2)
  y = m1*x + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630067821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 638, 'const': 344, 'code+const': 982}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x = min(points[i+i],points[j+j])
    y = max(points[i+i+1],points[j+j+1])
    w = abs(points[i+i]-points[j+j])
    h = abs(points[i+i+1]-points[j+j+1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x = (points[i+i]+points[j+j])/2
    y = (points[i+i+1]+points[j+j+1])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    w = abs(points[i+i]-points[j+j])
    h = abs(points[i+i+1]-points[j+j+1])
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    d = math.sqrt((points[i+i]-points[j+j])**2+(points[i+i+1]-points[j+j+1])**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    m1 = (points[p2+p2+1]-points[p1+p1+1])/(points[p2+p2]-points[p1+p1])
    m2 = (points[p4+p4+1]-points[p3+p3+1])/(points[p4+p4]-points[p3+p3])
    c2 = points[p4+p4+1]+(m2*points[p4+p4])*(-1)
    c1 = points[p2+p2+1]+(m1*points[p2+p2])*(-1)
    x = (c1-c2)/(m2-m1)
    y = m1*x+c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630069021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 794, 'const': 520, 'code+const': 1314}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  a = [points[2*i],points[2*i+1]]
  b = [points[2*j],points[2*j+1]]
  x = min(a[0],b[0])
  y = max(a[1],b[1])
  h = abs(a[1] - b[1])
  w = abs(a[0] - b[0])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  a = [points[2*i],points[2*i+1]]
  b = [points[2*j],points[2*j+1]]
  x = (a[0] + b[0])/2
  y = (a[1] + b[1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  a = [points[2*i],points[2*i+1]]
  b = [points[2*j],points[2*j+1]]
  h = abs(a[1] - b[1])
  w = abs(a[0] - b[0])
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  a = [points[2*i],points[2*i+1]]
  b = [points[2*j],points[2*j+1]]
  x = abs(a[0] - b[0])
  y = abs(a[1] - b[1])
  d = math.sqrt(x**2 + y**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  a1 = [points[2*p1],points[2*p1+1]]
  a2 = [points[2*p2],points[2*p2+1]]
  b1 = [points[2*p3],points[2*p3+1]]
  b2 = [points[2*p4],points[2*p4+1]]
  ma = (a2[1] - a1[1])/(a2[0] - a1[0])
  mb = (b2[1] - b1[1])/(b2[0] - b1[0])
  x = (b2[1] - mb*b2[0] + ma*a2[0] - a2[1])/(ma - mb)
  y = ma*(x - a2[0]) + a2[1]
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630072921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 646, 'const': 400, 'code+const': 1046}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    xi = points[2*i]
    yi = points[2*i+1]
    xj = points[2*j]
    yj = points[2*j+1]
    x = min(xi,xj)
    y = max(yi,yj)
    w = abs(xi-xj)
    h = abs(yi-yj)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi = points[2*i]
    yi = points[2*i+1]
    xj = points[2*j]
    yj = points[2*j+1]
    x = (xi+xj)/2
    y = (yi+yj)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi = points[2*i]
    yi = points[2*i+1]
    xj = points[2*j]
    yj = points[2*j+1]
    w = abs(xi-xj)
    h = abs(yi-yj)
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi = points[2*i]
    yi = points[2*i+1]
    xj = points[2*j]
    yj = points[2*j+1]
    d = math.sqrt((xi-xj)**2+(yi-yj)**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[2*p1]
    y1 = points[2*p1+1]
    x2 = points[2*p2]
    y2 = points[2*p2+1]
    x3 = points[2*p3]
    y3 = points[2*p3+1]
    x4 = points[2*p4]
    y4 = points[2*p4+1]
    m1 = (y2-y1) / (x2-x1)
    m2 = (y4-y3) / (x4-x3)
    c1 = y1-m1*x1
    c2 = y4-m2*x4
    x = (c2-c1)/(m1-m2)
    y = m1*x+c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630078721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 806, 'const': 520, 'code+const': 1326}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  i = points[2*i:2*i+2]
  j = points[2*j:2*j+2]
  x= min(i[0],j[0])
  y= max(i[1],j[1])
  w=abs(i[0]-j[0])
  h=abs(i[1]-j[1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  i = points[2*i:2*i+2]
  j = points[2*j:2*j+2]
  x= (i[0]+j[0])/2
  y=(i[1]+j[1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  i = points[2*i:2*i+2]
  j = points[2*j:2*j+2]
  x= min(i[0],j[0])
  y= max(i[1],j[1])
  w=(max(i[0],j[0])-min(i[0],j[0]))
  h=(max(i[1],j[1])-min(i[1],j[1]))
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  i = points[2*i:2*i+2]
  j = points[2*j:2*j+2]
  d = math.sqrt((i[0]-j[0])**2+(i[1]-j[1])**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  p1 = points[2*p1:2*p1+2]
  p2 = points[2*p2:2*p2+2]
  p3 = points[2*p3:2*p3+2]
  p4 = points[2*p4:2*p4+2]
  m1=(p2[1]-p1[1])/(p2[0]-p1[0])
  m2=(p4[1]-p3[1])/(p4[0]-p3[0])
  c_a=p1[1]-m1*p1[0]
  c_b=p3[1]-m2*p3[0]
  x = (c_b-c_a)/(m1-m2)
  y = (c_a*m2-c_b*m1)/(m2-m1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630082121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 614, 'const': 400, 'code+const': 1014}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  # กำหนดจุดจาก i, j
  xi,yi= points[2*i], points[2*i+1]
  xj,yj= points[2*j], points[2*j+1]
  x_min = min(xi,xj)
  x_max = max(xi,xj)
  y_max = max(yi,yj)
  y_min = min(yi,yj)
  w = x_max - x_min
  h = y_max - y_min
  return [x_min,y_max,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  # กำหนดจุดจาก i, j
  xi,yi= points[2*i], points[2*i+1]
  xj,yj= points[2*j], points[2*j+1]
  return [(xi+xj)/2,(yi+yj)/2] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  frame_result = frame(points,i,j)
  area = frame_result[-2] * frame_result[-1]
  return float(area) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  # กำหนดจุดจาก i, j
  xi,yi= points[2*i], points[2*i+1]
  xj,yj= points[2*j], points[2*j+1]
  # หาระยะทางจากจุดสองจุด
  d = math.sqrt((xi-xj)**2+(yi-yj)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  # กำหนดจุดจากทั้งสี่จุด
  x1,y1 = points[2*p1], points[2*p1+1]
  x2,y2 = points[2*p2], points[2*p2+1]
  x3,y3 = points[2*p3], points[2*p3+1]
  x4,y4 = points[2*p4], points[2*p4+1]
  # หาสมการของเส้นตรงที่ผ่าน (x1, y1) และ (x2, y2)
  m1 = (y2 - y1) / (x2 - x1) # หาความขัน
  c1 = y1 - (m1 * x1)
  # หาสมการของเส้นตรงที่ผ่าน (x3, y3) และ (x4, y4)
  m2 = (y4 - y3) / (x4 - x3) # หาความขัน
  c2 = y3 - (m2 * x3)
  # หาค่า x ของจุดตัด
  x = (c2 - c1) / (m1 - m2)
  # หาค่า y ของจุดตัด
  y = (m1 * x) + c1
  return [x, y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630084421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 604, 'const': 448, 'code+const': 1052}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x = min(points[2*i],points[2*j])
    y = max(points[(2*i)+1],points[(2*j)+1])
    w = abs(points[2*i] - points[2*j])
    h = abs(points[(2*i)+1] - points[(2*j)+1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x = (points[2*i] + points[2*j])*0.5
    y = (points[(2*i)+1] + points[(2*j)+1])*0.5
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    a = abs((points[2*i]- points[2*j]) * (points[(2*i)+1] - points[(2*j+1)]))
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j): #พีทาโกรัส (a**2+b**2)**0.5 = c
    d = ((points[2*i] - points[2*j])**2 + (points[(2*i)+1] - points[(2*j)+1])**2)**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    X1 = points[2*p1]
    X2 = points[2*p2]
    X3 = points[2*p3]
    X4 = points[2*p4]
    Y1 = points[2*p1+1]
    Y2 = points[2*p2+1]
    Y3 = points[2*p3+1]
    Y4 = points[2*p4+1]
    M1 = (Y2-Y1)/(X2-X1)
    M2 = (Y4-Y3)/(X4-X3)
    x = ((Y3-M2*X3)-(Y1-M1*X1))/(M1-M2)
    y = ((M1*x)+Y1-M1*X1)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630086721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4.0, -2.0, -7.0, 4.0, -2.0, -7.0, 5.0, -7.0, -2.0, -7.0],
 [2.0, 3.0, 1.0, 1.0, 3.0, 2.0, 2.0, 3.0, 3.0, -3.0],
 [5.0, 6.0, 11.0, 1.0, 11.0, 16.0, 4.0, 5.0, 7.0, 12.0],
 [1.0, 2.0, 5.0, 4.0, 1.0, 6.0, 5.0, 7.0, 6.0, 1.0]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 708, 'const': 400, 'code+const': 1108}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1 = float(points[2*i])
    x2 = float(points[2*j])
    y1 = float(points[(2*i)+1])
    y2 = float(points[(2*j)+1])
    tuax = x1,x2
    tuay = y1,y2
    x_left = min(tuax)
    y_left = max(tuay)
    w = abs(x1 - x2)
    h = abs(y2 - y1)
    return [x_left,y_left,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x_mid = float((points[2*i] + points[2*j])/2)
    y_mid = float((points[(2*i)+1] + points[(2*j)+1])/2)
    return [x_mid,y_mid] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x1 = float(points[2*i])
    x2 = float(points[2*j])
    y1 = float(points[(2*i)+1])
    y2 = float(points[(2*j)+1])
    w = abs(x1 - x2)
    h = abs(y1 - y2)
    return w*h # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1 = float(points[2*i])
    x2 = float(points[2*j])
    y1 = float(points[(2*i)+1])
    y2 = float(points[(2*j)+1])
    dis = ((x1 - x2)**2 + (y1 - y2)**2)**0.5
    return dis # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = float(points[2*p1])
    y1 = float(points[(2*p1)+1])
    x2 = float(points[2*p2])
    y2 = float(points[(2*p2)+1])
    x3 = float(points[2*p3])
    y3 = float(points[(2*p3)+1])
    x4 = float(points[2*p4])
    y4 = float(points[(2*p4)+1])
    m1 = (y2 - y1)/(x2 - x1)
    m2 = (y4 - y3)/(x4 - x3)
    x_inter = ((m1 * x1) - (m2 * x3) + (y3 - y1))/(m1 - m2)
    y_inter = (m1 * x_inter) - (m1 * x1) + y1
    return [x_inter,y_inter] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630088021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4.0, -2.0, -7.0, 4.0, -2.0, -7.0, 5.0, -7.0, -2.0, -7.0],
 [2.0, 3.0, 1.0, 1.0, 3.0, 2.0, 2.0, 3.0, 3.0, -3.0],
 [5.0, 6.0, 11.0, 1.0, 11.0, 16.0, 4.0, 5.0, 7.0, 12.0],
 [1.0, 2.0, 5.0, 4.0, 1.0, 6.0, 5.0, 7.0, 6.0, 1.0]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 844, 'const': 424, 'code+const': 1268}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    w=abs(float(points[2*i])-float(points[2*j]))
    h=abs(float(points[2*i+1])-float(points[2*j+1]))
    x=min(float(points[2*i]),float(points[2*j]))
    y=max(float(points[2*i+1]),float(points[2*j+1]))
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
   x=(float(points[2*i])+float(points[2*j]))/2
   y=(float(points[2*i+1])+float(points[2*j+1]))/2
   return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w=abs(float(points[2*i])-float(points[2*j]))
  h=abs(float(points[2*i+1])-float(points[2*j+1]))
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d=math.sqrt(((float(points[2*i])-float(points[2*j]))**2)+((float(points[2*i+1])-float(points[2*j+1]))**2))
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    c1=[float(points[2*p1]),float(points[2*p1+1])]
    c2=[float(points[2*p2]),float(points[2*p2+1])]
    c3=[float(points[2*p3]),float(points[2*p3+1])]
    c4=[float(points[2*p4]),float(points[2*p4+1])]
    m1=float((c2[1])-float(c1[1]))/(float(c2[0])-float(c1[0]))
    m2=float((c4[1])-float(c3[1]))/(float(c4[0])-float(c3[0]))
    x1=float(c1[0])
    x2=float(c3[0])
    y1=float(c1[1])
    y2=float(c3[1])
    x=(-y1+y2+m1*x1-m2*x2)/(m1-m2)
    y=m1*(x-x1)+y1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630092421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 646, 'const': 400, 'code+const': 1046}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  xi=points[2*i]
  xj=points[2*j]
  yi=points[2*i+1]
  yj=points[2*j+1]
  x=min(xi,xj)
  y=max(yi,yj)
  w=abs(xj-xi)
  h=abs(yj-yi)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi=points[2*i]
  xj=points[2*j]
  yi=points[2*i+1]
  yj=points[2*j+1]
  x=(xi+xj)/2
  y=(yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi=points[2*i]
  xj=points[2*j]
  yi=points[2*i+1]
  yj=points[2*j+1]
  w=abs(xj-xi)
  h=abs(yj-yi)
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi=points[2*i]
  xj=points[2*j]
  yi=points[2*i+1]
  yj=points[2*j+1]
  d=math.sqrt((xj-xi)**2+(yj-yi)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xi=points[2*p1]
  yi=points[2*p1+1]
  xj=points[2*p2]
  yj=points[2*p2+1]
  xa=points[2*p3]
  ya=points[2*p3+1]
  xb=points[2*p4]
  yb=points[2*p4+1]
  m1=(yj-yi)/(xj-xi)
  m2=(yb-ya)/(xb-xa)
  c1=yj-(m1*xj)
  c2=yb-(m2*xb)
  x=(c2-c1)/(m1-m2)
  y=m2*x+c2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630093021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 646, 'const': 400, 'code+const': 1046}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = (points[2 * (i)])
  yi = (points[1 + (2 * (i))])
  xj = (points[2 * (j)])
  yj = (points[1 + (2* (j))])
  x = min(xi , xj)
  y = max(yi , yj)
  w = abs(xi - xj)
  h = abs(yi - yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = (points[2*(i)])
  yi = (points[1+(2*(i))])
  xj = (points[2*(j)])
  yj = (points[1+(2*(j))])
  x = (xi + xj)/2
  y = (yi + yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = (points[2*(i)])
  yi = (points[1+(2*(i))])
  xj = (points[2*(j)])
  yj = (points[1+(2*(j))])
  w = abs(xi - xj)
  h = abs(yi - yj)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  import math
  xi = (points[2*(i)])
  yi = (points[1+(2*(i))])
  xj = (points[2*(j)])
  yj = (points[1+(2*(j))])
  dsquare = ((xi - xj)**2) + ((yi - yj)**2)
  d = math.sqrt(dsquare)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = (points[2*(p1)])
  y1 = (points[1+(2*(p1))])
  x2 = (points[2*(p2)])
  y2 = (points[1+(2*(p2))])
  x3 = (points[2*(p3)])
  y3 = (points[1+(2*(p3))])
  x4 = (points[2*(p4)])
  y4 = (points[1+(2*(p4))])
  m1 = (y2 - y1)/(x2 - x1)
  m2 = (y4 - y3)/(x4 - x3)
  c1 = y1 - (m1*x1)
  c2 = y3 - (m2*x3)
  x = (c2 - c1)/(m1 - m2)
  y = (m1*x) + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630094721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 668, 'const': 400, 'code+const': 1068}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  x = min(x1,x2)
  y = max(y1,y2)
  w = abs(x2-x1)
  h = abs(y2-y1)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  x = (x1+x2)/2
  y = (y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  w = abs(x2-x1)
  h = abs(y2-y1)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  d = ((abs(x1-x2))**2+(abs(y1-y2))**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[2*p1]
  y1 = points[2*p1+1]
  x2 = points[2*p2]
  y2 = points[2*p2+1]
  x3 = points[2*p3]
  y3 = points[2*p3+1]
  x4 = points[2*p4]
  y4 = points[2*p4+1]
  m1 = (y2-y1)/(x2-x1)
  m2 = (y4-y3)/(x4-x3)
  x = (m1*x1-y1-m2*x3+y3)/(m1-m2)
  y = (m2*y1-x1*m1*m2-m1*y3+x3*m1*m2)/(m2-m1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630099921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 706, 'const': 400, 'code+const': 1106}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = min(xi,xj)
  y = max(yi,yj)
  w = abs(xi-xj)
  h = abs(yi-yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = min(xi,xj)+abs(xi-xj)/2
  y = min(yi,yj)+abs(yi-yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  a = abs(xj-xi)*abs(yj-yi)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  m = abs(xj-xi)**2
  n = abs(yj-yi)**2
  d = math.sqrt(m+n)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xp1 = points[2*p1]
  yp1 = points[2*p1+1]
  xp2 = points[2*p2]
  yp2 = points[2*p2+1]
  xp3 = points[2*p3]
  yp3 = points[2*p3+1]
  xp4 = points[2*p4]
  yp4 = points[2*p4+1]
  slope1 = (yp2-yp1)/(xp2-xp1)
  slope2 = (yp4-yp3)/(xp4-xp3)
  a = yp1-slope1*xp1
  b = yp3-slope2*xp3
  Hline = slope1*xp2+a
  Mline = slope2*xp4+b
  x = (b-a)/(slope1-slope2)
  y = slope1*x+a
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630180021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 658, 'const': 400, 'code+const': 1058}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x = min([points[i*2],points[j*2]])
  y = max([points[i*2+1],points[j*2+1]])
  w = abs(points[i*2]-points[j*2])
  h = abs(points[i*2+1]-points[j*2+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (int(points[i*2])+int(points[j*2]))/2
  y = (int(points[i*2+1])+int(points[j*2+1]))/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs(points[i*2]-points[j*2])
  h = abs(points[i*2+1]-points[j*2+1])
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  w = abs(points[i*2]-points[j*2])
  h = abs(points[i*2+1]-points[j*2+1])
  d = math.sqrt(w**2+h**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,y1 = points[p1*2:(p1+1)*2]
  x2,y2 = points[p2*2:(p2+1)*2]
  x3,y3 = points[p3*2:(p3+1)*2]
  x4,y4 = points[p4*2:(p4+1)*2]
  m1 = (y2-y1)/(x2-x1)
  m2 = (y4-y3)/(x4-x3)
  c1 = y1-m1*x1
  c2 = y3-m2*x3
  x = (c2-c1)/(m1-m2)
  y = m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630185121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 606, 'const': 344, 'code+const': 950}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  wide = max(xi,xj)-min(xi,xj)
  high = max(yi,yj)-min(yi,yj)
  xmin = min(xi,xj)
  ymax = max(yi,yj)
  return [xmin,ymax,wide,high] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  xmid = (xi+xj)/2
  ymid = (yi+yj)/2
  return [xmid,ymid] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xmin,ymax,wide,high = frame(points,i,j)
    a = wide*high
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  d = math.sqrt((xi-xj)**2+(yi-yj)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xi = points[2*p1]
  yi = points[2*p1+1]
  xj = points[2*p2]
  yj = points[2*p2+1]
  xa = points[2*p3]
  ya = points[2*p3+1]
  xb = points[2*p4]
  yb = points[2*p4+1]
  slope1 = (yi-yj)/(xi-xj)
  yintercept1 = yj-slope1*xj
  slope2 = (ya-yb)/(xa-xb)
  yintercept2 = yb-slope2*xb
  x = (yintercept2-yintercept1)/(slope1-slope2)
  y = slope1*x+yintercept1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630220421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 668, 'const': 316, 'code+const': 984}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
     p1 = points[i+i]
     p2 = points[i+i+1]
     o1 = points[j+j]
     o2 = points[j+j+1]
     x = min(p1,o1)
     y = max(p2,o2)
     w = abs(p1-o1)
     h = abs(p2-o2)
     return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
     p1 = points[i+i]
     p2 = points[i+i+1]
     o1 = points[j+j]
     o2 = points[j+j+1]
     x = (p1+o1)/2
     y = (p2+o2)/2
     return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
     p1 = points[i+i]
     p2 = points[i+i+1]
     o1 = points[j+j]
     o2 = points[j+j+1]
     w = abs(p1-o1)
     h = abs(p2-o2)
     a = w*h
     return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    p1 = points[i+i]
    p2 = points[i+i+1]
    o1 = points[j+j]
    o2 = points[j+j+1]
    d = (((p1-o1)**2)+((p2-o2)**2))**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[p1+p1]
    y1 = points[p1+p1+1]
    x2 = points[p2+p2]
    y2 = points[p2+p2+1]
    x3 = points[p3+p3]
    y3 = points[p3+p3+1]
    x4 = points[p4+p4]
    y4 = points[p4+p4+1]
    A1 = y2 - y1
    B1 = x1 - x2
    C1 = A1 * x1 + B1 * y1
    A2 = y4 - y3
    B2 = x3 - x4
    C2 = A2 * x3 + B2 * y3
    d = A1 * B2 - A2 * B1
    x = (B2 * C1 - B1 * C2)/d
    y = (A1 * C2 - A2 * C1)/d
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630221021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 680, 'const': 400, 'code+const': 1080}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi,yi=points[i*2],points[(i*2)+1]
  xj,yj=points[j*2],points[(j*2)+1]
  x = min(xi,xj)
  y = max(yi,yj)
  w = abs(xi-xj)
  h = abs(yi-yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi,yi=points[i*2],points[(i*2)+1]
  xj,yj=points[j*2],points[(j*2)+1]
  x = (xi + xj)/2
  y = (yi + yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi,yi=points[i*2],points[(i*2)+1]
  xj,yj=points[j*2],points[(j*2)+1]
  w = abs(xi-xj)
  h = abs(yi-yj)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi,yi=points[i*2],points[(i*2)+1]
  xj,yj=points[j*2],points[(j*2)+1]
  d = ((xi-xj)**2+(yi-yj)**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  p1=x1,y1=points[p1*2],points[(p1*2)+1]
  p2=x2,y2=points[p2*2],points[(p2*2)+1]
  p2=x3,y3=points[p3*2],points[(p3*2)+1]
  p2=x4,y4=points[p4*2],points[(p4*2)+1]
  m1=(y2-y1)/(x2-x1)
  m2=(y4-y3)/(x4-x3)
  c1=y1-m1*x1
  c2=y3-m2*x3
  x=(c2-c1)/(m1-m2)
  y=m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630230721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 702, 'const': 400, 'code+const': 1102}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  i = i*2
  j = j*2
  xi = points[i]
  yi = points[i+1]
  xj = points[j]
  yj = points[j+1]
  lmaox = min(xi,xj)
  lmaoy = max(yi,yj)
  absx = abs(xi-xj)
  absy = abs(yi-yj)
  return(lmaox,lmaoy,absx,absy)
def middle(points,i,j):
  i = i*2
  j = j*2
  xi = points[i]
  yi = points[i+1]
  xj = points[j]
  yj = points[j+1]
  x = (xi+xj)/2
  y = (yi+yj)/2
  return(x,y)
def frame_area(points,i,j):
  i = i*2
  j = j*2
  xi = points[i]
  yi = points[i+1]
  xj = points[j]
  yj = points[j+1]
  absx = abs(xi-xj)
  absy = abs(yi-yj)
  dd = absx * absy
  return(dd)
def distance(points,i,j):
  i = i*2
  j = j*2
  xi = points[i]
  yi = points[i+1]
  xj = points[j]
  yj = points[j+1]
  num = math.sqrt((xj - xi)**2+(yj - yi)**2)
  return(num)
def intersection(points,p1,p2,p3,p4):
  p1 = p1*2
  p2 = p2*2
  p3 = p3*2
  p4 = p4*2
  x1 = points[p1]
  y1 = points[p1+1]
  x2 = points[p2]
  y2 = points[p2+1]
  x3 = points[p3]
  y3 = points[p3+1]
  x4 = points[p4]
  y4 = points[p4+1]
  px = ((((x1*y2)-(y1*x2))*(x3-x4))-((x1-x2)*((x3*y4)-(y3*x4))))
  py = (((x1*y2-y1*x2)*(y3-y4))-((y1-y2)*(x3*y4-y3*x4)))
  ski = ((x1-x2)*(y3-y4))-((y1-y2)*(x3-x4))
  x = px/ski
  y = py/ski
  return(x,y)

6630303921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 570, 'const': 344, 'code+const': 914}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    xa = points[2*i]
    ya = points[2*i+1]
    xb = points[2*j]
    yb = points[2*j+1]
    frame = [min(xa,xb),max(ya,yb),abs(xa-xb),abs(ya-yb)]
    return frame # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xa = points[2*i]
    ya = points[2*i+1]
    xb = points[2*j]
    yb = points[2*j+1]
    middle = [(xa+xb)/2,(ya+yb)/2]
    return middle # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x,y,w,h=frame(points,i,j)
    area = w*h
    return area # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xa = points[2*i]
    ya = points[2*i+1]
    xb = points[2*j]
    yb = points[2*j+1]
    import math
    dis = math.sqrt((xa-xb)**2+(ya-yb)**2)
    return dis # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    xa,ya=points[p1*2:(p1+1)*2]
    xb,yb=points[p2*2:(p2+1)*2]
    xc,yc=points[p3*2:(p3+1)*2]
    xd,yd=points[p4*2:(p4+1)*2]
    ma=(yb-ya)/(xb-xa)
    ca=ya-ma*xa
    mb=(yd-yc)/(xd-xc)
    cb=yc-mb*xc
    x = (cb-ca)/(ma-mb)
    y = ma*x+ca
    inter = [x,y]
    return inter # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630316021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 668, 'const': 452, 'code+const': 1120}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
 x_points=points[::2]
 y_points=points[1::2]
 xi=x_points[i]
 yi=y_points[i]
 xj=x_points[j]
 yj=y_points[j]
 a=[xi,xj]
 b=[yi,yj]
 return [min(a),max(b),(max(a)-min(a)),(max(b)-min(b))]
def middle(points,i,j):
  x_points=points[::2]
  y_points=points[1::2]
  xi=x_points[i]
  yi=y_points[i]
  xj=x_points[j]
  yj=y_points[j]
  x=float((xj+xi)/2)
  y=float((yj+yi)/2)
  return [x,y]
def frame_area(points,i,j):
 x_points=points[::2]
 y_points=points[1::2]
 xi=x_points[i]
 yi=y_points[i]
 xj=x_points[j]
 yj=y_points[j]
 a=[xi,xj]
 b=[yi,yj]
 return (float(max(a)-min(a)))*float((max(b)-min(b)))
def distance(points,i,j):
 x_points=points[::2]
 y_points=points[1::2]
 xi=x_points[i]
 yi=y_points[i]
 xj=x_points[j]
 yj=y_points[j]
 d=((yj-yi)**2+(xj-xi)**2)**(1/2)
 return d
def intersection(points,p1,p2,p3,p4):
 x_points=points[::2]
 y_points=points[1::2]
 m1=(y_points[p2] - y_points[p1])/(x_points[p2] - x_points[p1])
 c1=((m1*(-1*x_points[p1]))+y_points[p1])
 m2=(y_points[p4] - y_points[p3])/(x_points[p4] - x_points[p3])
 c2=((m2*(-1*x_points[p3]))+y_points[p3])
 X=(c2-c1)/(m1-m2)
 Y=((m2*c1)-(m1*c2))/(m2-m1)
 return [X,Y]

6630328621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 658, 'const': 400, 'code+const': 1058}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x1=points[i*2]
  y1=points[i*2+1]
  x2=points[j*2]
  y2=points[j*2+1]
  k=x1,x2
  f=y1,y2
  x=min(k)
  y=max(f)
  h=abs(y1-y2)
  w=abs(x1-x2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1=points[i*2]
  y1=points[i*2+1]
  x2=points[j*2]
  y2=points[j*2+1]
  x=(x1+x2)/2
  y=(y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1=points[i*2]
  y1=points[i*2+1]
  x2=points[j*2]
  y2=points[j*2+1]
  h=abs(y1-y2)
  w=abs(x1-x2)
  a=h*w
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1=points[i*2]
  y1=points[i*2+1]
  x2=points[j*2]
  y2=points[j*2+1]
  d= math.sqrt((x1-x2)**2+(y1-y2)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1=points[p1*2]
  y1=points[p1*2+1]
  x2=points[p2*2]
  y2=points[p2*2+1]
  x3=points[p3*2]
  y3=points[p3*2+1]
  x4=points[p4*2]
  y4=points[p4*2+1]
  m1=(y2-y1)/(x2-x1)
  c1=y1-m1*x1
  m2=(y3-y4)/(x3-x4)
  c2=y3-m2*x3
  x=(c2-c1)/(m1-m2)
  y=m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6630358421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 814, 'const': 400, 'code+const': 1214}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    xi = points[2*i]
    yi = points[2*i+1]
    xj = points[2*j]
    yj = points[2*j+1]
    w = max(xi,xj)-min(xi,xj)
    h = max(yi,yj)-min(yi,yj)
    x = min(xi,xj)
    y = max(yi,yj)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi = points[2*i]
    yi = points[2*i+1]
    xj = points[2*j]
    yj = points[2*j+1]
    x = (xi+xj)/2
    y = (yi+yj)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi = points[2*i]
    yi = points[2*i+1]
    xj = points[2*j]
    yj = points[2*j+1]
    w = max(xi,xj)-min(xi,xj)
    h = max(yi,yj)-min(yi,yj)
    x = min(xi,xj)
    y = max(yi,yj)
    a = float(w*h)
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi = points[2*i]
    yi = points[2*i+1]
    xj = points[2*j]
    yj = points[2*j+1]
    w = max(xi,xj)-min(xi,xj)
    h = max(yi,yj)-min(yi,yj)
    d = float(math.sqrt(w**2 + h**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    xp1 = points[2*p1]
    yp1 = points[2*p1+1]
    xp2 = points[2*p2]
    yp2 = points[2*p2+1]
    xp3 = points[2*p3]
    yp3 = points[2*p3+1]
    xp4 = points[2*p4]
    yp4 = points[2*p4+1]
    x = ( (xp1*yp2-yp1*xp2)*(xp3-xp4)-(xp1-xp2)*(xp3*yp4-yp3*xp4) ) / ( (xp1-xp2)*(yp3-yp4)-(yp1-yp2)*(xp3-xp4) ) #สูตรสมการการหาจุดตัดของเส้นสองเส้น อ้างอิงสมการ:https://dirask.com/posts/JavaScript-calculate-intersection-point-of-two-lines-for-given-4-points-VjvnAj
    y = ( (xp1*yp2-yp1*xp2)*(yp3-yp4)-(yp1-yp2)*(xp3*yp4-yp3*xp4) ) / ( (xp1-xp2)*(yp3-yp4)-(yp1-yp2)*(xp3-xp4) )
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631003821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 664, 'const': 260, 'code+const': 924}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    xi, yi = points[(i*2):((i*2)+2)]
    xj, yj = points[(j*2):((j*2)+2)]
    x = min(xi, xj)
    y = max(yi, yj)
    w = (max(xi, xj)-min(xi, xj))
    h = (max(yi, yj)-min(yi, yj))
    return [x,y,w,h]
def middle(points,i,j):
    xi, yi = points[(i*2):((i*2)+2)]
    xj, yj = points[(j*2):((j*2)+2)]
    x = ((xi+xj)/2)
    y = ((yi+yj)/2)
    return [x,y]
def frame_area(points,i,j):
    xi, yi = points[(i*2):((i*2)+2)]
    xj, yj = points[(j*2):((j*2)+2)]
    w = (max(xi, xj)-min(xi, xj))
    h = (max(yi, yj)-min(yi, yj))
    a = (w*h)
    return float(a)
def distance(points,i,j):
    xi, yi = points[(i*2):((i*2)+2)]
    xj, yj = points[(j*2):((j*2)+2)]
    d = ((((xi-xj)**2)+((yi-yj)**2))**0.5)
    return d
def intersection(points,p1,p2,p3,p4):
    x1, y1 = points[(p1*2):((p1*2)+2)]
    x2, y2 = points[(p2*2):((p2*2)+2)]
    x3, y3 = points[(p3*2):((p3*2)+2)]
    x4, y4 = points[(p4*2):((p4*2)+2)]
    m1_2 = ((y2-y1)/(x2-x1))
    c1_2 = (y1-(m1_2*x1))
    m3_4 = ((y4-y3)/(x4-x3))
    c3_4 = (y3-(m3_4*x3))
    x = ((c3_4-c1_2)/(m1_2-m3_4))
    y = ((m1_2*x)+c1_2)
    return [x,y]

6631005021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 762, 'const': 400, 'code+const': 1162}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x1,y1=points[2*i:2*(i+1)]
    x2,y2=points[2*j:2*(j+1)]
    x=min(x1,x2 )
    y=max(y1,y2 )
    w=abs(x1-x2)
    h=abs(y1-y2)
    return [x,y,w,h]
def middle(points,i,j):
  x1,y1=points[2*i : 2*(i+1)]
  x2,y2=points[2*j : 2*(j+1)]
  x=   (x1+x2)/2
  y=   (y1+y2)/2
  return [x,y]
def frame_area(points,i,j):
    x1,y1=points[2*i:2*(i+1)]
    x2,y2=points[2*j:2*(j+1)]
    w= abs(x1-x2)
    h= abs(y1-y2)
    a=w*h
    return float(a)
def distance(points,i,j):
    x1,y1=points[2*i : 2*(i+1)]
    x2,y2=points[2*j : 2*(j+1)]
    d=math.sqrt(abs(x1  -x2 )**2+abs(y1 -y2 )**2)
    return d
def intersection(points,p1,p2,p3,p4):
    p1,p1y =points[2*p1:2*(p1+1)]
    p2,p2y =points[2*p2:2*(p2+1)]
    p3,p3y =points[2*p3:2*(p3+1)]
    p4,p4y =points[2*p4:2*(p4+1)]
    x1=(p1*p2y-p1y*p2)*(p3-p4)
    x2=(p1-p2)*(p3*p4y-p3y*p4)
    x3=(p1-p2)*(p3y-p4y)
    x4=(p1y-p2y)*(p3-p4)
    y1=(p1*p2y-p1y*p2)*(p3y-p4y)
    y2=(p1y-p2y)*(p3*p4y-p3y*p4)
    y3=(p1-p2)*(p3y-p4y)
    y4=(p1y-p2y)*(p3-p4)
    x=( x1-x2) / (x3-x4)
    y=(y1-y2) / (y3-y4)
    return [x,y]

6631011821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 592, 'const': 344, 'code+const': 936}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1=points[i*2]
  x2=points[j*2]
  y1=points[i*2+1]
  y2=points[j*2+1]
  x=min(x1,x2)
  y=max(y1,y2)
  w=abs(x1-x2)
  h=abs(y2-y1)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1=points[i*2]
  x2=points[j*2]
  y1=points[i*2+1]
  y2=points[j*2+1]
  x=(x1+x2)/2
  y=(y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x,y,w,h=frame(points,i,j)
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1=points[i*2]
  x2=points[j*2]
  y1=points[i*2+1]
  y2=points[j*2+1]
  x=abs(x1-x2)
  y=abs(y2-y1)
  d=(x**2+y**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1=points[p1*2]
  x2=points[p2*2]
  x3=points[p3*2]
  x4=points[p4*2]
  y1=points[p1*2+1]
  y2=points[p2*2+1]
  y3=points[p3*2+1]
  y4=points[p4*2+1]
  m1=(y2-y1)/(x2-x1)
  m2=(y4-y3)/(x4-x3)
  c1=y1-m1*x1
  c2=y3-m2*x3
  x=(c2-c1)/(m1-m2)
  y=m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631012421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 734, 'const': 424, 'code+const': 1158}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = min(xi,xj)
  y = max(yi,yj)
  w = abs(max(xi,xj)-min(xi,xj))
  h = abs(max(yi,yj)-min(yi,yj))
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = (xi+xj)/2
  y = (yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  a = abs((max(yi,yj)-min(yi,yj))*(max(xi,xj)-min(xi,xj)))
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  d = pow(((pow(yi-yj,2))+(pow(xi-xj,2))),0.5)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  p1x = points[2*p1]
  p1y = points[2*p1+1]
  p2x = points[2*p2]
  p2y = points[2*p2+1]
  p3x = points[2*p3]
  p3y = points[2*p3+1]
  p4x = points[2*p4]
  p4y = points[2*p4+1]
  #Line 1: p1 & p2
  mL1 = (p2y-p1y)/(p2x-p1x)
  A1 = 0-mL1
  B1 = 1
  C1 = p2y - (mL1 * p2x)
  #Line 2: p3 & p4
  mL2 = (p4y-p3y)/(p4x-p3x)
  A2 = 0-mL2
  B2 = 1
  C2 = p4y - (mL2 * p4x)
  #Intersection Point
  x = (C1*B2-C2*B1)/(A1*B2-A2*B1)
  y = (C1*A2-C2*A1)/(B1*A2-B2*A1)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4
#6631012421 ต้นศักดิ์ คล่องคำนวณการ sec8

6631014721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 914, 'const': 496, 'code+const': 1410}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    first_coor = points[2*i:(2*i)+2]
    second_coor = points[2*j:(2*j)+2]
    x = min(first_coor[0],second_coor[0])
    y = max(first_coor[1],second_coor[1])
    w = abs(first_coor[0]-second_coor[0])
    h  = abs(first_coor[1]-second_coor[1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    first_coor = points[2*i:(2*i)+2]
    second_coor = points[2*j:(2*j)+2]
    x = (first_coor[0]+second_coor[0])/2
    y = (first_coor[1]+second_coor[1])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    w=  frame(points,i,j)[2]
    h = frame(points,i,j)[3]
    a = w*h
    return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    first_coor = points[2*i:(2*i)+2]
    second_coor = points[2*j:(2*j)+2]
    x_diff = abs(first_coor[0] - second_coor[0])
    y_diff = abs(first_coor[1] - second_coor[1])
    d = math.sqrt(math.pow(x_diff,2) + math.pow(y_diff,2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    coor_1 = points[2*p1:(2*p1)+2]
    coor_2 = points[2*p2:(2*p2)+2]
    coor_3 = points[2*p3:(2*p3)+2]
    coor_4 = points[2*p4:(2*p4)+2]
    x_first_part = (coor_1[0]*coor_2[1] - coor_1[1]*coor_2[0])*(coor_3[0]-coor_4[0])
    x_second_part = (coor_1[0]-coor_2[0])*(coor_3[0]*coor_4[1] - coor_3[1]*coor_4[0])
    x_third_part = (coor_1[0]-coor_2[0])*(coor_3[1]-coor_4[1])
    x_fourth_part = (coor_1[1]-coor_2[1])*(coor_3[0]-coor_4[0])
    x = (x_first_part - x_second_part) / (x_third_part - x_fourth_part)
    y_first_part = (coor_1[0]*coor_2[1] - coor_1[1]*coor_2[0])*(coor_3[1]-coor_4[1])
    y_second_part = (coor_1[1]-coor_2[1])*(coor_3[0]*coor_4[1] - coor_3[1]*coor_4[0])
    y_third_part = (coor_1[0]-coor_2[0])*(coor_3[1]-coor_4[1])
    y_fourth_part = (coor_1[1]-coor_2[1])*(coor_3[0]-coor_4[0])
    y = (y_first_part - y_second_part) / (y_third_part - y_fourth_part)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631015321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 590, 'const': 232, 'code+const': 822}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x1,y1 = points[i*2:i*2+2]
  x2,y2 = points[j*2:j*2+2]
  x = min(x1,x2)
  y = max(y1,y2)
  w = abs(x1-x2)
  h = abs(y1-y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1,y1 = points[i*2:i*2+2]
  x2,y2 = points[j*2:j*2+2]
  x = (x1+x2)/2
  y = (y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x,y,w,h = frame(points,i,j)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1,y1 = points[i*2:i*2+2]
  x2,y2 = points[j*2:j*2+2]
  d = math.sqrt((x1-x2)**2+(y1-y2)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,y1 = points[p1*2:p1*2+2]
  x2,y2 = points[p2*2:p2*2+2]
  x3,y3 = points[p3*2:p3*2+2]
  x4,y4 = points[p4*2:p4*2+2]
  m1 = (y2-y1)/(x2-x1)
  c1 = y1-m1*x1
  m2 = (y4-y3)/(x4-x3)
  c2 = y3-m2*x3
  x = (c2-c1)/(m1-m2)
  y = m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631020421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 590, 'const': 344, 'code+const': 934}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  (x1,y1) = points[i*2:(i+1)*2]
  (x2,y2) = points[j*2:(j+1)*2]
  x = min(x1,x2)
  y = max(y1,y2)
  w = abs(x1-x2)
  h = abs(y1-y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  (xi,yi) = points[i*2:(i+1)*2]
  (xj,yj) = points[j*2:(j+1)*2]
  (x,y) = (xi+xj)/2, (yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  [x,y,w,h] = frame(points,i,j)
  a = w*h
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  (x1,y1) = points[i*2:(i+1)*2]
  (x2,y2) = points[j*2:(j+1)*2]
  d = math.sqrt(((x1-x2)**2)+((y1-y2))**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  (x1,y1) = points[p1*2:(p1+1)*2]
  (x2,y2) = points[p2*2:(p2+1)*2]
  (x3,y3) = points[p3*2:(p3+1)*2]
  (x4,y4) = points[p4*2:(p4+1)*2]
  m1 = (y2-y1)/(x2-x1)
  m2 = (y4-y3)/(x4-x3)
  c1 = y1 - (m1*x1)
  c2 = y3 - (m2*x3)
  x = -(c2-c1)/(m2-m1)
  y = m2*x + c2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631104521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 706, 'const': 428, 'code+const': 1134}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  x = min(x1,x2)
  y = max(y1,y2)
  w = abs(x1-x2)
  h = abs(y1-y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  x = (x1+x2)/2
  y = (y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  w = abs(x1-x2)
  h = abs(y1-y2)
  a = (w*h)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  w = abs(x1-x2)
  h = abs(y1-y2)
  d = math.sqrt(w**2+h**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[2*p1]
  y1 = points[2*p1+1]
  x2 = points[2*p2]
  y2 = points[2*p2+1]
  x3 = points[2*p3]
  y3 = points[2*p3+1]
  x4 = points[2*p4]
  y4 = points[2*p4+1]
  m1 = (y1-y2)/(x1-x2)
  m2 = (y3-y4)/(x3-x4)
  c1 = y1-m1*x1
  c2 = y3-m2*x3
  det = (-1*m1*1)-(-1*m2*1)
  x = ((c1*1)-(c2*1))/det
  y = ((-1*m1*c2)-(-1*m2*c1))/det
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631107421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 886, 'const': 496, 'code+const': 1382}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x=[points[2*i]]+[points[(2*i)+1]]
    y=[points[2*j]]+[points[(2*j)+1]]
    a = [x[0]] + [y[0]]
    b = [x[1]] + [y[1]]
    c = [min(a)] + [max(b)]
    d = [abs(x[0] - y[0])] + [abs(x[1] - y[1])]
    e = c + d
    return(e)
def middle(points,i,j):
    x=[points[2*i]]+[points[(2*i)+1]]
    y=[points[2*j]]+[points[(2*j)+1]]
    a = (x[0] + y[0])/2
    b = (x[1] + y[1])/2
    c=[a]+[b]
    return(c)
def frame_area(points,i,j):
    x=[points[2*i]]+[points[(2*i)+1]]
    y=[points[2*j]]+[points[(2*j)+1]]
    a = abs(x[0] - y[0]) * abs(x[1] - y[1])
    b=float(a)
    return(b)
def distance(points,i,j):
    x=[points[2*i]]+[points[(2*i)+1]]
    y=[points[2*j]]+[points[(2*j)+1]]
    import math
    a=abs(x[0]-y[0])**2
    b=abs(x[1]-y[1])**2
    c=a+b
    d=math.sqrt(c)
    return(d)
def intersection(points,p1,p2,p3,p4):
    w=[points[2*p1]]+[points[(2*p1)+1]]
    x=[points[2*p2]]+[points[(2*p2)+1]]
    y=[points[2*p3]]+[points[(2*p3)+1]]
    z=[points[2*p4]]+[points[(2*p4)+1]]
    m1=(x[1]-w[1])/(x[0]-w[0])
    m2=(z[1]-y[1])/(z[0]-y[0])
    intersectx=((-((m2*y[0])-y[1]))-(-((m1*w[0])-w[1])))/(m1-m2)
    intersecty=(m1*intersectx)-(m1*w[0])+w[1]
    return([intersectx]+[intersecty])

6631109721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 540, 'const': 232, 'code+const': 772}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1,y1=points[i*2 : (i*2)+2]
  x2,y2=points[j*2 :(j*2)+2]
  return [min(x1,x2),max(y1,y2),abs(x1-x2),abs(y1-y2)]
def middle(points,i,j):
  x1,y1=points[i*2 : (i*2)+2]
  x2,y2=points[j*2 :(j*2)+2]
  return [(x1+x2)/2,(y1+y2)/2]
def frame_area(points,i,j):
  x,y,w,h=frame(points,i,j)
  return w*h
def distance(points,i,j):
  x1,y1=points[i*2 : (i*2)+2]
  x2,y2=points[j*2 : (j*2)+2]
  return ((x2-x1)**2+(y2-y1)**2)**0.5
def intersection(points,p1,p2,p3,p4):
    x1, y1 = points[p1 * 2 : (p1 * 2) + 2]
    x2, y2 = points[p2 * 2 : (p2 * 2) + 2]
    x3, y3 = points[p3 * 2 : (p3 * 2) + 2]
    x4, y4 = points[p4 * 2 : (p4 * 2) + 2]
    m1=(y2-y1)/(x2-x1)
    m2=(y4-y3)/(x4-x3)
    c1=y1-m1*x1
    c2=y3-m2*x3
    x=(c2-c1)/(m1-m2)
    y=m1*x+c1
    return[x,y]

6631110221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 600, 'const': 344, 'code+const': 944}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x = min(points[2*i],points[2*j])
    y = max(points[(2*i)+1],points[(2*j)+1])
    w = max(points[2*i],points[2*j])-x
    h = y-min(points[(2*i)+1],points[(2*j)+1])
    return [x,y,w,h]
def middle(points,i,j):
    x = (points[2*i]+points[2*j])/2
    y = (points[(2*i)+1]+points[(2*j)+1])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x,y,w,h = frame(points,i,j)
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1,y1,x2,y2 = points[2*i],points[(2*i)+1],points[2*j],points[(2*j)+1]
    d = (((x1-x2)**2)+((y1-y2)**2))**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    m1 = (points[(2*p1)+1]-points[(2*p2)+1])/(points[2*p1]-points[2*p2])
    m2 = (points[(2*p3)+1]-points[(2*p4)+1])/(points[2*p3]-points[2*p4])
    c1 = points[(2*p1)+1]-(m1*points[2*p1])
    c2 = points[(2*p3)+1]-(m2*points[2*p3])
    x = (c2-c1)/(m1-m2)
    y = (m1*x)+c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631111921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 628, 'const': 344, 'code+const': 972}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    return [min(x1,x2),max(y1,y2),abs(x1-x2),abs(y1-y2)] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    return [float(x1+x2)/2,float(y1+y2)/2] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x,y,w,h = frame (points,i,j)
    return float(w*h) # เมื่อ w*h เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    return ((x1-x2)**2+(y1-y2)**2)**0.5 # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    p1x = points[p1*2]
    p1y = points[p1*2+1]
    p2x = points[p2*2]
    p2y = points[p2*2+1]
    p3x = points[p3*2]
    p3y = points[p3*2+1]
    p4x = points[p4*2]
    p4y = points[p4*2+1]
    intersection_x = ((p1x*p2y-p1y*p2x)*(p3x-p4x)-(p1x-p2x)*(p3x*p4y-p3y*p4x))/((p1x-p2x)*(p3y-p4y)-(p1y-p2y)*(p3x-p4x))
    intersection_y = ((p1x*p2y-p1y*p2x)*(p3y-p4y)-(p1y-p2y)*(p3x*p4y-p3y*p4x))/((p1x-p2x)*(p3y-p4y)-(p1y-p2y)*(p3x-p4x))
    return [intersection_x , intersection_y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631120521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 700, 'const': 400, 'code+const': 1100}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x = min(points[i*2],points[j*2])
  y = max(points[i*2+1],points[j*2+1])
  w = abs(points[i*2]-points[j*2])
  h = abs(points[i*2+1]-points[j*2+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[i*2]+points[j*2])/2
  y = (points[i*2+1]+points[j*2+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs(points[i*2]-points[j*2])
  h = abs(points[i*2+1]-points[j*2+1])
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x = points[j*2]-points[i*2]
  y = points[j*2+1]-points[i*2+1]
  d = (x ** 2 + y ** 2) ** 0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1, y1 = points[2*p1],points[2*p1+1]
  x2, y2 = points[2*p2],points[2*p2+1]
  x3, y3 = points[2*p3],points[2*p3+1]
  x4, y4 = points[2*p4],points[2*p4+1]
  x = ((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
  y = ((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631125721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 590, 'const': 344, 'code+const': 934}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1,y1=points[i*2:(i+1)*2]
  x2,y2=points[j*2:(j+1)*2]
  x=min(x1,x2)
  y=max(y1,y2)
  w=abs(x2-x1)
  h=abs(y2-y1)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1,y1=points[i*2:(i+1)*2]
  x2,y2=points[j*2:(j+1)*2]
  x=(x1+x2)/2
  y=(y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x,y,w,h=frame(points,i,j)
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1,y1=points[i*2:(i+1)*2]
  x2,y2=points[j*2:(j+1)*2]
  import math
  d = math.sqrt((x2-x1)**2+(y2-y1)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,y1=points[p1*2:(p1+1)*2]
  x2,y2=points[p2*2:(p2+1)*2]
  x3,y3=points[p3*2:(p3+1)*2]
  x4,y4=points[p4*2:(p4+1)*2]
  m1=(y2-y1)/(x2-x1)
  m2=(y4-y3)/(x4-x3)
  c1=-m1*x1+y1
  c2=-m2*x3+y3
  x=(c2-c1)/(m1-m2)
  y=m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631130821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 758, 'const': 496, 'code+const': 1254}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
 X = points[0::2]
 Y = points[1::2]
 Z = X[i],X[j]
 A = Y[i],Y[j]
 minx = min(Z)
 maxy = max(A)
 W = max(Z)-min(Z)
 H = max(A)-min(A)
 return [minx,maxy,W,H]
def middle(points,i,j):
 X = points[0::2]
 Y = points[1::2]
 midx = (X[i]+X[j])/2
 midy = (Y[i]+Y[j])/2
 return [midx,midy]
def frame_area(points,i,j):
 Area =  frame(points,i,j)[2]*frame(points,i,j)[3]
 return float(Area)
def distance(points,i,j):
  X = points[0::2]
  Y = points[1::2]
  Dx = X[j] - X[i]
  Dy = Y[j] - Y[i]
  dsquared = Dx**2 + Dy**2
  d = math.sqrt(dsquared)
  return d
def intersection(points,p1,p2,p3,p4):
  x = points[0::2]
  y = points[1::2]
  x1 = (x[p1]*y[p2] - y[p1]*x[p2])*(x[p3]-x[p4])-(x[p3]*y[p4] - y[p3]*x[p4])*(x[p1]-x[p2])
  x2 = (x[p1]-x[p2])*(y[p3]-y[p4]) -  (x[p3]-x[p4])*(y[p1]-y[p2])
  x3 = x1/x2
  y1= (x[p1]*y[p2] - y[p1]*x[p2])*(y[p3]-y[p4])-(x[p3]*y[p4] - y[p3]*x[p4])*(y[p1]-y[p2])
  y2 = (x[p1]-x[p2])*(y[p3]-y[p4]) -  (x[p3]-x[p4])*(y[p1]-y[p2])
  y3= y1/y2
  return [x3,y3]

6631131421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 540, 'const': 344, 'code+const': 884}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1,y1=points[i*2:(i+1)*2]
    x2,y2=points[j*2:(j+1)*2]
    return [min(x1,x2),max(y1,y2),abs(x1-x2),abs(y1-y2)]
def middle(points,i,j):
   x1,y1=points[i*2:(i+1)*2]
   x2,y2=points[j*2:(j+1)*2]
   return [(x1+x2)/2,(y1+y2)/2]
def frame_area(points,i,j):
   x,y,w,h=frame(points,i,j)
   return w*h
def distance(points,i,j):
    x1,y1=points[i*2:(i+1)*2]
    x2,y2=points[j*2:(j+1)*2]
    return  ((x1-x2)**2+(y1-y2)**2)**0.5
def intersection(points,p1,p2,p3,p4):
    x1,y1=points[p1*2:(p1+1)*2]
    x2,y2=points[p2*2:(p2+1)*2]
    x3,y3=points[p3*2:(p3+1)*2]
    x4,y4=points[p4*2:(p4+1)*2]
    m1=(y2-y1)/(x2-x1)
    c1=y1-m1*x1
    m2=(y4-y3)/(x4-x3)
    c2=y3-m2*x3
    x=(c2-c1)/(m1-m2)
    y=m1*x+c1
    return [x,y]

6631132021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 614, 'const': 520, 'code+const': 1134}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x = points[0::2]
    y = points[1::2]
    x_left = min(x[i],x[j])
    y_top = max(y[i],y[j])
    w = abs(x[i] - x[j])
    h = abs(y[i] - y[j])
    return [x_left,y_top,w,h]
def middle(points,i,j):
    x = points[0::2]
    y = points[1::2]
    a = x[i]
    b = x[j]
    mid_x = (a+b)/2
    d = y[i]
    e = y[j]
    mid_y = (d+e)/2
    return [mid_x,mid_y]
def frame_area(points,i,j):
    x = points[0::2]
    y = points[1::2]
    w = abs(x[i] - x[j])
    h = abs(y[i] - y[j])
    a = w*h
    return float(a)
def distance(points,i,j):
    x = points[0::2]
    y = points[1::2]
    a = abs(x[i] - x[j])
    b = abs(y[i] - y[j])
    d = math.sqrt(a*a + b*b)
    return float(d)
def intersection(points,p1,p2,p3,p4):
    x = points[0::2]
    y = points[1::2]
    m1 = (y[p1]-y[p2])/(x[p1]-x[p2])
    c1 = y[p1]-(m1*x[p1])
    m2 = (y[p3]-y[p4])/(x[p3]-x[p4])
    c2 = y[p3]-(m2*x[p3])
    inters_x = (c1-c2)/(m2-m1)
    inters_y = (m1*inters_x) +c1
    return [inters_x,inters_y]

6631137221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 598, 'const': 344, 'code+const': 942}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x = min(points[2*i], points[2*j])
  y = max(points[2*i + 1], points[2*j + 1])
  w = abs(points[2*i] - points[2*j])
  h = abs(points[2*i + 1] - points[2*j + 1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[2*i] + points[2*j]) / 2
  y = (points[2*i + 1] + points[2*j + 1]) / 2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x, y, w, h = frame(points, i, j)
  a = w * h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x = points[2*i] - points[2*j]
  y = points[2*i + 1] - points[2*j + 1]
  d = math.sqrt((x**2) + (y**2))
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,y1 = points[2*p1], points[2*p1 + 1]
  x2,y2 = points[2*p2], points[2*p2 + 1]
  x3,y3 = points[2*p3], points[2*p3 + 1]
  x4,y4 = points[2*p4], points[2*p4 + 1]
  m1 = (y1 - y2) / (x1 - x2)
  m2 = (y3 - y4) / (x3 - x4)
  c1 = y1 - m1 * x1 # y = mx+c
  c2 = y3 - m2 * x3
  x = (c1 - c2) / (m2 - m1) # m1x+c1 = m2x+c2 --> c1-c2 = m2x - m1x --> ดึง x ตัวร่วม
  y = (m1 * x) + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631138921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 686, 'const': 400, 'code+const': 1086}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x_i, y_i = points[2 * i], points[2 * i + 1]
    x_j, y_j = points[2 * j], points[2 * j + 1]
    x = min(x_i, x_j)
    y = max(y_i, y_j)
    w = abs(x_i - x_j)
    h = abs(y_i - y_j)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x_i, y_i = points[2 * i], points[2 * i + 1]
    x_j, y_j = points[2 * j], points[2 * j + 1]
    x = (x_i + x_j) / 2
    y = (y_i + y_j) / 2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    frame_info = frame(points, i, j)
    a = frame_info[2] * frame_info[3]
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
   x_i, y_i = points[2 * i], points[2 * i + 1]
   x_j, y_j = points[2 * j], points[2 * j + 1]
   d = math.sqrt((x_i - x_j) ** 2 + (y_i - y_j) ** 2)
   return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1, y1 = points[2 * p1], points[2 * p1 + 1]
    x2, y2 = points[2 * p2], points[2 * p2 + 1]
    x3, y3 = points[2 * p3], points[2 * p3 + 1]
    x4, y4 = points[2 * p4], points[2 * p4 + 1]
    x = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / ((x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4))
    y = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / ((x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4))
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631203021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 642, 'const': 400, 'code+const': 1042}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x = min(points[i*2],points[j*2])
  y = max(points[i*2+1],points[j*2+1])
  w = abs(points[i*2] - points[j*2])
  h = abs(points[i*2+1] - points[j*2+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[i*2] + points[j*2])/2
  y = (points[i*2+1] + points[j*2+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs(points[i*2] - points[j*2])
  h = abs(points[i*2+1] - points[j*2+1])
  a = w * h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  import math
  w = abs(points[i*2] - points[j*2])
  h = abs(points[i*2+1] - points[j*2+1])
  d = math.sqrt((w**2)+(h**2))
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
#y = m1*x+c1
#y = m2*x+c2
#x = (c2-c1)/(m1-m2)
  m1 = ((points[(p2*2)+1]) - (points[(p1*2)+1]))/((points[p2*2]) - (points[p1*2]))
  m2 = ((points[(p4*2)+1]) - (points[(p3*2)+1]))/((points[p4*2]) - (points[p3*2]))
  c1 = (points[(p1*2)+1]) - (m1*(points[p1*2]))
  c2 = (points[(p3*2)+1]) - (m2*(points[p3*2]))
  x  = (c2-c1)/(m1-m2)
  y  = m1*x + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631208121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 576, 'const': 400, 'code+const': 976}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    xi = points[i*2]
    yi = points[i*2+1]
    xj = points[j*2]
    yj = points[j*2+1]
    x = min(xi,xj)
    y = max(yi,yj)
    w = abs(xi-xj)
    h = abs(yi-yj)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi = points[i*2]
    yi = points[i*2+1]
    xj = points[j*2]
    yj = points[j*2+1]
    wide = (xi-xj)/2
    height = (yi-yj)/2
    x = xi-wide
    y = yi-height
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    ans =  frame(points,i,j)
    return float(ans[3]*ans[2]) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    ans =  frame(points,i,j)
    d = ((ans[3]**2)+(ans[2]**2))**(0.5)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2]
    y1 = points[p1*2+1]
    x2 = points[p2*2]
    y2 = points[p2*2+1]
    x3 = points[p3*2]
    y3= points[p3*2+1]
    x4 = points[p4*2]
    y4 = points[p4*2+1]
    c1=y1-(((y2-y1)/(x2-x1))*x1)
    c2=y3-(((y4-y3)/(x4-x3))*x3)
    x=(c2-c1)/(((y2-y1)/(x2-x1))-((y4-y3)/(x4-x3)))
    y=((y2-y1)/(x2-x1))*x+c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631225821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 612, 'const': 400, 'code+const': 1012}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def middle(points,i,j):
    ans = []
    ans.append((points[2*i]+points[2*j])/2)
    ans.append((points[2*i+1]+points[2*j+1])/2)
    return ans
def frame(points,i,j):
    ans = []
    ans.append(min(points[2*i],points[2*j]))
    ans.append(max(points[2*i+1],points[2*j+1]))
    ans.append(abs(points[2*i]-points[2*j]))
    ans.append(abs(points[2*i+1]-points[2*j+1]))
    return ans
def frame_area(points,i,j):
    ans = frame(points,i,j)
    return float(ans[-1]*ans[-2])
def distance(points,i,j):
    x = points[2*i] - points[2*j]
    y = points[2*i+1] - points[2*j+1]
    D = (x**2 + y**2)**(0.5)
    return D
def intersection(points,p1,p2,p3,p4):
    m1 = (points[2*p1+1] - points[2*p2+1])/(points[2*p1] - points[2*p2])
    m2 = (points[2*p3+1] - points[2*p4+1])/(points[2*p3] - points[2*p4])
    c1 = points[2*p1+1] - m1*points[2*p1]
    c2 = points[2*p3+1] - m2*points[2*p3]
    x = (c2 - c1)/(m1 - m2)
    y = m1*x + c1
    return [x,y]

6631226421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 684, 'const': 400, 'code+const': 1084}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def middle(points,i,j):
    x=((points[i*2]+points[j*2])/2) # สูตรหาจุดกึ่งกลาง
    y=((points[i*2+1]+points[j*2+1])/2) # สูตรหาจุดกึ่งกลาง
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame(points,i,j):
    x=min(points[i*2],points[j*2])
    y=max(points[i*2+1],points[j*2+1])
    w=abs(points[i*2]-points[j*2])
    h=abs(points[i*2+1]-points[j*2+1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def frame_area(points,i,j):
    x=min(points[i*2],points[j*2])
    y=max(points[i*2+1],points[j*2+1])
    w=abs(points[i*2]-points[j*2])
    h=abs(points[i*2+1]-points[j*2+1])
    a=w*h # สูตรหาพื้นที่
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x=points[i*2]-points[j*2]
    y=points[i*2+1]-points[j*2+1]
    d=(x**2+y**2)**(0.5) # สูตรการหาระยะห่างระหว่างจุด
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1,y1=points[p1*2],points[p1*2+1]
    x2,y2=points[p2*2],points[p2*2+1]
    x3,y3=points[p3*2],points[p3*2+1]
    x4,y4=points[p4*2],points[p4*2+1]
    slope1=(y2-y1)/(x2-x1) # หาความชันของเส้นที่ 1
    slope2=(y4-y3)/(x4-x3) # หาความชันของเส้นที่ 2
    a=y1-slope1*x1
    b=y3-slope2*x3
    x=(b-a)/(slope1-slope2)
    y=slope1*x+a
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631229321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 652, 'const': 400, 'code+const': 1052}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = points [i*2]
  yi = points [i*2+1]
  xj = points [j*2]
  yj = points [j*2+1]
  x = min(xi,xj)
  y = max(yi,yj)
  w = abs(xi-xj)
  h = abs(yi-yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
#points = [1,1,2,2,3,3,4,5,7,8,1,5,3,1]
  xi = points [i*2]
  yi = points [i*2+1]
  xj = points [j*2]
  yj = points [j*2+1]
  x = (xi+xj)/2
  y = (yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = points [i*2]
  yi = points [i*2+1]
  xj = points [j*2]
  yj = points [j*2+1]
  x = min(xi,xj)
  y = max(yi,yj)
  w = abs(xi-xj)
  h = abs(yi-yj)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points [i*2]
  yi = points [i*2+1]
  xj = points [j*2]
  yj = points [j*2+1]
  d = (((xi-xj)**2)+((yi-yj)**2))**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points [p1*2]
  y1 = points [p1*2+1]
  x2 = points [p2*2]
  y2 = points [p2*2+1]
  x3 = points [p3*2]
  y3 = points [p3*2+1]
  x4 = points [p4*2]
  y4 = points [p4*2+1]
  m1 = (y2-y1)/(x2-x1)
  m2 = (y4-y3)/(x4-x3)
  #y = m1*x+c1
  #y = m2*x+c2
  c1 = y1-m1*x1
  c2 = y3-m2*x3
  #m1*x+c1 = m2*x+c2
  #c2-c1 = x(m1-m2)
  x = (c2-c1)/(m1-m2)
  y = m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631317921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 682, 'const': 496, 'code+const': 1178}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    dot1 = points[i*2:i*2+2]
    dot2 = points[j*2:j*2+2]
    x = min(dot1[0], dot2[0])
    y = max(dot1[1], dot2[1])
    w = abs(dot1[0] - dot2[0])
    h = abs(dot1[1] - dot2[1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    dot1 = points[i*2:i*2+2]
    dot2 = points[j*2:j*2+2]
    x = (dot1[0] + dot2[0]) / 2
    y = (dot1[1] + dot2[1]) / 2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    w = frame(points,i,j)[2]
    h = frame(points,i,j)[3]
    a = w * h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    dot1 = points[i*2:i*2+2]
    dot2 = points[j*2:j*2+2]
    a = dot1[0] - dot2[0]
    b = dot1[1] - dot2[1]
    d = math.sqrt(a**2 + b**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    dot1 = points[p1*2:p1*2+2]
    dot2 = points[p2*2:p2*2+2]
    dot3 = points[p3*2:p3*2+2]
    dot4 = points[p4*2:p4*2+2]
    m1 = (dot2[1] - dot1[1]) / (dot2[0] - dot1[0])
    m2 = (dot4[1] - dot3[1]) / (dot4[0] - dot3[0])
    c1 = dot1[1] - (m1*dot1[0])
    c2 = dot3[1] - (m2*dot3[0])
    x = (c2 - c1) / (m1 - m2)
    y = m1*x + c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631321321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 636, 'const': 424, 'code+const': 1060}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = points[2*i]
  yi = points[2*i + 1]
  xj = points[2*j]
  yj = points[2*j + 1]
  x = min(xi, xj)
  y = max(yi, yj)
  w = abs(xj - xi)
  h = abs(yj - yi)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[2*i]
  yi = points[2*i + 1]
  xj = points[2*j]
  yj = points[2*j + 1]
  x = 0.5*(xi + xj)
  y = 0.5*(yi + yj)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = points[2*i]
  yi = points[2*i + 1]
  xj = points[2*j]
  yj = points[2*j + 1]
  width = abs(xj - xi)
  height = abs(yj - yi)
  a = width * height
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[2*i]
  yi = points[2*i + 1]
  xj = points[2*j]
  yj = points[2*j + 1]
  dx_squared = (xj - xi)**2
  dy_squared = (yj - yi)**2
  d = (dx_squared + dy_squared)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[2*p1]
  y1 = points[2*p1 + 1]
  x2 = points[2*p2]
  y2 = points[2*p2 + 1]
  x3 = points[2*p3]
  y3 = points[2*p3 + 1]
  x4 = points[2*p4]
  y4 = points[2*p4 + 1]
  m1 = (y2 - y1)/(x2 - x1)
  m2 = (y4 - y3)/(x4 - x3)
  x = (m2 * x3 - m1 * x1 + y1 - y3) / (m2 - m1)
  y = m1 * (x - x1) + y1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631324221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 690, 'const': 400, 'code+const': 1090}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    w = abs(points[2*i]-points[2*j])
    h = abs(points[(2*i)+1]-points[(2*j)+1])
    middle_frame_x = (((points[(2*i)])+(points[(2*j)]))/2)
    middle_frame_y = (((points[(2*i)+1])+(points[(2*j)+1]))/2)
    x = int(middle_frame_x - (w/2))
    y = int(middle_frame_y + (h/2))
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x = float(((points[(2*i)])+(points[(2*j)]))/2)
    y = float(((points[(2*i)+1])+(points[(2*j)+1]))/2)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    w = abs(points[2*i]-points[2*j])
    h = abs(points[(2*i)+1]-points[(2*j)+1])
    a =  float(w*h)
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    d = float(math.sqrt((((points[(2*i)])-(points[2*j]))**2) + ((((points[(2*i)+1])-(points[(2*j)+1]))**2))))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    p1_x,p1_y = points[(2*p1)],points[(2*p1)+1]
    p2_x,p2_y = points[(2*p2)],points[(2*p2)+1]
    p3_x,p3_y = points[(2*p3)],points[(2*p3)+1]
    p4_x,p4_y = points[(2*p4)],points[(2*p4)+1]
    m_line1 = (p2_y-p1_y)/(p2_x-p1_x)
    m_line2 = (p4_y-p3_y)/(p4_x-p3_x)
    cons1 = p1_y - (m_line1 * p1_x)
    cons2 = p3_y - (m_line2 * p3_x)
    x = float(cons2-cons1)/(m_line1-m_line2)
    y = float((m_line1*x)+cons1)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631325921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 598, 'const': 400, 'code+const': 998}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math as m
def frame(points,i,j):
    i = i*2
    j = j*2
    x = min(points[i],points[j])
    y = max(points[i+1],points[j+1])
    w = abs(points[i]-points[j])
    h = abs(points[i+1]-points[j+1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    i=i*2
    j=j*2
    x=(points[i]+points[j])/2
    y=(points[i+1]+points[j+1])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    i = i*2
    j = j*2
    w = abs(points[i]-points[j])
    h = abs(points[i+1]-points[j+1])
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    i = i*2
    j = j*2
    d = m.sqrt(((points[i]-points[j])**2)+((points[i+1]-points[j+1])**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    p1 = p1*2
    p2 = p2*2
    p3 = p3*2
    p4 = p4*2
    m1 = (points[p1+1]-points[p2+1]) / (points[p1]-points[p2])
    m2 = (points[p3+1]-points[p4+1]) / (points[p3]-points[p4])
    c1 = points[p1+1] - (m1*points[p1])
    c2 = points[p3+1] - (m2*points[p3])
    x = (c2-c1)/(m1-m2)
    y = (m1*x) + c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631329421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 648, 'const': 472, 'code+const': 1120}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  first_point = [points[i*2],points[i*2+1]]
  second_point = [points[j*2],points[j*2+1]]
  x = min(first_point[0],second_point[0])
  y = max(first_point[1],second_point[1])
  w = abs(first_point[0]-second_point[0])
  h = abs(first_point[1]-second_point[1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  first_point = [points[i*2],points[i*2+1]]
  second_point = [points[j*2],points[j*2+1]]
  x = (first_point[0]+second_point[0])/2
  y = (first_point[1]+second_point[1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  result = frame(points,i,j)
  a = result[2]*result[3]
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  first_point = [points[i*2],points[i*2+1]]
  second_point = [points[j*2],points[j*2+1]]
  d = ((first_point[0]-second_point[0])**2+(first_point[1]-second_point[1])**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  first_slope = (points[p1*2+1]-points[p2*2+1])/(points[p1*2]-points[p2*2])
  second_slope = (points[p3*2+1]-points[p4*2+1])/(points[p3*2]-points[p4*2])
  first_intercept = points[p1*2+1]-first_slope*points[p1*2]
  second_intercept = points[p3*2+1]-second_slope*points[p3*2]
  x = (second_intercept-first_intercept)/(first_slope-second_slope)
  y = first_slope*x+first_intercept
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631343121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 708, 'const': 496, 'code+const': 1204}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = points[0+2*i]
  yi = points[1+2*i]
  xj = points[0+2*j]
  yj = points[1+2*j]
  x = min(xi,xj)
  y = max(yi,yj)
  w = abs(xi-xj)
  h = abs(yi-yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[0+2*i]
  yi = points[1+2*i]
  xj = points[0+2*j]
  yj = points[1+2*j]
  x = (xi+xj)/2
  y = (yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = points[0+2*i]
  yi = points[1+2*i]
  xj = points[0+2*j]
  yj = points[1+2*j]
  w = abs(xi-xj)
  h = abs(yi-yj)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  import math
  xi = points[0+2*i]
  yi = points[1+2*i]
  xj = points[0+2*j]
  yj = points[1+2*j]
  w = abs(xi-xj)
  h = abs(yi-yj)
  d = math.sqrt(w**2+h**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  p1x = points[0+2*p1]
  p1y = points[1+2*p1]
  p2x = points[0+2*p2]
  p2y = points[1+2*p2]
  p3x = points[0+2*p3]
  p3y = points[1+2*p3]
  p4x = points[0+2*p4]
  p4y = points[1+2*p4]
  m12 = (p2y-p1y)/(p2x-p1x)
  m34 = (p4y-p3y)/(p4x-p3x)
  c12 = p1y-m12*p1x
  c34 = p3y-m34*p3x
  x = (-(c34-c12))/(m34-m12)
  y = m12*x+c12
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631344821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
from math import *
def frame(points,i,j):
    xi = points[0 + 2 * i]
    yi = points[1 + 2 * i]
    xj = points[0 + 2 * j]
    yj = points[1 + 2 * j]
    x=min(xi,xj)
    y=max(yi,yj)
    w=abs(xi-xj)
    h=abs(yi-yj)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi = points[0 + 2 * i]
    yi = points[1 + 2 * i]
    xj = points[0 + 2 * j]
    yj = points[1 + 2 * j]
    a = (xi + xj)/2
    b = (yi + yj)/2
    x = float(a)
    y = float(b)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi = points[0 + 2 * i]
    yi = points[1 + 2 * i]
    xj = points[0 + 2 * j]
    yj = points[1 + 2 * j]
    c=abs(xi-xj)
    b=abs(yi-yj)
    a=float(c)*float(b)
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi = points[0 + 2 * i]
    yi = points[1 + 2 * i]
    xj = points[0 + 2 * j]
    yj = points[1 + 2 * j]
    a=xi - xj
    b=yi - yj
    d= sqrt((a**2) + (b**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    xi = points[0 + 2 * p1]
    yi = points[1 + 2 * p1]
    xj = points[0 + 2 * p2]
    yj = points[1 + 2 * p2]
    xu = points[0 + 2 * p3]
    yu = points[1 + 2 * p3]
    xv = points[0 + 2 * p4]
    yv = points[1 + 2 * p4]
    m1=(yj-yi)/(xj-xi)
    m2=(yv-yu)/(xv-xu)
    c1=yi-(xi*m1)
    c2=yu-(xu*m2)
    a=(c1-c2)/(m2-m1)
    b=((c1*m2)-(c2*m1))/(m2-m1)
    x=a
    y=b
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631348321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 720, 'const': 400, 'code+const': 1120}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    xi = points[2*i]
    yi = points[2*i + 1]
    xj = points[2*j]
    yj = points[2*j + 1]
    x = min(xi,xj)
    y = max(yi,yj)
    w = abs(xi-xj)
    h = abs(yi-yj)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi = points[2*i]
    yi = points[2*i + 1]
    xj = points[2*j]
    yj = points[2*j + 1]
    x = (xi + xj)/2
    y = (yi + yj)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi = points[2*i]
    yi = points[2*i + 1]
    xj = points[2*j]
    yj = points[2*j + 1]
    x = abs(xi-xj)
    y = abs(yi-yj)
    a = x*y
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi = points[2*i]
    yi = points[2*i + 1]
    xj = points[2*j]
    yj = points[2*j + 1]
    d = float(((xi-xj)**2 + (yi-yj)**2)**(1/2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[2*p1]
    y1 = points[2*p1 + 1]
    x2 = points[2*p2]
    y2 = points[2*p2 + 1]
    x3 = points[2*p3]
    y3 = points[2*p3 + 1]
    x4 = points[2*p4]
    y4 = points[2*p4 + 1]
    x = float(((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4)))
    y = float(((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4)))
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631351121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 646, 'const': 400, 'code+const': 1046}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
#   dot1 = (points[2*i],points[(2*i)+1])
#   dot2 = (points[2*j],points[(2*j)+1])
    x = min(points[2*i],points[2*j])
    y = max(points[(2*i)+1],points[(2*j)+1])
    w = abs(points[2*i] - points[2*j])
    h = abs(points[(2*i)+1] - points[(2*j)+1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
#   dot1 = (points[2*i],points[(2*i)+1])
#   dot2 = (points[2*j],points[(2*j)+1])
    x = (points[2*i] + points[2*j]) / 2
    y = (points[(2*i)+1] + points[(2*j)+1]) / 2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
#   dot1 = (points[2*i],points[(2*i)+1])
#   dot2 = (points[2*j],points[(2*j)+1])
    x = abs(points[2*i] - points[2*j])
    y = abs(points[(2*i)+1] - points[(2*j)+1])
    a = x * y
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
#   dot1 = (points[2*i],points[(2*i)+1])
#   dot2 = (points[2*j],points[(2*j)+1])
    x = abs(points[2*i] - points[2*j])
    y = abs(points[(2*i)+1] - points[(2*j)+1])
    d = math.sqrt((x ** 2) + (y ** 2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
# def intersection(points,p1,p2,p3,p4):
# #   dot1 = (points[2*p1],points[(2*p1)+1])
# #   dot2 = (points[2*p2],points[(2*p2)+1])
# #   dot3 = (points[2*p3],points[(2*p3)+1])
# #   dot4 = (points[2*p4],points[(2*p4)+1])
#     m1 = (points[(2*p1)+1] - points[(2*p2)+1]) / (points[2*p1] - points[2*p2])
#     c1 = points[(2*p1)+1] - (points[2*p1] * m1)
#     m2 = (points[(2*p3)+1] - points[(2*p4)+1]) / (points[2*p3] - points[2*p4])
#     c2 = points[(2*p3)+1] - (points[2*p3] * m1)
#     x = (c1 - c2) / (m2 - m1)
#     y = (m1 * x) + c1
def intersection(points, p1, p2, p3, p4):
    x1, y1 = points[2*p1], points[(2*p1)+1]
    x2, y2 = points[2*p2], points[(2*p2)+1]
    x3, y3 = points[2*p3], points[(2*p3)+1]
    x4, y4 = points[2*p4], points[(2*p4)+1]
    m1 = (y1 - y2) / (x1 - x2)
    c1 = y1 - (x1 * m1)
    m2 = (y3 - y4) / (x3 - x4)
    c2 = y3 - (x3 * m2)
    x = (c1 - c2) / (m2 - m1)
    y = (m1 * x) + c1
    return [x, y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4
# points=[1,1,2,2,3,3,4,5,7,8,1,5,3,1]
# print(frame(points,1,3))
# print(middle(points,0,2))
# print(frame_area(points,1,3))
# print(distance(points,1,2))
# print(intersection(points,5,6,1,2))

6631365021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 648, 'const': 424, 'code+const': 1072}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x = min(points[i*2],points[j*2])
    y = max(points[i*2+1],points[j*2+1])
    w = abs(points[j*2] - points[i*2])
    h = abs(points[j*2+1] - points[i*2+1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x = (points[i*2]+points[j*2])/2
    y = (points[i*2+1]+points[j*2+1])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    a = abs(points[j*2] - points[i*2]) * abs(points[j*2+1] - points[i*2+1])
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    d = ((points[i*2+1]-points[j*2+1])**2+(points[i*2]-points[j*2])**2)**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    p1 = [points[p1*2],points[p1*2+1]]
    p2 = [points[p2*2],points[p2*2+1]]
    p3 = [points[p3*2],points[p3*2+1]]
    p4 = [points[p4*2],points[p4*2+1]]
    a = (p2[1]-p1[1])/(p2[0]-p1[0])
    b = (p4[1]-p3[1])/(p4[0]-p3[0])
    c1 = p2[1]-(a)*p2[0]
    c2 = p4[1]-(b)*p4[0]
    x = (c2-c1)/(a-b)
    y = a*x + c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631452921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 592, 'const': 368, 'code+const': 960}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    xi = points[i*2]
    xj = points[j*2]
    yi = points[(i*2)+1]
    yj = points[(j*2)+1]
    xmin = min(xi,xj)
    ymax = max(yi,yj)
    w = max(xi,xj)-min(xi,xj)
    h = max(yi,yj)-min(yi,yj)
    return [xmin,ymax,w,h]
def middle(points,i,j):
    xi = points[i*2]
    xj = points[j*2]
    yi = points[(i*2)+1]
    yj = points[(j*2)+1]
    x = (xi+xj)/2
    y = (yi+yj)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    a,b,c,d = frame(points,i,j)
    return float(c*d)
def distance(points,i,j):
    xi = points[i*2]
    xj = points[j*2]
    yi = points[(i*2)+1]
    yj = points[(j*2)+1]
    return ((xj-xi)**2+(yj-yi)**2)**(1/2)
def intersection(points,p1,p2,p3,p4):
    xi,yi = points[p1*2:(p1+1)*2]
    xj,yj = points[p2*2:(p2+1)*2]
    xs,ys = points[p3*2:(p3+1)*2]
    xu,yu = points[p4*2:(p4+1)*2]
    s1 = (yj-yi)/(xj-xi)
    c1 = yi-(s1*xi)
    s2 = (yu-ys)/(xu-xs)
    c2 = ys-(s2*xs)
    x = (c2-c1)/(s1-s2)
    y = (s1*x)+c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631461521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 850, 'const': 400, 'code+const': 1250}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def middle(points, i, j):
    x_mid = (points[2*i] + points[2*j]) / 2
    y_mid = (points[2*i+1] + points[2*j+1]) / 2
    return [x_mid, y_mid]
def frame(points, i, j):
    x_min = min(points[2*i], points[2*j])
    x_max = max(points[2*i], points[2*j])
    y_min = min(points[2*i+1], points[2*j+1])
    y_max = max(points[2*i+1], points[2*j+1])
    return [x_min, y_max, x_max - x_min, y_max - y_min]
def frame_area(points, i, j):
    frame_data = frame(points, i, j)
    return frame_data[2] * frame_data[3]
def distance(points, i, j):
    x_diff = points[2*i] - points[2*j]
    y_diff = points[2*i+1] - points[2*j+1]
    return math.sqrt(x_diff**2 + y_diff**2)
def intersection(points, p1, p2, p3, p4):
    x_num = (points[2*p1] * points[2*p2+1] - points[2*p1+1] * points[2*p2]) * (points[2*p3] - points[2*p4]) - (points[2*p1] - points[2*p2]) * (points[2*p3] * points[2*p4+1] - points[2*p3+1] * points[2*p4])
    y_num = (points[2*p1] * points[2*p2+1] - points[2*p1+1] * points[2*p2]) * (points[2*p3+1] - points[2*p4+1]) - (points[2*p1+1] - points[2*p2+1]) * (points[2*p3] * points[2*p4+1] - points[2*p3+1] * points[2*p4])
    denom = (points[2*p1] - points[2*p2]) * (points[2*p3+1] - points[2*p4+1]) - (points[2*p1+1] - points[2*p2+1]) * (points[2*p3] - points[2*p4])
    x_inter = x_num / denom
    y_inter = y_num / denom
    return [x_inter, y_inter]

6631465021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 798, 'const': 400, 'code+const': 1198}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
 x1 = points[i*2]
 y1 = points[(i*2)+1]
 x2 = points[j*2]
 y2 = points[(j*2)+1]
 maxx = max(x1,x2)
 minx = min(x1,x2)
 maxy = max(y1,y2)
 miny = min(y1,y2)
 x = minx
 y = maxy
 w = maxx-minx
 h = maxy-miny
 return [x,y,w,h]
 # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
 x1 = points[i*2]
 y1 = points[(i*2)+1]
 x2 = points[j*2]
 y2 = points[(j*2)+1]
 maxx = max(x1,x2)
 minx = min(x1,x2)
 maxy = max(y1,y2)
 miny = min(y1,y2)
 x = ((maxx-minx)/2)+minx
 y = ((maxy-miny)/2)+miny
 return [x,y]
 # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
 x1 = points[i*2]
 y1 = points[(i*2)+1]
 x2 = points[j*2]
 y2 = points[(j*2)+1]
 maxx = max(x1,x2)
 minx = min(x1,x2)
 maxy = max(y1,y2)
 miny = min(y1,y2)
 w = maxx-minx
 h = maxy-miny
 a = w*h
 return float(a)
 # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
 x1 = points[i*2]
 y1 = points[(i*2)+1]
 x2 = points[j*2]
 y2 = points[(j*2)+1]
 maxx = max(x1,x2)
 minx = min(x1,x2)
 maxy = max(y1,y2)
 miny = min(y1,y2)
 ex = pow(maxx-minx,2)
 ey = pow(maxy-miny,2)
 d = math.sqrt(ex+ey)
 return d
 # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
 x1 = points[p1*2]
 y1 = points[(p1*2)+1]
 x2 = points[p2*2]
 y2 = points[(p2*2)+1]
#l1
 x3 = points[p3*2]
 y3 = points[(p3*2)+1]
 x4 = points[p4*2]
 y4 = points[(p4*2)+1]
#l2
 m1 = (y2-y1)/(x2-x1)
 m2 = (y4-y3)/(x4-x3)
 c1 = y1 - (m1*x1)
 c2 = y3 - (m2*x3)
 #x*m1+c1=xm2+c2
 #x*(m1-m2)=c2-c1
 #x=(c2-c1)/(m1-m2)
 x = (c2-c1)/(m1-m2)
 y = (m1*x) + c1
 return [x,y]
 # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631469621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 576, 'const': 344, 'code+const': 920}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1,y1 = points[i*2 : (i+1)*2]
  x2,y2 = points[j*2 : (j+1)*2]
  x = min(x1,x2)
  y = max(y1,y2)
  w = abs(x2-x1)
  h = abs(y2-y1)
  return [x,y,w,h]
def middle(points,i,j):
  x1,y1 = points[i*2 : (i+1)*2]
  x2,y2 = points[j*2 : (j+1)*2]
  x = (x1+x2)/2
  y = (y1+y2)/2
  return [x,y]
def frame_area(points,i,j):
  x,y,w,h = frame(points,i,j)
  a = w*h
  return float(a)
def distance(points,i,j):
  x1,y1 = points[i*2 : (i+1)*2]
  x2,y2 = points[j*2 : (j+1)*2]
  d = ((x2-x1)**2 + (y2-y1)**2)**0.5
  return d
def intersection(points,p1,p2,p3,p4):
  x1,y1 = points[p1*2 : (p1+1)*2]
  x2,y2 = points[p2*2 : (p2+1)*2]
  x3,y3 = points[p3*2 : (p3+1)*2]
  x4,y4 = points[p4*2 : (p4+1)*2]
  m1 = (y2-y1)/(x2-x1)
  m2 = (y4-y3)/(x4-x3)
  c1 = y1 - m1*x1
  c2 = y3 - m2*x3
  x = (c2-c1)/(m1-m2)
  y = m1*x + c1
  return [x,y]

6631470121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 674, 'const': 344, 'code+const': 1018}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  xi, yi = points[2*i], points[2*i+1]
  xj, yj = points[2*j], points[2*j+1]
  x_l = min(xi, xj)
  x_r = max(xi, xj)
  y_t = max(yi, yj)
  y_b = min(yi, yj)
  w = x_r - x_l
  h = y_t - y_b
  return [x_l,y_t,w,h] # เมื่อ x_l,y_t เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi, yi = points[2*i], points[2*i+1]
  xj, yj = points[2*j], points[2*j+1]
  x = (xi + xj) / 2
  y = (yi + yj) / 2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  _, _, width, height = frame(points, i, j)
  a = width * height
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi, yi = points[2*i], points[2*i+1]
  xj, yj = points[2*j], points[2*j+1]
  d = math.sqrt((xj - xi)**2 + (yj - yi)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1, y1 = points[2*p1], points[2*p1+1]
  x2, y2 = points[2*p2], points[2*p2+1]
  x3, y3 = points[2*p3], points[2*p3+1]
  x4, y4 = points[2*p4], points[2*p4+1]
  det = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)
  x = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / det
  y = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / det
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631501021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 618, 'const': 400, 'code+const': 1018}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x1 = points[2*i]
    y1 = points[2*i+1]
    x2 = points[2*j]
    y2 = points[2*j+1]
    x = min([x1,x2])
    y = max([y1,y2])
    w = abs(x1-x2)
    h = abs(y1-y2)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x1 = points[2*i]
    y1 = points[2*i+1]
    x2 = points[2*j]
    y2 = points[2*j+1]
    x = (x1+x2)/2
    y = (y1+y2)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    info = frame(points,i,j)
    a = info[2]*info[3]
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1 = points[2*i]
    y1 = points[2*i+1]
    x2 = points[2*j]
    y2 = points[2*j+1]
    x = abs(x1-x2)
    y = abs(y1-y2)
    d = math.sqrt(x**2+y**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    m1 = (points[(p1*2)+1]-points[(p2*2)+1])/(points[(p1*2)]-points[(p2*2)])
    m2 = (points[(p3*2)+1]-points[(p4*2)+1])/(points[(p3*2)]-points[(p4*2)])
    c1 = points[(p1*2)+1] - m1*points[(p1*2)]
    c2 =  points[(p3*2)+1] - m2*points[(p3*2)]
    x = (c1-c2)/(m2-m1)
    y = m1*x+c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631503221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 632, 'const': 400, 'code+const': 1032}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1,y1=points[i*2:(i+1)*2]
  x2,y2=points[j*2:(j+1)*2]
  x=min(x1,x2)
  y=max(y1,y2)
  w=abs(x1-x2)
  h=abs(y1-y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1,y1=points[i*2:(i+1)*2]
  x2,y2=points[j*2:(j+1)*2]
  x=(x1+x2)/2
  y=(y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1,y1=points[i*2:(i+1)*2]
  x2,y2=points[j*2:(j+1)*2]
  w=abs(x1-x2)
  h=abs(y1-y2)
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1,y1=points[i*2:(i+1)*2]
  x2,y2=points[j*2:(j+1)*2]
  d=((x1-x2)**2+(y1-y2)**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,y1=points[p1*2:(p1+1)*2]
  x2,y2=points[p2*2:(p2+1)*2]
  x3,y3=points[p3*2:(p3+1)*2]
  x4,y4=points[p4*2:(p4+1)*2]
  m1=(y2-y1)/(x2-x1)
  c1=y1-m1*x1
  m2=(y4-y3)/(x4-x3)
  c2=y3-m2*x3
  x=(c2-c1)/(m1-m2)
  y=m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631505521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 576, 'const': 400, 'code+const': 976}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def middle(points, i, j):
  x_mid = (2*i)
  y_mid = (2*j)
  x1,y1 = points[x_mid],points[x_mid+1]
  x2,y2 = points[y_mid],points[y_mid+1]
  a = (x1+x2)/2
  b = (y1+y2)/2
  return [a,b]
def frame(points, i, j):
  xi = points[i * 2]
  yi = points[i * 2 + 1]
  xj = points[j * 2]
  yj = points[j * 2 + 1]
  y_max = max(yi, yj)
  y_min = min(yi, yj)
  x_min = min(xi, xj)
  x_max = max(xi, xj)
  width = abs(x_min - x_max)
  height = abs(y_min - y_max)
  return ([x_min, y_max, width, height])
def frame_area(points, i, j):
  x = frame(points, i, j)
  return (x[2] * x[3])
def distance(points, i, j):
  x = frame(points, i, j)
  width = x[2]
  height = x[3]
  return (math.sqrt(width**2 + height**2))
def intersection(points, p1, p2, p3, p4):
  x_1, y_1 = points[p1 * 2], points[p1 * 2 + 1]
  x_2, y_2 = points[p2 * 2], points[p2 * 2 + 1]
  x_3, y_3 = points[p3 * 2], points[p3 * 2 + 1]
  x_4, y_4 = points[p4 * 2], points[p4 * 2 + 1]
  m1 = (y_2-y_1)/(x_2-x_1)
  m2 = (y_4-y_3)/(x_4-x_3)
  c1 = y_1 - m1*x_1
  c2 = y_3 - m2*x_3
  x = (c2-c1)/(m1-m2)
  y = (m1*x)+c1
  return [x,y]

6631511221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 544, 'const': 260, 'code+const': 804}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1,y1=points[i*2:2*i+2]
  x2,y2=points[j*2:2*j+2]
  return [min(x1,x2),max(y1,y2),abs(x1-x2),abs(y1-y2)]
def middle(points,i,j):
  x1,y1=points[i*2:2*i+2]
  x2,y2=points[j*2:2*j+2]
  return [(x1+x2)/2,(y1+y2)/2]
def frame_area(points,i,j):
  x,y,a,b=frame(points,i,j)
  return a*b
def distance(points,i,j):
  x1,y1=points[i*2:2*i+2]
  x2,y2=points[j*2:2*j+2]
  return ((x1-x2)**2+(y1-y2)**2)**0.5
def intersection(points,p1,p2,p3,p4):
  x1,y1=points[p1*2:2*p1+2]
  x2,y2=points[p2*2:2*p2+2]
  x3,y3=points[p3*2:2*p3+2]
  x4,y4=points[p4*2:2*p4+2]
  m1=(y1-y2)/(x1-x2)
  m2=(y3-y4)/(x3-x4)
  x=(((-1)*m2*x3)+(y3)+(m1*x1)-y1)/(m1-m2)
  y=m1*x-m1*x2+y2
  return (x,y)

6631513521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 568, 'const': 400, 'code+const': 968}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1=points[i*2]
    y1=points[(i*2)+1]
    x2=points[j*2]
    y2=points[(j*2)+1]
    x=min(x1,x2)
    y=max(y1,y2)
    w=abs(x2-x1)
    h=abs(y2-y1)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x=(points[i*2]+points[j*2])/2
    y=(points[(i*2)+1]+points[(j*2)+1])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    frame_=(frame(points,i,j))
    w=frame_[2]
    h=frame_[3]
    a=w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1=points[i*2]
    y1=points[(i*2)+1]
    x2=points[j*2]
    y2=points[(j*2)+1]
    d=((x1-x2)**2+(y1-y2)**2)**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1=points[p1*2]
    y1=points[(p1*2)+1]
    x2=points[p2*2]
    y2=points[(p2*2)+1]
    x3=points[p3*2]
    y3=points[(p3*2)+1]
    x4=points[p4*2]
    y4=points[(p4*2)+1]
    ml1=(y2-y1)/(x2-x1)
    ml2=(y4-y3)/(x4-x3)
    cl1=y1-(ml1*x1)
    cl2=y3-(ml2*x3)
    x=(cl1-cl2)/(ml2-ml1)
    y=(ml1*x)+cl1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631514121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 708, 'const': 260, 'code+const': 968}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1, y1 = points[i*2:i*2 + 2]
  x2, y2 = points[j*2:j*2 + 2]
  x = min(x1,x2)
  y = max(y1,y2)
  w = abs(x1-x2)
  h = abs(y1-y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
   x1, y1 = points[i*2:i*2 + 2]
   x2, y2 = points[j*2:j*2 + 2]
   x = (x1 + x2)/2
   y = (y1 + y2)/2
   return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x1, y1 = points[i*2:i*2 + 2]
    x2, y2 = points[j*2:j*2 + 2]
    w = abs(x1-x2)
    h = abs(y1-y2)
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
   x1, y1 = points[i*2:i*2 + 2]
   x2, y2 = points[j*2:j*2 + 2]
   d = ((x1 - x2)**2 + (y1 - y2)**2)**0.5
   return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
   x1, y1 = points[p1*2:p1*2 + 2]
   x2, y2 = points[p2*2:p2*2 + 2]
   x3, y3 = points[p3*2:p3*2 + 2]
   x4, y4 = points[p4*2:p4*2 + 2]
   x = ((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
   y = ((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4))
   return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631515821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 588, 'const': 368, 'code+const': 956}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    ca = points[i*2]
    da = points[(i*2)+1]
    cb = points[j*2]
    db = points[(j*2)+1]
    x = min(ca,cb)
    y = max(da,db)
    w = abs(ca-cb)
    h = abs(da-db)
    return[x,y,w,h]  # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    ca = points[i*2]
    da = points[(i*2)+1]
    cb = points[j*2]
    db = points[(j*2)+1]
    x = (ca+cb)/2
    y = (da+db)/2
    return[x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x,y,w,h = frame(points,i,j)
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    ca = points[i*2]
    da = points[(i*2)+1]
    cb = points[j*2]
    db = points[(j*2)+1]
    d = ((cb-ca)**2+(db-da)**2)**0.5
    return float(d) # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    sa = points[p1*2]
    ta = points[(p1*2)+1]
    sb = points[p2*2]
    tb = points[(p2*2)+1]
    sc = points[p3*2]
    tc = points[(p3*2)+1]
    sd = points[p4*2]
    td = points[(p4*2)+1]
    i1 = (tb-ta)/(sb-sa)
    j1 = ta-(i1*sa)
    i2 = (td-tc)/(sd-sc)
    j2 = tc-(i2*sc)
    x = (j2-j1)/(i1-i2)
    y = (i1*x)+j1
    return[x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631516421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4.0, -2.0, -7.0, 4.0, -2.0, -7.0, 5.0, -7.0, -2.0, -7.0],
 [2.0, 3.0, 1.0, 1.0, 3.0, 2.0, 2.0, 3.0, 3.0, -3.0],
 [5.0, 6.0, 11.0, 1.0, 11.0, 16.0, 4.0, 5.0, 7.0, 12.0],
 [1.0, 2.0, 5.0, 4.0, 1.0, 6.0, 5.0, 7.0, 6.0, 1.0]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 750, 'const': 400, 'code+const': 1150}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x_i,y_i = points[i*2],points[(i*2)+1]
  x_j,y_j = points[j*2],points[(j*2)+1]
  x_i = float(x_i)
  y_i = float(y_i)
  x_j = float(x_j)
  y_j = float(y_j)
  x = min(x_i,x_j)
  y = max(y_i,y_j)
  w = abs(x_i-x_j)
  h = abs(y_i-y_j)
  return [x,y,w,h]
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x_i,y_i = points[i*2],points[(i*2)+1]
    x_j,y_j = points[j*2],points[(j*2)+1]
    x_i = float(x_i)
    y_i = float(y_i)
    x_j = float(x_j)
    y_j = float(y_j)
    x = ((x_i + x_j)/2)
    y = ((y_i + y_j)/2)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    w = frame(points,i,j)[2]
    h = frame(points,i,j)[3]
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j): # x-x **2 + y-y**2 **1/2
    x_i,y_i = points[i*2],points[(i*2)+1]
    x_j,y_j = points[j*2],points[(j*2)+1]
    x_i = float(x_i)
    y_i = float(y_i)
    x_j = float(x_j)
    y_j = float(y_j)
    d = math.sqrt(((x_i - x_j)**2) + ((y_i - y_j)**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x_p1,y_p1 = points[p1*2],points[(p1*2)+1] #p1p3 = x p2p4 = y
    x_p2,y_p2 = points[p2*2],points[(p2*2)+1]
    x_p3,y_p3 = points[p3*2],points[(p3*2)+1]
    x_p4,y_p4 = points[p4*2],points[(p4*2)+1]
    x_p1 = float(x_p1)
    x_p2 = float(x_p2)
    x_p3 = float(x_p3)
    x_p4 = float(x_p4)
    m1 = ((y_p1)-(y_p2))/((x_p1)-(x_p2))
    m3 = ((y_p3)-(y_p4))/((x_p3)-(x_p4)) # y = mx + c Ffp c = y - mx
    c_eq1 = (y_p1) - ((m1)*(x_p1))
    c_eq2 = (y_p3) - ((m3)*(x_p3)) # eq1 = eq2 x = y=0 / y = x = 0
    x = (c_eq1 -c_eq2)/(m3-m1)
    y = m1*x + c_eq1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631518721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 666, 'const': 400, 'code+const': 1066}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  i = i*2 #เนื่องจาก index ตัวแหน่งที่ i มี 2 ตัว ==> XiYi
  j = j*2 #เนื่องจาก index ตัวแหน่งที่ j มี 2 ตัว ==> XjYj
  x1, x2, y1, y2 = points[i], points[j], points[i+1], points[j+1]
  #x,y เป็นพิกัดของจุดบนซ้าย
  x = min(x1, x2)
  y = max(y1, y2)
  #w,h เป็นความกว้างและความสูงของเฟรม
  w = abs(x2 - x1)
  h = abs(y2 - y1)
  return [x,y,w,h]
def middle(points,i,j):
  i = i*2 #เนื่องจาก index ตัวแหน่งที่ i มี 2 ตัว ==> XiYi
  j = j*2 #เนื่องจาก index ตัวแหน่งที่ j มี 2 ตัว ==> XjYj
  x1, x2, y1, y2 = points[i], points[j], points[i+1], points[j+1]
  x = (x1 + x2) / 2 #หาจุดกึ่งกลางของ x
  y = (y1 + y2) / 2 #หาจุดกึ่งกลางของ y
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  i = i*2 #เนื่องจาก index ตัวแหน่งที่ i มี 2 ตัว ==> XiYi
  j = j*2 #เนื่องจาก index ตัวแหน่งที่ j มี 2 ตัว ==> XjYj
  x1, x2, y1, y2 = points[i], points[j], points[i+1], points[j+1]
  #w,h เป็นความกว้างและความสูงของเฟรม
  w = abs(x2 - x1)
  h = abs(y2 - y1)
  a = w*h #area = กว้าง x ยาว
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  i = i*2 #เนื่องจาก index ตัวแหน่งที่ i มี 2 ตัว ==> XiYi
  j = j*2 #เนื่องจาก index ตัวแหน่งที่ j มี 2 ตัว ==> XjYj
  x1, x2, y1, y2 = points[i], points[j], points[i+1], points[j+1]
  d = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  p1 = p1*2
  p2 = p2*2
  p3 = p3*2
  p4 = p4*2
  x1, y1, x2, y2 = points[p1], points[p1+1], points[p2], points[p2+1]
  x3, y3, x4, y4 = points[p3], points[p3+1], points[p4], points[p4+1]
  # คำนวณค่าความชันของเส้นตรงที่ 1 (m1) และเส้นตรงที่ 2 (m2)
  m1 = (y2 - y1) / (x2 - x1)
  m2 = (y4 - y3) / (x4 - x3)
  # คำนวณค่าจุดตัด x จาก m1(x-x1)+y1 = m2(x-x3)+y3
  x = ((m1*x1)-(m2*x3)+(y3)-(y1))/(m1-m2)
  # คำนวณค่าจุดตัด y โดยใช้สมการของเส้นตรงที่ 1 (y =mx+c)
  y = m1 * (x - x1) + y1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4
#-----------------------------------------------------

6631519321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 632, 'const': 400, 'code+const': 1032}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1=points[i*2]
  y1=points[(i*2)+1]
  x2=points[j*2]
  y2=points[(j*2)+1]
  x = min(x1,x2)
  y = max(y1,y2)
  w = abs(x1 - x2)
  h = abs(y1 - y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1=points[i*2]
  y1=points[(i*2)+1]
  x2=points[j*2]
  y2=points[(j*2)+1]
  x = (x1+x2)/2
  y = (y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1=points[i*2]
  y1=points[(i*2)+1]
  x2=points[j*2]
  y2=points[(j*2)+1]
  w = abs(x1 - x2)
  h = abs(y1 - y2)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1=points[i*2]
  y1=points[(i*2)+1]
  x2=points[j*2]
  y2=points[(j*2)+1]
  d = ((x1-x2)**2+(y1-y2)**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1=points[p1*2]
  y1=points[(p1*2)+1]
  x2=points[p2*2]
  y2=points[(p2*2)+1]
  x3=points[p3*2]
  y3=points[(p3*2)+1]
  x4=points[p4*2]
  y4=points[(p4*2)+1]
  m1 = (y2-y1)/(x2-x1)
  c1 = y1-m1*x1
  m2 = (y4-y3)/(x4-x3)
  c2 = y3-m2*x3
  x = (c1-c2)/(m2-m1)
  y = m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631522121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 662, 'const': 400, 'code+const': 1062}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  xi = points[2*i]
  xj = points[2*j]
  yi = points[2*i+1]
  yj = points[2*j+1]
  x = min(xi,xj)
  y = max(yi,yj)
  w = abs(xi-xj)
  h = abs(yi-yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[2*i]
  xj = points[2*j]
  yi = points[2*i+1]
  yj = points[2*j+1]
  x  = (xi+xj)/2
  y  = (yi+yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = points[2*i]
  xj = points[2*j]
  yi = points[2*i+1]
  yj = points[2*j+1]
  w = abs(xi-xj)
  h = abs(yi-yj)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[2*i]
  xj = points[2*j]
  yi = points[2*i+1]
  yj = points[2*j+1]
  d = math.sqrt(((xj-xi)**2) + (yj-yi)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xi = points[2*p1]
  xj = points[2*p2]
  yi = points[2*p1+1]
  yj = points[2*p2+1]
  zi = points [2*p3]
  zj = points [2*p4]
  wi = points [2*p3+1]
  wj = points [2*p4+1]
  delta_x1 = xj-xi
  delta_y1 = yj-yi
  delta_x2  = zj-zi
  delta_y2 = wj-wi
  mi = delta_y1 / delta_x1
  mj = delta_y2 / delta_x2
  ci = yi-mi*xi
  cj =wj-mj*zj
  x = (cj-ci)/(mi-mj)
  y= mi*x+ci
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631524421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 544, 'const': 344, 'code+const': 888}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1,y1= points[i*2:(i+1)*2]
  x2,y2= points[j*2:(j+1)*2]
  return [min(x1,x2),max(y1,y2),abs(x1-x2),abs(y1-y2)]
def middle(points,i,j):
  x1,y1= points[i*2:(i+1)*2]
  x2,y2= points[j*2:(j+1)*2]
  return [(x1+x2)/2,(y1+y2)/2]
def frame_area(points,i,j):
  x,y,w,h=frame(points,i,j)
  return float(w*h)
def distance(points,i,j):
   x1,y1= points[i*2:(i+1)*2]
   x2,y2= points[j*2:(j+1)*2]
   return ((x1-x2)**2+(y1-y2)**2)**0.5
def intersection(points,p1,p2,p3,p4):
  x1,y1=points[p1*2:(p1+1)*2]
  x2,y2=points[p2*2:(p2+1)*2]
  x3,y3=points[p3*2:(p3+1)*2]
  x4,y4=points[p4*2:(p4+1)*2]
  m1=(y2-y1)/(x2-x1)
  c1=y1-m1*x1
  m2=(y4-y3)/(x4-x3)
  c2=y3-m2*x3
  x=(c2-c1)/(m1-m2)
  y=m1*x+c1
  return [x,y]

6631526721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 608, 'const': 400, 'code+const': 1008}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x = min(points[2*i],points[2*j])
    y = max(points[2*i+1],points[2*j+1])
    w = abs(points[2*j] - points[2*i])
    h = abs(points[2*i+1] - points[2*j+1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x = (points[2*i] + points[2*j])/2
    y = (points[2*i+1] + points[2*j+1])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    a = abs(points[2*i] - points[2*j]) * abs(points[2*i+1]-points[2*j+1])
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    d = ((points[2*i] - points[2*j])**2 + (points[2*i+1] - points[2*j+1])**2)**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    slope_1 = (points[2*p2+1] - points[2*p1+1]) / (points[2*p2] - points[2*p1])
    intercept_1 = points[2*p1+1] - slope_1*points[2*p1]
    slope_2 = (points[2*p4+1] - points[2*p3+1]) / (points[2*p4] - points[2*p3])
    intercept_2 = points[2*p3+1] - slope_2*points[2*p3]
    x = (intercept_2 - intercept_1) / (slope_1 - slope_2)
    y = slope_1*x + intercept_1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631528021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 654, 'const': 400, 'code+const': 1054}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j): #list all var needed
  x1, y1 = points[i*2:(i+1)*2:]
  x2, y2 = points[j*2:(j+1)*2:]
  min1 = min(x1,x2)
  max1 = max(y1,y2)
  a1 = abs(x1-x2)
  a2 = abs(y1-y2)
  return [min1, max1, a1, a2]
def middle(points,i,j): #divide 2
  x1, y1 = points[i*2:(i+1)*2:]
  x2, y2 = points[j*2:(j+1)*2:]
  a1 = (x1+x2)/2
  a2 = (y1+y2)/2
  return [a1, a2]
def frame_area(points,i,j): #width x height
  x1, y1 = points[i*2:(i+1)*2:]
  x2, y2 = points[j*2:(j+1)*2:]
  w = abs(x1-x2)
  h = abs(y1-y2)
  area = w * h
  return float(area)
def distance(points,i,j): #float dis from start > end
  x1, y1 = points[i*2:(i+1)*2:]
  x2, y2 = points[j*2:(j+1)*2:]
  #d=√((x2 – x1)² + (y2 – y1)²)
  a = (x1-x2)**2
  b = (y1-y2)**2
  d = math.sqrt(a+b)
  return d
def intersection(points,p1,p2,p3,p4): #4 point 2 line 1 inct
  x1, y1 = points[p1*2:(p1+1)*2:]
  x2, y2 = points[p2*2:(p2+1)*2:]
  x3, y3 = points[p3*2:(p3+1)*2:]
  x4, y4 = points[p4*2:(p4+1)*2:]
  l1 = (y2-y1)/(x2-x1)
  l2 = (y4-y3)/(x4-x3)
  a1 = y1 - (l1*x1)
  a2 = y3 - (l2*x3)
  x = (a2-a1)/(l1-l2)
  y = (l1*x) + a1
  return [x, y]

6631529621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 734, 'const': 400, 'code+const': 1134}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points, i, j):
    x_coords = [points[i * 2], points[j * 2]]
    y_coords = [points[i * 2 + 1], points[j * 2 + 1]]
    min_x = min(x_coords)
    max_x = max(x_coords)
    min_y = min(y_coords)
    max_y = max(y_coords)
    length = max_x - min_x
    height = max_y - min_y
    smallest_rectangle = [min_x, max_y, length, height]
    return smallest_rectangle
def middle(points, i,j):
    answer = []
    points_x = []
    points_y = []
    points_x = points[::2]
    points_y = points[1::2]
    x = (points_x[i] + points_x[j])/ 2
    y = (points_y[i] + points_y[j]) / 2
    answer.append(x)
    answer.append(y)
    return answer
def frame_area(points, i, j):
    x_coords = [points[i * 2], points[j * 2]]
    y_coords = [points[i * 2 + 1], points[j * 2 + 1]]
    min_x = min(x_coords)
    max_x = max(x_coords)
    min_y = min(y_coords)
    max_y = max(y_coords)
    length = max_x - min_x
    height = max_y - min_y
    area = length * height
    return area
def distance(points, i,j):
    answer = []
    points_x = []
    points_y = []
    points_x = points[::2]
    points_y = points[1::2]
    answer = math.sqrt((points_x[i] - points_x[j])**2 + (points_y[i] - points_y[j])**2)
    return answer
def intersection(points,p1,p2,p3,p4):
    answer = []
    points_x = []
    points_y = []
    points_x = points[::2]
    points_y = points[1::2]
    x1 = points_x[p1]
    y1 = points_y[p1]
    x2 = points_x[p2]
    y2 = points_y[p2]
    x3 = points_x[p3]
    y3 = points_y[p3]
    x4 = points_x[p4]
    y4 = points_y[p4]
    a1 = y2 - y1
    b1 = x1 - x2
    c1 = a1 * x1 + b1 * y1
    a2 = y4 - y3
    b2 = x3 - x4
    c2 = a2 * x3 + b2 * y3
    determinant = a1 * b2 - a2 * b1
    x = (b2 * c1 - b1 * c2) / determinant
    y = (a1 * c2 - a2 * c1) / determinant
    answer.append(x)
    answer.append(y)
    return answer

6631532421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 646, 'const': 400, 'code+const': 1046}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = min(xi,xj)
  y = max(yi,yj)
  w = abs(xi-xj)
  h = abs(yi-yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j) :
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = (xi + xj)/2
  y = (yi + yj)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  w = abs(xi-xj)
  h = abs(yi-yj)
  a = h*w
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  d = math.sqrt(((xi-xj)**2)+((yi-yj)**2))
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[2*p1]
    y1 = points[2*p1+1]
    x2 = points[2*p2]
    y2 = points[2*p2+1]
    x3 = points[2*p3]
    y3 = points[2*p3+1]
    x4 = points[2*p4]
    y4 = points[2*p4+1]
    mi = (y2-y1)/(x2-x1)
    ci = y1 - mi*x1 #ci = y2 - mi*x2
    mf = (y4-y3)/(x4-x3)
    cf = y3 - mf*x3 #cf = y4 - mf*x4
    x = (cf-ci)/(mi-mf)
    y = mf*x + cf #y = mi*x + ci
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631535321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 656, 'const': 400, 'code+const': 1056}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x0, y0 = points[2*i], points[2*i+1]
  x1, y1 = points[2*j], points[2*j+1]
  minx = min(x0, x1)
  maxy = max(y0, y1)
  width = abs(x1 - x0)
  height = abs(y1 - y0)
  return [minx,maxy,width,height]
def middle(points,i,j):
  x0, y0 = points[2*i], points[2*i+1]
  x1, y1 = points[2*j], points[2*j+1]
  x = (x0 + x1) / 2
  y = (y0 + y1) / 2
  return [x,y]
def frame_area(points,i,j):
  x0, y0 = points[2*i], points[2*i+1]
  x1, y1 = points[2*j], points[2*j+1]
  width = abs(x1 - x0)
  height = abs(y1 - y0)
  area = width * height
  return float(area)
def distance(points,i,j):
  x0, y0 = points[2*i], points[2*i+1]
  x1, y1 = points[2*j], points[2*j+1]
  d = ((x1 - x0)**2 + (y1 - y0)**2)**0.5
  return d
def intersection(points,p1,p2,p3,p4):
  x0, y0 = points[2*p1], points[2*p1+1]
  x1, y1 = points[2*p2], points[2*p2+1]
  x2, y2 = points[2*p3], points[2*p3+1]
  x3, y3 = points[2*p4], points[2*p4+1]
  #หาความชันและหาc
  m1 = (y1 - y0 ) / (x1 - x0)
  m2 = (y3 - y2) / (x3 - x2)
  c1 = y0 - m1 * x0
  c2 = y2 - m2 * x2
  x = (c2 - c1) / (m1 - m2)
  y = m1 * x + c1
  return [x,y]

6631539921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 642, 'const': 400, 'code+const': 1042}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1=points[i*2]
  y1=points[(i*2)+1]
  x2=points[j*2]
  y2=points[(j*2)+1]
  x=min(x1,x2)
  y=max(y1,y2)
  w=abs(x2-x1)
  h=abs(y2-y1)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1=points[i*2]
  y1=points[(i*2)+1]
  x2=points[j*2]
  y2=points[(j*2)+1]
  x=(x1+x2)/2
  y=(y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1=points[i*2]
  y1=points[(i*2)+1]
  x2=points[j*2]
  y2=points[(j*2)+1]
  w=abs(x2-x1)
  h=abs(y2-y1)
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1=points[i*2]
  y1=points[(i*2)+1]
  x2=points[j*2]
  y2=points[(j*2)+1]
  x=(x1-x2)**2
  y=(y1-y2)**2
  d=(x+y)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  p1x=points[p1*2]
  p1y=points[(p1*2)+1]
  p2x=points[p2*2]
  p2y=points[(p2*2)+1]
  p3x=points[p3*2]
  p3y=points[(p3*2)+1]
  p4x=points[p4*2]
  p4y=points[(p4*2)+1]
  m1=(p2y-p1y)/(p2x-p1x)
  m2=(p4y-p3y)/(p4x-p3x)
  c1=p1y-(m1*p1x)
  c2=p3y-(m2*p3x)
  x=-(c1-c2)/(m1-m2)
  y=(m1*x)+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631540421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 722, 'const': 400, 'code+const': 1122}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    xi, yi = points[2*i], points[2*i+1]
    xj, yj = points[2*j], points[2*j+1]
    x = min(xi, xj)
    y = max(yi, yj)
    w = abs(xi - xj)
    h = abs(yi - yj)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi, yi = points[2*i], points[2*i+1]
    xj, yj = points[2*j], points[2*j+1]
    x = (xi + xj) / 2
    y = (yi + yj) / 2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi, yi = points[2*i], points[2*i+1]
    xj, yj = points[2*j], points[2*j+1]
    we = abs(xi-xj)
    hi = abs(yi-yj)
    return float(we*hi) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi, yi = points[2*i], points[2*i+1]
    xj, yj = points[2*j], points[2*j+1]
    return math.sqrt((xj - xi)**2 + (yj - yi)**2)
   # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1, y1 = points[2*p1], points[2*p1+1]
    x2, y2 = points[2*p2], points[2*p2+1]
    x3, y3 = points[2*p3], points[2*p3+1]
    x4, y4 = points[2*p4], points[2*p4+1]
    x_num = (x1*y2 - y1*x2)*(x3 - x4) - (x1 - x2)*(x3*y4 - y3*x4)
    y_num = (x1*y2 - y1*x2)*(y3 - y4) - (y1 - y2)*(x3*y4 - y3*x4)
    denom = (x1 - x2)*(y3 - y4) - (y1 - y2)*(x3 - x4)
    x = x_num / denom
    y = y_num / denom
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631545621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 608, 'const': 424, 'code+const': 1032}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x = points[::2]
    y = points[1::2]
    w = abs(x[i]-x[j])
    h = abs(y[i]-y[j])
    x_min = min(x[i], x[j])
    y_max = max(y[i], y[j])
    x = x_min
    y = y_max
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x = points[::2]
    y = points[1::2]
    x = (x[i]+x[j])/2
    y = (y[i]+y[j])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x = points[::2]
    y = points[1::2]
    w = abs(x[i]-x[j])
    h = abs(y[i]-y[j])
    a = w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x = points[::2]
    y = points[1::2]
    cal_x = (x[j]-x[i])**2
    cal_y = (y[j]-y[i])**2
    d = (cal_x+cal_y)**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x = points[::2]
    y = points[1::2]
    x1,y1 = x[p1],y[p1]
    x2,y2 = x[p2],y[p2]
    x3,y3 = x[p3],y[p3]
    x4,y4 = x[p4],y[p4]
    m1 = (y2-y1)/(x2-x1)
    m2 = (y4-y3)/(x4-x3)
    x = ((m1*x1)-(m2*x3)-y1+y3)/(m1-m2)
    y = m1*(x-x1)+y1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631547921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 704, 'const': 400, 'code+const': 1104}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
 x = min(points[2*i],points[2*j])
 y = max(points[2*i+1],points[2*j+1])
 wid = abs(points[2*i] - points[2*j])
 hei = abs(points[2*i+1] - points[2*j+1])
 return [x,y,wid,hei]
def middle(points,i,j):
  c = points[2*+i] + points[2*j]
  d = points[2*i+1] + points[2*j+1]
  return [c/2,d/2]
def frame_area(points,i,j):
 wid = abs(points[2*i] - points[2*j])
 hei = abs(points[2*i+1] - points[2*j+1])
 w = float(wid)
 h = float(hei)
 return w*h
def distance(points,i,j):
  import math
  j = math.sqrt((points[2*i]- points[2*j])**2 + (points[2*i+1]- points[2*j+1])**2)
  return j
def intersection(points,p1,p2,p3,p4):
  x1 = points[2*p1]
  x2 = points[2*p2]
  x3 = points[2*p3]
  x4 = points[2*p4]
  y1 = points[2*p1+1]
  y2 = points[2*p2+1]
  y3 = points[2*p3+1]
  y4 = points[2*p4+1]
  px= ( (x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4) ) / ( (x1-x2)*(y3-y4)-(y1-y2)*(x3-x4) )
  py= ( (x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4) ) / ( (x1-x2)*(y3-y4)-(y1-y2)*(x3-x4) )
  return [px,py]

6631548521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 634, 'const': 344, 'code+const': 978}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x = min(points[2*i], points[2*j])
    y = max(points[2*i+1], points[2*j+1])
    w = abs(points[2*i] - points[2*j])
    h = abs(points[2*i+1] - points[2*j+1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x = (points[2*i] + points[2*j]) / 2
    y = (points[2*i+1] + points[2*j+1]) / 2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    _, _, w, h = frame(points, i, j)
    a = w * h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    dx = points[2*i] - points[2*j]
    dy = points[2*i+1] - points[2*j+1]
    d = math.sqrt(dx**2 + dy**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    A1 = points[2*p2+1] - points[2*p1+1]
    B1 = points[2*p1] - points[2*p2]
    C1 = A1*points[2*p1] + B1*points[2*p1+1]
    A2 = points[2*p4+1] - points[2*p3+1]
    B2 = points[2*p3] - points[2*p4]
    C2 = A2*points[2*p3] + B2*points[2*p3+1]
    det = A1*B2 - A2*B1
    x = (B2*C1 - B1*C2) / det
    y = (A1*C2 - A2*C1) / det
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631550721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 716, 'const': 400, 'code+const': 1116}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi, yi = points[2*i], points[2*i+1]
  xj, yj = points[2*j], points[2*j+1]
  x = min(xi, xj)
  y = max(yi, yj)
  w = abs(xi - xj)
  h = abs(yi - yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi, yi = points[2*i], points[2*i+1]
  xj, yj = points[2*j], points[2*j+1]
  x = (xi + xj) / 2
  y = (yi + yj) / 2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi, yi = points[2*i], points[2*i+1]
  xj, yj = points[2*j], points[2*j+1]
  width = abs(xi - xj)
  lenght = abs(yi - yj)
  a = width * lenght
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi, yi = points[2*i], points[2*i+1]
  xj, yj = points[2*j], points[2*j+1]
  d =((xj - xi)**2 + (yj - yi)**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1, y1 = points[2*p1], points[2*p1+1]
  x2, y2 = points[2*p2], points[2*p2+1]
  x3, y3 = points[2*p3], points[2*p3+1]
  x4, y4 = points[2*p4], points[2*p4+1]
  x_num = (x1*y2 - y1*x2)*(x3 - x4) - (x1 - x2)*(x3*y4 - y3*x4)
  y_num = (x1*y2 - y1*x2)*(y3 - y4) - (y1 - y2)*(x3*y4 - y3*x4)
  denom = (x1 - x2)*(y3 - y4) - (y1 - y2)*(x3 - x4)
  x = x_num / denom
  y = y_num / denom
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631552021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 694, 'const': 400, 'code+const': 1094}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1 = points[i*2] #พิกัด x1
    y1 = points[i*2+1] #พิกัด y1
    x2 = points[j*2] #พิกัด x2
    y2 = points[j*2+1] #พิกัด y2
    x = min(x1 , x2) #พิกัดของ x ของจุดบนซ้าย
    y = max(y1 , y2) #พิกัดของ y ของจุดบนซ้าย
    w = abs(x1 - x2) #ความกว้างของสี่เหลี่ยม
    h = abs(y1 - y2) #ความสูงของสี่เหลี่ยม
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x1 = points[i*2] #พิกัด x1
    y1 = points[i*2+1] #พิกัด y1
    x2 = points[j*2] #พิกัด x2
    y2 = points[j*2+1] #พิกัด y2
    x = (x1 + x2) / 2
    y = (y1 + y2) / 2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x1 = points[i*2] #พิกัด x1
    y1 = points[i*2+1] #พิกัด y1
    x2 = points[j*2] #พิกัด x2
    y2 = points[j*2+1] #พิกัด y2
    w = abs(x1 - x2)
    h = abs(y1 - y2)
    a = h * w
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    import math
    x1 = points[i*2] #พิกัด x1
    y1 = points[i*2+1] #พิกัด y1
    x2 = points[j*2] #พิกัด x2
    y2 = points[j*2+1] #พิกัด y2
    d = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points, p1, p2, p3, p4):
    x1 = points[p1*2] #พิกัด x ของ p1
    y1 = points[p1*2+1] #พิกัด y ของ p1
    x2 = points[p2*2] #พิกัด x ของ p2
    y2 = points[p2*2+1] #พิกัด y ของ p2
    x3 = points[p3*2] #พิกัด x ของ p3
    y3 = points[p3*2+1] #พิกัด y ของ p3
    x4 = points[p4*2]  #พิกัด x ของ p4
    y4 = points[p4*2+1]  #พิกัด y ของ p4
    denom = ((x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4))
    x = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / denom #หาจุดตัดของเส้นตรงที่เกิดจากทั้ง 4 จุด
    y = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / denom #หาจุดตัดของเส้นตรงที่เกิดจากทั้ง 4 จุด
    return [x, y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631701121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 684, 'const': 400, 'code+const': 1084}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def middle(points,i,j):
  px1=points[2*i]
  py1=points[2*i+1]
  px2=points[2*j]
  py2=points[2*j+1]
  a=(float(px1)+float(px2))/2
  b=(float(py1)+float(py2))/2
  return[a,b]
def frame(points,i,j):
  px1=points[2*i]
  py1=points[2*i+1]
  px2=points[2*j]
  py2=points[2*j+1]
  a=min(px1,px2)
  b=max(py1,py2)
  c=abs(float(px1)-float(px2))
  d=abs(float(py1)-float(py2))
  return[a,b,int(c),int(d)]
def frame_area(points,i,j):
  px1=points[2*i]
  py1=points[2*i+1]
  px2=points[2*j]
  py2=points[2*j+1]
  w=abs(float(px1)-float(px2))
  h=abs(float(py1)-float(py2))
  area=w*h
  return area
def distance(points,i,j):
  px1=points[2*i]
  py1=points[2*i+1]
  px2=points[2*j]
  py2=points[2*j+1]
  Distance=((px1-px2)**2+(py1-py2)**2)**(0.5)
  return Distance
def intersection(points,i,j,k,l):
  px1=points[2*i]
  py1=points[2*i+1]
  px2=points[2*j]
  py2=points[2*j+1]
  px3=points[2*k]
  py3=points[2*k+1]
  px4=points[2*l]
  py4=points[2*l+1]
  m1=(py2-py1)/(px2-px1)
  c1=py1-m1*px1
  m2=(py3-py4)/(px3-px4)
  c2=py3-m2*px3
  x=(c1-c2)/(m2-m1)
  y=m1*x+c1
  return[x,y]

6631703421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 642, 'const': 400, 'code+const': 1042}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1=points[i*2]
    x2=points[j*2]
    y1=points[i*2+1]
    y2=points[j*2+1]
    x=min(x1,x2)
    y=max(y1,y2)
    w=abs(x2-x1)
    h=abs(y2-y1)
    return [x,y,w,h]
def middle(points,i,j):
    x1=points[i*2]
    x2=points[j*2]
    y1=points[i*2+1]
    y2=points[j*2+1]
    x=(x1+x2)/2
    y=(y1+y2)/2
    return [x,y]
def frame_area(points,i,j):
    x1=points[i*2]
    x2=points[j*2]
    y1=points[i*2+1]
    y2=points[j*2+1]
    w=abs(x2-x1)
    h=abs(y2-y1)
    a=w*h
    return float(a)
def distance(points,i,j):
    x1=points[i*2]
    x2=points[j*2]
    y1=points[i*2+1]
    y2=points[j*2+1]
    import math
    d=math.sqrt(((x2-x1)**2)+((y2-y1)**2))
    return d
def intersection(points,p1,p2,p3,p4):
    x1=points[p1*2]
    x2=points[p2*2]
    x3=points[p3*2]
    x4=points[p4*2]
    y1=points[p1*2+1]
    y2=points[p2*2+1]
    y3=points[p3*2+1]
    y4=points[p4*2+1]
    m1=(y2-y1)/(x2-x1)
    m2=(y4-y3)/(x4-x3)
    c1=y1-(m1*x1)
    c2=y3-(m2*x3)
    x=(c2-c1)/(m1-m2)
    y=m1*x+c1
    return [x,y]

6631801221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 554, 'const': 344, 'code+const': 898}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def middle(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    return [(x1+x2)/2 , (y1+y2)/2]
def frame(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    return [min(x1,x2), max(y1,y2), abs(x2-x1),abs(y2-y1)]
def frame_area(points,i,j):
    A,B,C,D = frame(points,i,j)
    return C*D
def distance(points,i,j):
    x1 = points[i*2]
    y1 = points[i*2+1]
    x2 = points[j*2]
    y2 = points[j*2+1]
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)
def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2]
    y1 = points[p1*2+1]
    x2 = points[p2*2]
    y2 = points[p2*2+1]
    x3 = points[p3*2]
    y3 = points[p3*2+1]
    x4 = points[p4*2]
    y4 = points[p4*2+1]
    m1 = (y2-y1)/(x2-x1)
    m2 = (y4-y3)/(x4-x3)
    c1 = y1 -m1*x1
    c2 = y3-m2*x3
    x = (c2-c1)/(m1-m2)
    y = m1*x+c1
    return [x,y]

6631803521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 632, 'const': 400, 'code+const': 1032}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1 = points[2*i]
    y1 = points[(2*i)+1]
    x2 = points[2*j]
    y2 = points[(2*j)+1]
    x = min(x1,x2)
    y = max(y1,y2)
    w = abs(x1-x2)
    h = abs(y1-y2)
    return [x,y,w,h]
def middle(points,i,j):
    x1 = points[2*i]
    y1 = points[(2*i)+1]
    x2 = points[2*j]
    y2 = points[(2*j)+1]
    x = (x1+x2)/2
    y = (y1+y2)/2
    return [x,y]
def frame_area(points,i,j):
    x1 = points[2*i]
    y1 = points[(2*i)+1]
    x2 = points[2*j]
    y2 = points[(2*j)+1]
    w = abs(x1-x2)
    h = abs(y1-y2)
    a = w * h
    return float(a)
def distance(points,i,j):
    x1 = points[2*i]
    y1 = points[(2*i)+1]
    x2 = points[2*j]
    y2 = points[(2*j)+1]
    d = (((x1-x2)**2)+((y1-y2)**2))**0.5
    return d
def intersection(points,p1,p2,p3,p4):
    x1 = points[2*p1]
    y1 = points[(2*p1)+1]
    x2 = points[2*p2]
    y2 = points[(2*p2)+1]
    x3 = points[2*p3]
    y3 = points[(2*p3)+1]
    x4 = points[2*p4]
    y4 = points[(2*p4)+1]
    m1 = (y2 - y1)/(x2 - x1)
    c1 = y1 - (m1*x1)
    m2 = (y4 - y3)/(x4 - x3)
    c2 = y3 - (m2*x3)
    x = (c2 - c1)/(m1 - m2)
    y = m1*x + c1
    return [x,y]

6631804121: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 586, 'const': 344, 'code+const': 930}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    xi = points[2*i]
    yi = points[2*i+1]
    xj = points[2*j]
    yj = points[2*j+1]
    x = min(xi,xj)
    y = max(yi,yj)
    weight = abs(xi-xj)
    high = abs(yi-yj)
    return [x,y,weight,high]
def middle(points,i,j):
    xi = points[2*i]
    yi = points[2*i+1]
    xj = points[2*j]
    yj = points[2*j+1]
    xm = (xi+xj)/2
    ym = (yi+yj)/2
    return [xm,ym] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x,y,w,h = frame(points,i,j)
    area = w*h
    return area # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi = points[2*i]
    yi = points[2*i+1]
    xj = points[2*j]
    yj = points[2*j+1]
    distance = math.sqrt((xi-xj)**2+(yi-yj)**2)
    return distance # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):#หาจุดตัด
    x1 = points[2*p1]
    y1 = points[2*p1+1]
    x2 = points[2*p2]
    y2 = points[2*p2+1]
    x3 = points[2*p3]
    y3 = points[2*p3+1]
    x4 = points[2*p4]
    y4 = points[2*p4+1]
    m1_2 = (y2-y1)/(x2-x1)#สร้างสมการเส้นตรงที่ 1
    c1_2 = y1-m1_2*x1
    m3_4 = (y4-y3)/(x4-x3)#สร้างสมการเส้นตรงที่ 2
    c3_4 = y3-m3_4*x3
    x = (c3_4-c1_2)/(m1_2-m3_4)
    y = m1_2*x+c1_2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631805821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 624, 'const': 400, 'code+const': 1024}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    xi=points[i*2]
    yi=points[(i*2)+1]
    xj=points[j*2]
    yj=points[(j*2)+1]
    x=min(xi,xj)
    y=max(yi,yj)
    w=abs(xj-xi)
    h=abs(yj-yi)
    return[x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi=points[i*2]
    yi=points[(i*2)+1]
    xj=points[j*2]
    yj=points[(j*2)+1]
    return[(xi+xj)/2,(yi+yj)/2] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi=points[i*2]
    yi=points[(i*2)+1]
    xj=points[j*2]
    yj=points[(j*2)+1]
    w=abs(xj-xi)
    h=abs(yj-yi)
    a=w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi=points[i*2]
    yi=points[(i*2)+1]
    xj=points[j*2]
    yj=points[(j*2)+1]
    d=(((xj-xi)**2 + (yj-yi)**2)**(1/2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1=points[p1*2]
    y1=points[(p1*2)+1]
    x2=points[p2*2]
    y2=points[(p2*2)+1]
    x3=points[p3*2]
    y3=points[(p3*2)+1]
    x4=points[p4*2]
    y4=points[(p4*2)+1]
    m1=(y2-y1)/(x2-x1)
    m2=(y4-y3)/(x4-x3)
    c1=y1-(m1*x1)
    c2=y3-(m2*x3)
    x=(c2-c1)/(m1-m2)
    y=(m1*x)+c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631806421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 628, 'const': 344, 'code+const': 972}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x0,y0=points[i*2:(i+1)*2]
    x1,y1=points[j*2:(j+1)*2]
    return [min(x0,x1),max(y0,y1),abs(x0-x1),abs(y0-y1)]
def middle(points,i,j):
    x0, y0 = points[2*i], points[2*i+1]
    x1, y1 = points[2*j], points[2*j+1]
    x_mid = (x0 + x1) / 2
    y_mid = (y0 + y1) / 2
    return [x_mid, y_mid]
def frame_area(points,i,j):
    x,y,widt,height=frame(points,i,j)
    return widt*height
def distance(points,i,j):
    x0, y0 = points[2*i], points[2*i+1]
    x1, y1 = points[2*j], points[2*j+1]
    dist = ((x1 - x0)**2 + (y1 - y0)**2)**0.5
    return dist
def intersection(points,p1,p2,p3,p4):
    x1, y1 = points[2*p1], points[2*p1+1]
    x2, y2 = points[2*p2], points[2*p2+1]
    x3, y3 = points[2*p3], points[2*p3+1]
    x4, y4 = points[2*p4], points[2*p4+1]
    x_num = (x1*y2 - y1*x2)*(x3 - x4) - (x1 - x2)*(x3*y4 - y3*x4)
    y_num = (x1*y2 - y1*x2)*(y3 - y4) - (y1 - y2)*(x3*y4 - y3*x4)
    d = (x1 - x2)*(y3 - y4) - (y1 - y2)*(x3 - x4)
    x_intersect = x_num / d
    y_intersect = y_num / d
    return [x_intersect,y_intersect]

6631807021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 612, 'const': 400, 'code+const': 1012}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1=points[2*i]
    x2=points[(2*j)]
    y1=points[(2*i+1)]
    y2=points[(2*j+1)]
    return[min(x1,x2),max(y1,y2),max((x1-x2),(x2-x1)),max((y1-y2),(y2-y1))]
def middle(points,i,j):
    x1=points[2*i]
    x2=points[(2*j)]
    y1=points[(2*i+1)]
    y2=points[(2*j+1)]
    return[(x1+x2)/2,(y1+y2)/2]
def frame_area(points,i,j):
    x1=points[2*i]
    x2=points[(2*j)]
    y1=points[(2*i+1)]
    y2=points[(2*j+1)]
    return float(abs(x1-x2)*abs(y1-y2))
def distance(points,i,j):
    x1=points[i*2]
    x2=points[(2*j)]
    y1=points[(i*2+1)]
    y2=points[(2*j+1)]
    return ((abs(x1-x2)**2+abs(y1-y2)**2))**(1/2)
def intersection(points,p1,p2,p3,p4):
    x1=points[2*p1]
    y1=points[2*p1+1]
    x2=points[2*p2]
    y2=points[2*p2+1]
    x3=points[2*p3]
    y3=points[2*p3+1]
    x4=points[2*p4]
    y4=points[2*p4+1]
    m1=(y2-y1)/(x2-x1)
    c1=y1-m1*x1
    m2=(y4-y3)/(x4-x3)
    c2=y3-(m2*x3)
    x=(c1-c2)/(m2-m1)
    y=(m2*x)+c2
    return[x,y]

6631808721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 638, 'const': 400, 'code+const': 1038}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x1 = points[i*2]
    y1 = points[(i*2)+1]
    x2 = points[j*2]
    y2 = points[(j*2)+1]
    x = min(x1,x2)
    y = max(y1,y2)
    w = abs(x2-x1)
    h = abs(y2-y1)
    return [x,y,w,h]
def middle(points,i,j):
    x1 = points[i*2]
    y1 = points[(i*2)+1]
    x2 = points[j*2]
    y2 = points[(j*2)+1]
    x = (x1+x2)/2
    y = (y1+y2)/2
    return [x,y]
def frame_area(points,i,j):
    x1 = points[i*2]
    y1 = points[(i*2)+1]
    x2 = points[j*2]
    y2 = points[(j*2)+1]
    a = abs(x2-x1)*abs(y2-y1)
    return a
def distance(points,i,j):
    x1 = points[i*2]
    y1 = points[(i*2)+1]
    x2 = points[j*2]
    y2 = points[(j*2)+1]
    d = math.sqrt(pow(x2-x1, 2)+pow(y2-y1, 2))
    return d
def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2]
    y1 = points[(p1*2)+1]
    x2 = points[p2*2]
    y2 = points[(p2*2)+1]
    x3 = points[p3*2]
    y3 = points[(p3*2)+1]
    x4 = points[p4*2]
    y4 = points[(p4*2)+1]
    m1 = (y2-y1)/(x2-x1)
    m2 = (y4-y3)/(x4-x3)
    c1 = y1-(m1*x1)
    c2 = y3-(m2*x3)
    x = (c2-c1)/(m1-m2)
    y = (m1*x)+c1
    return [x,y]

6631809321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 572, 'const': 344, 'code+const': 916}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x1=points[i*2]
    y1=points[i*2+1]
    x2=points[j*2]
    y2=points[j*2+1]
    x=min(x1,x2)
    y=max(y1,y2)
    w=abs(x1-x2)
    h=abs(y1-y2)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x1=points[i*2]
    y1=points[i*2+1]
    x2=points[j*2]
    y2=points[j*2+1]
    x=(x1+x2)/2
    y=(y1+y2)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x,y,w,h = frame(points,i,j)
    a=w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x1=points[i*2]
    y1=points[i*2+1]
    x2=points[j*2]
    y2=points[j*2+1]
    d=((x1-x2)**2+(y1-y2)**2)**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1=points[p1*2]
    y1=points[p1*2+1]
    x2=points[p2*2]
    y2=points[p2*2+1]
    x3=points[p3*2]
    y3=points[p3*2+1]
    x4=points[p4*2]
    y4=points[p4*2+1]
    m12=(y2-y1)/(x2-x1)
    m34=(y4-y3)/(x4-x3)
    x=(m12*x1-m34*x3+y3-y1)/(m12-m34)
    y=m12*(x-x1)+y1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6631810921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 594, 'const': 344, 'code+const': 938}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  x = min(x1,x2)
  y = max(y1,y2)
  w = abs(x1-x2)
  h = abs(y1-y2)
  return [x,y,w,h]
def middle(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  mid_x = (x1+x2)/2
  mid_y = (y1+y2)/2
  return [mid_x,mid_y]
def frame_area(points,i,j):
  x,y,w,h = frame(points,i,j)
  a = w*h
  return a
def distance(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  w = x1-x2
  h = y1-y2
  d = math.sqrt(w**2+h**2)
  return d
def intersection(points,p1,p2,p3,p4):
  x1 = points[2*p1]
  y1 = points[2*p1+1]
  x2 = points[2*p2]
  y2 = points[2*p2+1]
  x3 = points[2*p3]
  y3 = points[2*p3+1]
  x4 = points[2*p4]
  y4 = points[2*p4+1]
  #L: y = mx+c
  m1 = (y2-y1)/(x2-x1)
  c1 = y1 - m1*x1
  m2 = (y4-y3)/(x4-x3)
  c2 = y4 - m2*x4
  x_in = (c2-c1)/(m1-m2)
  y_in = m1*x_in + c1
  return [x_in,y_in]

6632006921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 580, 'const': 292, 'code+const': 872}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def xIndex(i):
  return i*2
def yIndex(i):
  return i*2 + 1
def frame(points,i,j):
  x = min(points[xIndex(i)], points[xIndex(j)])
  y = max(points[yIndex(i)], points[yIndex(j)])
  w = abs(points[xIndex(i)] - points[xIndex(j)])
  h = abs(points[yIndex(i)] - points[yIndex(j)])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[xIndex(i)] + points[xIndex(j)])/2
  y = (points[yIndex(i)] + points[yIndex(j)])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x, y, w, h = frame(points, i, j)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d = ((points[xIndex(i)] - points[xIndex(j)])**2 + (points[yIndex(i)] - points[yIndex(j)])**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  m1 = (points[yIndex(p1)] - points[yIndex(p2)])/(points[xIndex(p1)] - points[xIndex(p2)])
  m2 = (points[yIndex(p3)] - points[yIndex(p4)])/(points[xIndex(p3)] - points[xIndex(p4)])
  c1 = points[yIndex(p1)] - m1*points[xIndex(p1)]
  c2 = points[yIndex(p3)] - m2*points[xIndex(p3)]
  x = (c1-c2)/(m2-m1)
  y = m1*x + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632011021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 640, 'const': 424, 'code+const': 1064}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x = min(points[2*i],points[2*j])
  y = max(points[2*i+1],points[2*j+1])
  w = max(points[2*i],points[2*j])-min(points[2*i],points[2*j])
  h = max(points[2*i+1],points[2*j+1])-min(points[2*i+1],points[2*j+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[2*i]+points[2*j])/2
  y = (points[2*i+1]+points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  temp = frame(points,i,j)
  a = temp[2]*temp[3]
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d = ((points[2*i]-points[2*j])**2+(points[2*i+1]-points[2*j+1])**2)**(1/2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  m1 = (points[2*p2+1]-points[2*p1+1])/(points[2*p2]-points[2*p1])
  c1 = points[2*p1+1]-m1*points[2*p1]
  m2 = (points[2*p4+1]-points[2*p3+1])/(points[2*p4]-points[2*p3])
  c2 = points[2*p3+1]-m2*points[2*p3]
  x = (c2-c1)/(m1-m2)
  y = m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632015521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 662, 'const': 400, 'code+const': 1062}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    xi,yi = points[i*2],points[i*2+1]
    xj,yj = points[j*2],points[j*2+1]
    x = min(xi,xj)
    y = max(yi,yj)
    w = abs(xi-xj)
    h = abs(yi-yj)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi,yi = points[i*2],points[i*2+1]
    xj,yj = points[j*2],points[j*2+1]
    x = (xi+xj)/2
    y = (yi+yj)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi,yi = points[i*2],points[i*2+1]
    xj,yj = points[j*2],points[j*2+1]
    w = abs(xi-xj)
    h = abs(yi-yj)
    a = w*h
    return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi,yi = points[i*2],points[i*2+1]
    xj,yj = points[j*2],points[j*2+1]
    d = math.sqrt((xi-xj)**2+(yi-yj)**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    xi1,yi1 = points[p1*2],points[p1*2+1]
    xj1,yj1 = points[p2*2],points[p2*2+1]
    xi2,yi2 = points[p3*2],points[p3*2+1]
    xj2,yj2 = points[p4*2],points[p4*2+1]
    m1 = (yj1-yi1)/(xj1-xi1)
    m2 = (yj2-yi2)/(xj2-xi2)
    x = ((m1*xi1)-yi1-(m2*xj2)+yj2)/(m1-m2)
    y = m1*(x-xi1)+yi1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632017821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 642, 'const': 400, 'code+const': 1042}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    p1 = min(points[(2*i)],points[(2*j)])
    p2 = max(points[(2*i+1)],points[(2*j+1)])
    width = abs(points[(2*i)]-points[(2*j)])
    height = abs(points[(2*i+1)]-points[(2*j+1)])
    return p1,p2,width,height
def middle(points,i,j):
    p1 = (points[(2*i)]+points[(2*j)])/2
    p2 = (points[(2*i+1)]+points[(2*j+1)])/2
    return p1,p2
def frame_area(points,i,j):
    width = abs(points[(2*i)]-points[(2*j)])
    height = abs(points[(2*i+1)]-points[(2*j+1)])
    sq_area = width*height
    return sq_area
def distance(points,i,j):
    dist = math.sqrt(((points[(2*i)]-points[(2*j)])**2)+((points[(2*i+1)]-points[(2*j+1)])**2))
    return dist
def intersection(points,p1,p2,p3,p4):
    m1 = (points[(2*p2+1)]-points[(2*p1+1)])/(points[(2*p2)]-points[(2*p1)])
    m2 = (points[(2*p4+1)]-points[(2*p3+1)])/(points[(2*p4)]-points[(2*p3)])
    xc = (points[(2*p3+1)]-points[(2*p1+1)]+m1*points[(2*p1)]-m2*points[(2*p3)])/(m1-m2)
    yc = points[(2*p1+1)] + m1*(xc-points[(2*p1)])
    return xc,yc

6632029321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 602, 'const': 400, 'code+const': 1002}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
#คืนลิสต์ที่มีสมาชิก 4 ตัว เป็นข้อมูลของกรอบสี่เหลี่ยมที่เล็กที่สุดที่ครอบจุดสองจุดนี้ได้พอดี
#โดยสองตัวแรกเป็นพิกัด (x, y) ของจุดซ้ายบนของกรอบสี่เหลี่ยมนั้น และสองตัวหลังเป็นความกว้างและความสูงของกรอบสี่เหลี่ยมตามลำดับ
 xi=points[2*i]
 yi=points[2*i+1]
 xj=points[2*j]
 yj=points[2*j+1]
 w=abs(xj-xi)
 h=abs(yj-yi)
 x=min(xi,xj)
 y=max(yi,yj)
 return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
 #คืนพิกัด (x, y) ของจุดกึ่งกลางของจุด  xi,yi  และ  xj,yj  เป็นลิสต์ [x, y] โดย x และ y เป็นจำนวนจริง
 xi=points[2*i]
 yi=points[2*i+1]
 xj=points[2*j]
 yj=points[2*j+1]
 x=(xj+xi)/2
 y=(yj+yi)/2
 return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
#คืนพื้นที่ของกรอบสี่เหลี่ยมในข้อ 2 เป็นจำนวนจริง
 y=frame(points,i,j)
 a=y[2]*y[3]
 return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
#คืนความยาวของส่วนของเส้นตรงที่มีจุดเริ่มต้นเป็น  xi,yi  และมีจุดสิ้นสุดเป็น  xj,yj  เป็นจำนวนจริง
 import math
 xi=points[2*i]
 yi=points[2*i+1]
 xj=points[2*j]
 yj=points[2*j+1]
 d=math.sqrt((xi-xj)**2+(yi-yj)**2)
 return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
#intersection(points,p1,p2,p3,p4) คืนพิกัด (x,y) ของจุดตัดของเส้นตรงที่มีจุดปลายเป็น p1 และ p2
#กับเส้นตรงที่มีจุดปลายเป็น p3 และ p4 โดย x และ y เป็นจำนวนจริง กำหนดให้อินพุตของฟังก์ชันนี้มีจุดตัดและมีจุดตัดเพียงจุดเดียวเท่านั้น และจะไม่มีอินพุตที่มีเส้นตรงที่มีความชันเป็น  ∞
 x1=points[2*p1]
 y1=points[2*p1+1]
 x2=points[2*p2]
 y2=points[2*p2+1]
 x3=points[2*p3]
 y3=points[2*p3+1]
 x4=points[2*p4]
 y4=points[2*p4+1]
 m1=(y2-y1)/(x2-x1)
 m2=(y4-y3)/(x4-x3)
 x=(y1-y3-m1*x1+m2*x3)/(m2-m1)
 y=(m2*y1-m1*y3+m1*m2*(x3-x1))/(m2-m1)
 return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632038021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 636, 'const': 400, 'code+const': 1036}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  x = min(x1,x2)
  y = max(y1,y2)
  w = abs(x1-x2)
  h = abs(y1-y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  x = (x1+x2)/2
  y = (y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  a =  abs(x1-x2)*abs(y1-y2)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1 = points[2*i]
  y1 = points[2*i+1]
  x2 = points[2*j]
  y2 = points[2*j+1]
  d = (((x2-x1)**2)+((y2-y1)**2))**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[2*p1]
  y1 = points[2*p1+1]
  x2 = points[2*p2]
  y2 = points[2*p2+1]
  x3 = points[2*p3]
  y3 = points[2*p3+1]
  x4 = points[2*p4]
  y4 = points[2*p4+1]
  m1 = (y2-y1)/(x2-x1)
  m2 = (y4-y3)/(x4-x3)
  c1 = y1-(m1*x1)
  c2 = y3-(m2*x3)
  x = (c2-c1)/(m1-m2)
  y = ((m1*c2)-(m2*c1))/(m1-m2)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632041821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 616, 'const': 400, 'code+const': 1016}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  w = abs(points[i*2] - points[j*2])
  h = abs(points[i*2+1] - points[j*2+1])
  x = min(points[i*2],points[j*2])
  y = max(points[i*2+1],points[j*2+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[i*2] + points[j*2])/2
  y = (points[i*2+1] + points[j*2+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  w = abs(points[i*2] - points[j*2])
  h = abs(points[i*2+1] - points[j*2+1])
  a = w * h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d = ((points[i*2] - points[j*2])**2 + (points[i*2+1]-points[j*2+1])**2)**(1/2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  # find m1 and m2
  m1 = (points[p1*2+1] - points[p2*2+1])/(points[p1*2] - points[p2*2])
  m2 = (points[p3*2+1] - points[p4*2+1])/(points[p3*2] - points[p4*2])
  #y = m1x + c1
  #y = m2x + c2
  #find c1 and c2
  c1 = points[p1*2+1] - (points[p1*2]*m1)
  c2 = points[p3*2+1] - (points[p3*2]*m2)
  #m1x + c1 = m2x + c2
  # (c1-c2)/(m2-m1) = x
  x = (c1-c2)/(m2-m1)
  y = x*m1 + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632078021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 690, 'const': 376, 'code+const': 1066}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x=min(points[i*2],points[j*2])
  y=max(points[2*i+1],points[2*j+1])
  w=abs(points[2*i]-points[2*j])
  h=abs(points[2*i+1]-points[2*j+1])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x=(points[2*i]+points[2*j])/2
  y=(points[2*i+1]+points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x=min(points[i*2],points[j*2])
  y=max(points[2*i+1],points[2*j+1])
  w=abs(points[2*i]-points[2*j])
  h=abs(points[2*i+1]-points[2*j+1])
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d=math.sqrt((points[i*2]-points[j*2])**2+(points[2*i+1]-points[2*j+1])**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  m1=(points[2*p2+1]-points[2*p1+1])/(points[p2*2]-points[p1*2])
  m2=(points[2*p4+1]-points[2*p3+1])/(points[p4*2]-points[p3*2])
  c1=(points[2*p1+1]-m1*points[p1*2])
  c2=(points[2*p3+1]-m2*points[p3*2])
  x=(c2-c1)/(m1-m2)
  y=((m2*c1-m1*c2)/(m2-m1))
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632084821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 726, 'const': 400, 'code+const': 1126}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x1 = points[i*2]
  y1 = points[i*2+1]
  x2 = points[j*2]
  y2 = points[j*2+1]
  x = min(x1,x2)
  y = max(y1,y2)
  w = max(x1,x2)-x
  h = y-min(y1,y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1 = points[i*2]
  y1 = points[i*2+1]
  x2 = points[j*2]
  y2 = points[j*2+1]
  return [(x1+x2)/2,(y1+y2)/2] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1 = points[i*2]
  y1 = points[i*2+1]
  x2 = points[j*2]
  y2 = points[j*2+1]
  x = min(x1,x2)
  y = max(y1,y2)
  w = max(x1,x2)-x
  h = y-min(y1,y2)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1 = points[i*2]
  y1 = points[i*2+1]
  x2 = points[j*2]
  y2 = points[j*2+1]
  x = min(x1,x2)
  y = max(y1,y2)
  w = max(x1,x2)-x
  h = y-min(y1,y2)
  a = w*h
  d = math.sqrt(h**2+w**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[p1*2]
  y1 = points[p1*2+1]
  x2 = points[p2*2]
  y2 = points[p2*2+1]
  x3 = points[p3*2]
  y3 = points[p3*2+1]
  x4 = points[p4*2]
  y4 = points[p4*2+1]
  # eqa y=ax+c y=bx+d
  a = (y2-y1)/(x2-x1)
  b = (y4-y3)/(x4-x3)
  c = y1-a*x1
  d = y3-b*x3
  x = (d-c)/(a-b)
  y = a*(d-c)/(a-b)+c
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632092821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 780, 'const': 468, 'code+const': 1248}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x_points, y_points = [points[::2][i], points[::2][j]], [points[1::2][i], points[1::2][j]]
  [z_x, z_y], [w, l] = [min(x_points), max(y_points)], [(max(x_points)-min(x_points)), (max(y_points)-min(y_points))]
  return [z_x, z_y, w, l]
def middle(points,i,j):
  x_points, y_points = [points[::2][i], points[::2][j]], [points[1::2][i], points[1::2][j]]
  middle = [(max(x_points)+min(x_points))/2, (max(y_points)+min(y_points))/2]
  return middle
def frame_area(points,i,j):
  x_points, y_points = [points[::2][i], points[::2][j]], [points[1::2][i], points[1::2][j]]
  w, l = (max(x_points)-min(x_points)), (max(y_points)-min(y_points))
  Area = w*l
  return Area
def distance(points,i,j):
  x_points, y_points = [points[::2][i], points[::2][j]], [points[1::2][i], points[1::2][j]]
  distance = (((max(x_points)-min(x_points))**2+(max(y_points)-min(y_points))**2)**0.5)
  return distance
def intersection(points,p1,p2,p3,p4):
  def equation(point_1, point_2):
    m = (point_2[1] - point_1[1])/(point_2[0] - point_1[0])
    c = point_1[1] - m*point_1[0]
    return m, c
  x_points, y_points = points[::2], points[1::2]
  p1, p2, p3, p4 = [x_points[p1], y_points[p1]], [x_points[p2], y_points[p2]], [x_points[p3], y_points[p3]], [x_points[p4], y_points[p4]]
  (m1, c1), (m2, c2) = equation(p1, p2), equation(p3, p4)
  x_inter = (c2 - c1)/(m1 - m2)
  y_inter = m1*x_inter + c1
  return [x_inter, y_inter]

6632102421: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 612, 'const': 392, 'code+const': 1004}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
from math import sqrt
def frame(points,i,j):
  x1, y1 = points[i*2], points[i*2+1]
  x2, y2 = points[j*2], points[j*2+1]
  x, y = min(x1, x2), max(y1, y2)
  w, h = abs(x1-x2), abs(y1-y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[i*2]+points[j*2])/2
  y = (points[i*2+1]+points[j*2+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  _, _, w, h = frame(points, i, j)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1, y1 = points[i*2], points[i*2+1]
  x2, y2 = points[j*2], points[j*2+1]
  dx = abs(x1-x2)
  dy = abs(y1-y2)
  d = sqrt(dx*dx + dy*dy)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1, y1 = points[p1*2], points[p1*2+1]
  x2, y2 = points[p2*2], points[p2*2+1]
  x3, y3 = points[p3*2], points[p3*2+1]
  x4, y4 = points[p4*2], points[p4*2+1]
  m1 = (y2 - y1) / (x2 - x1)
  m2 = (y4 - y3) / (x4 - x3)
  c1 = y1 - m1*x1
  c2 = y3 - m2*x3
  x = (c2-c1) / (m1-m2)
  y = m1*x + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632105321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5.0, 6.0, 11.0, 1.0, 11.0, 16.0, 4.0, 5.0, 7.0, 12.0],
 [1.0, 2.0, 5.0, 4.0, 1.0, 6.0, 5.0, 7.0, 6.0, 1.0]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 858, 'const': 400, 'code+const': 1258}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    xi=points[2*i]
    yi=points[2*i+1]
    xj=points[2*j]
    yj=points[2*j+1]
    x=min(xi,xj)
    y=max(yi,yj)
    h=math.sqrt((abs(xi-xi))**2+(abs(yi-yj))**2)
    w=math.sqrt((abs(xi-xj))**2+(abs(yi-yi))**2)
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    xi=points[2*i]
    yi=points[2*i+1]
    xj=points[2*j]
    yj=points[2*j+1]
    x=(xi+xj)/2
    y=(yi+yj)/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    xi=points[2*i]
    yi=points[2*i+1]
    xj=points[2*j]
    yj=points[2*j+1]
    x=min(xi,xj)
    y=max(yi,yj)
    h=math.sqrt((abs(xi-xi))**2+(abs(yi-yj))**2)
    w=math.sqrt((abs(xi-xj))**2+(abs(yi-yi))**2)
    a=w*h
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    xi=points[2*i]
    yi=points[2*i+1]
    xj=points[2*j]
    yj=points[2*j+1]
    y1=max(yi,yj)
    y2=min(yi,yj)
    x1=max(xi,xj)
    x2=min(xi,xj)
    d=math.sqrt((x1-x2)**2+(y1-y2)**2)
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1, y1=points[2*p1], points[2*p1+1]
    x2, y2=points[2*p2], points[2*p2+1]
    x3, y3=points[2*p3], points[2*p3+1]
    x4, y4=points[2*p4], points[2*p4+1]
    x21 = x2 - x1
    y21 = y2 - y1
    x43 = x4 - x3
    y43 = y4 - y3
    a = x21 * y43 - x43 * y21
    x13 = x1 - x3
    y13 = y1 - y3
    t0 = x43 * y13 - y43 * x13
    t = t0 / a
    x,y = [ x1 + (t * x21), y1 + (t * y21) ]
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632107621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 668, 'const': 424, 'code+const': 1092}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  xi = points[2*i]
  yi = points[2*i + 1]
  xj = points[2*j]
  yj = points[2*j + 1]
  x = min(xi, xj)
  y = max(yi, yj)
  w = abs(xj - xi)
  h = abs(yj - yi)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[2*i]
  yi = points[2*i + 1]
  xj = points[2*j]
  yj = points[2*j + 1]
  x = (xi + xj) / 2
  y = (yi + yj) / 2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi = points[2*i]
  yi = points[2*i + 1]
  xj = points[2*j]
  yj = points[2*j + 1]
  a = abs(xj - xi) * abs(yj - yi)
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[2*i]
  yi = points[2*i + 1]
  xj = points[2*j]
  yj = points[2*j + 1]
  d = ((xi - xj)**2 + (yi - yj)**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[2*p1]
  y1= points[2*p1 + 1]
  x2 = points[2*p2]
  y2 = points[2*p2 + 1]
  x3 = points[2*p3]
  y3= points[2*p3 + 1]
  x4 = points[2*p4]
  y4 = points[2*p4 + 1]
  m1 = (y2 - y1) / (x2 - x1)
  c1 = (y1*x2 - y2*x1) / (x2 - x1)
  m2 = (y4 - y3) / (x4 - x3)
  c2 = (y3*x4 - y4*x3) / (x4 - x3)
  x = (c2 - c1) / (m1 - m2)
  y = (m1*c2 - m2*c1) / (m1 - m2)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632111021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 724, 'const': 500, 'code+const': 1224}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame (points, i, j):
    point_i = (points[2 * i], points[2 * i + 1])
    point_j = (points[2 * j], points[2 * j + 1])
    x, y = min(point_i[0], point_j[0]), max(point_i[1], point_j[1])
    w, h = abs(point_i[0] - point_j[0]), abs(point_i[1] - point_j[1])
    return [x, y, w, h]  # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle (points, i, j):
    point_i = (points[2 * i], points[2 * i + 1])
    point_j = (points[2 * j], points[2 * j + 1])
    x, y = (point_i[0] + point_j[0]) / 2, (point_i[1] + point_j[1]) / 2
    return [x, y]  # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area (points, i, j):
    w = frame(points, i, j)
    a = w[2] * w[3]
    return a  # เมื่อ a เป็นพื้นที่ของเฟรม
def distance (points, i, j):
    w = frame(points, i, j)
    d = (w[2] ** 2 + w[3] ** 2) ** 0.5
    return d  # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection (points, p1, p2, p3, p4):
    a, b = points[2 * p1], points[2 * p1 + 1]
    c, d = (points[2 * p2], points[2 * p2 + 1])
    e, f = (points[2 * p3], points[2 * p3 + 1])
    g, h = (points[2 * p4], points[2 * p4 + 1])
    l1 = ((d - b) / (c - a), -1, (b - a * (d - b) / (c - a)))
    l2 = ((h - f) / (g - e), -1, (f - e * (h - f) / (g - e)))
    x, y = (l1[1] * l2[2] - l2[1] * l1[2]) / (l1[0] * l2[1] - l2[0] * l1[1]), (l2[0] * l1[2] - l1[0] * l2[2]) / (
                l1[0] * l2[1] - l2[0] * l1[1])
    return [x, y]  # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632134521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 636, 'const': 400, 'code+const': 1036}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points, i, j) :
  x1, y1, x2, y2 = 2 * i, 2 * i + 1, 2 * j, 2 * j + 1
  x, y = min(points[x1], points[x2]), max(points[y1], points[y2])
  w, h = abs(points[x1] - points[x2]), abs(points[y1] - points[y2])
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points, i, j) :
  x1, y1, x2, y2 = 2 * i, 2 * i + 1, 2 * j, 2 * j + 1
  x = (points[x1] + points[x2]) / 2
  y = (points[y1] + points[y2]) / 2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points, i, j) :
  lis = frame(points, i, j)
  a = lis[2] * lis[3]
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points, i, j) :
  x1, y1, x2, y2 = 2 * i, 2 * i + 1, 2 * j, 2 * j + 1
  d = (points[x1] - points[x2]) ** 2 + (points[y1] - points[y2]) ** 2
  d **= 0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points, p1, p2, p3, p4) :
  x1, y1, x2, y2 = 2 * p1, 2 * p1 + 1, 2 * p2, 2 * p2 + 1
  x3, y3, x4, y4 = 2 * p3, 2 * p3 + 1, 2 * p4, 2 * p4 + 1
  m1 = (points[y1] - points[y2]) / (points[x1] - points[x2])
  c1 = points[y1] - m1 * points[x1]
  m2 = (points[y3] - points[y4]) / (points[x3] - points[x4])
  c2 = points[y3] - m2 * points[x3]
  x = (c1 - c2) / (m2 - m1)
  y = m1 * x + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632140221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 766, 'const': 400, 'code+const': 1166}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x1,y1 = points[i*2],points[i*2+1]
  x2,y2 = points[j*2],points[j*2+1]
  w = abs(x1-x2)
  h = abs(y1-y2)
  x = min(x1,x2)
  y = max(y1,y2)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1,y1 = points[i*2],points[i*2+1]
  x2,y2 = points[j*2],points[j*2+1]
  x = min(x1,x2) + abs(x1-x2)/2
  y = min(y1,y2) + abs(y1-y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x1,y1 = points[i*2],points[i*2+1]
  x2,y2 = points[j*2],points[j*2+1]
  w = abs(x1-x2)
  h = abs(y1-y2)
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1,y1 = points[i*2],points[i*2+1]
  x2,y2 = points[j*2],points[j*2+1]
  w = abs(x1-x2)
  h = abs(y1-y2)
  d = math.sqrt(w**2+h**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,y1 = points[p1*2],points[p1*2+1]
  x2,y2 = points[p2*2],points[p2*2+1]
  x3,y3 = points[p3*2],points[p3*2+1]
  x4,y4 = points[p4*2],points[p4*2+1]
  denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)
  x = ((x1*y2 - y1*x2) * (x3 - x4) - (x1 - x2) * (x3*y4 - y3*x4)) / denominator
  y = ((x1*y2 - y1*x2) * (y3 - y4) - (y1 - y2) * (x3*y4 - y3*x4)) / denominator
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632146021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 558, 'const': 344, 'code+const': 902}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
    x1,y1=points[i*2:(i+1)*2]
    x2,y2=points[j*2:(j+1)*2]
    return[min(x1,x2),max(y1,y2),abs(x2-x1),abs(y2-y1)]
def middle(points,i,j):
    x1,y1=points[i*2:(i+1)*2]
    x2,y2=points[j*2:(j+1)*2]
    return[((x1+x2)/2),((y1+y2)/2)]
def frame_area(points,i,j):
    x,y,w,h=frame(points,i,j)
    return(w*h)
def distance(points,i,j):
    x1,y1=points[i*2:(i+1)*2]
    x2,y2=points[j*2:(j+1)*2]
    return (abs(math.sqrt(((x1-x2)**2)+((y1-y2)**2))))
def intersection(points,p1,p2,p3,p4):
    x1,y1=points[p1*2:(p1+1)*2]
    x2,y2=points[p2*2:(p2+1)*2]
    x3,y3=points[p3*2:(p3+1)*2]
    x4,y4=points[p4*2:(p4+1)*2]
    m1=(y1-y2)/(x1-x2)
    m2=(y3-y4)/(x3-x4)
    c1=y1-(m1*x1)
    c2=y3-(m2*x3)
    x=(c2-c1)/(m1-m2)
    y=m1*x+c1
    return[x,y]

6632149021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 594, 'const': 344, 'code+const': 938}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x1,y1 = points[i*2:(i+1)*2]
  x2,y2 = points[j*2:(j+1)*2]
  x = min(x1,x2) #จุดxซ้ายบน
  y = max(y1,y2) #จุดyซ้ายบน
  w  = abs(x1-x2) #ระยะกว้าง
  h  = abs(y1-y2) #ระยะยาว
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x1,y1 = points[i*2:(i+1)*2]
  x2,y2 = points[j*2:(j+1)*2]
  x = (x1+x2)/2 #สูตรหาจุดกึ่งกลางใน x axis
  y = (y1+y2)/2 #สูตรหาจุดกึ่งกลางใน y axis
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x, y, width, height = frame(points,i,j)
  a = width * height #ศุตรหาพื้นที่
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x1,y1 = points[i*2:(i+1)*2]
  x2,y2 = points[j*2:(j+1)*2]
  x = x2 - x1
  y = y2 - y1
  d = math.sqrt((x**2)+(y**2))
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,y1 = points[p1*2:(p1+1)*2]
  x2,y2 = points[p2*2:(p2+1)*2]
  x3,y3 = points[p3*2:(p3+1)*2]
  x4,y4 = points[p4*2:(p4+1)*2]
  # อิงจากสูตร y = mx + c
  # y = (m1*x) + c1 ---> สมการที่ 1
  # y = (m2*x3) + c2 ---> สมการที่ 2
  m1 = (y2-y1)/(x2-x1) #หาค่าความชันสมการที่ตัดผ่านของจุด 1,2
  m2 = (y4-y3)/(x4-x3) #หาค่าความชันสมการที่ตัดผ่านของจุด 3,4
  c1 = y1 - (m1*x1)
  c2 = y3 - (m2*x3)
  #แก้สมการหา x กำหนดให้ค่า x(สมการที่ 1) = x(สมการที่ 2) และ y(สมการที่ 1) = y(สมการที่ 2) ,(m1)(x) + c1 = (m2)(x) +c2
  x = (c2 - c1)/(m1 - m2)
  #นำค่า x ไปแทนในสมการที่ 1
  y = (m1*x) + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632156321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 500, 'const': 280, 'code+const': 780}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    xi, yi, xj, yj = fpair(points, i, j)
    min_x = min(xi, xj)
    max_y = max(yi, yj)
    width = abs(xi - xj)
    length = abs(yi - yj)
    return [min_x, max_y, width, length]
def middle(points,i,j):
    xi, yi, xj, yj = fpair(points, i, j)
    x = (xi + xj)/2
    y = (yi + yj)/2
    return [x, y]
def frame_area(points,i,j):
    min_x, max_y, width, length = frame(points,i,j)
    Area = width * length
    return Area
def distance(points,i,j):
    min_x, max_y, width, length = frame(points,i,j)
    displacement = (width**2 + length**2)**0.5
    return displacement
def intersection(points,p1,p2,p3,p4):
    m1, c1 = equation(points, p1, p2)
    m2, c2 = equation(points, p3, p4)
    x = (c2 - c1) / (m1 - m2)
    y = (m1*x) + c1
    return [x, y]
def equation(points,i, j):
    xi, yi, xj, yj = fpair(points, i, j)
    m = (yj - yi) / (xj - xi)
    c = yi - m * xi
    return m, c
def pair(points,n):
    xn = points[2*n]
    yn = points[2*n+1]
    return xn, yn
def fpair(points, i, j):
    xi, yi = pair(points, i)
    xj, yj = pair(points, j)
    return xi, yi, xj, yj

6632162021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 548, 'const': 288, 'code+const': 836}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
    x=min(points[i*2],points[j*2])
    y=max(points[i*2+1],points[j*2+1])
    w=abs(points[i*2]-points[j*2])
    h=abs(points[i*2+1]-points[j*2+1])
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x=(points[i*2]+points[j*2])/2
    y=(points[i*2+1]+points[j*2+1])/2
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    x,y,h,w=frame(points,i,j)
    a=h*w
    return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    x,y,h,w=frame(points,i,j)
    d=(h*h+w*w)**0.5
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    m1=(points[p1*2+1]-points[p2*2+1])/(points[p1*2]-points[p2*2])
    c1=points[p1*2+1]-m1*points[p1*2]
    m2=(points[p3*2+1]-points[p4*2+1])/(points[p3*2]-points[p4*2])
    c2=points[p3*2+1]-m2*points[p3*2]
    x=(c2-c1)/(m1-m2)
    y=m1*x+c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632163721: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 600, 'const': 400, 'code+const': 1000}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = min(xi,xj)
  y = max(yi,yj)
  w = max(xi,xj) - min(xi,xj)
  h = max(yi,yj) - min(yi,yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = float((xi+xj)/2)
  y = float((yi+yj)/2)
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  frame_info = frame(points,i,j)
  a = frame_info[2]*frame_info[3]
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  d = (((xj-xi)**2)+((yj-yi)**2))**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1 = points[2*p1]
  y1 = points[2*p1+1]
  x2 = points[2*p2]
  y2 = points[2*p2+1]
  x3 = points[2*p3]
  y3 = points[2*p3+1]
  x4 = points[2*p4]
  y4 = points[2*p4+1]
  m1 = (y1-y2)/(x1-x2)
  c1 = y1-m1*x1
  m2 = (y3-y4)/(x3-x4)
  c2 = y3-m2*x3
  x = (c1-c2)/(m2-m1)
  y = m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632175221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 710, 'const': 400, 'code+const': 1110}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math as ma
def frame(points,i,j):
    x = int(min(points[i*2],points[j*2]))
    y = int(max(points[i*2+1],points[j*2+1]))
    w = int(max(points[i*2],points[j*2]) - x)
    h = int(y - min(points[i*2+1],points[j*2+1]))
    return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    x = float((points[i*2]+points[j*2])/2)
    y = float((points[i*2+1]+points[j*2+1])/2)
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
    a = float((max(points[i*2],points[j*2]) - min(points[i*2],points[j*2]))*(max(points[i*2+1],points[j*2+1]) - min(points[i*2+1],points[j*2+1])))
    return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
    d = ma.sqrt((abs(points[i*2]-points[j*2])**2+abs(points[i*2+1]-points[j*2+1])**2))
    return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x1 = points[p1*2]
    y1 = points[p1*2+1]
    x2 = points[p2*2]
    y2 = points[p2*2+1]
    x3 = points[p3*2]
    y3 = points[p3*2+1]
    x4 = points[p4*2]
    y4 = points[p4*2+1]
    m1 = (y1-y2)/(x1-x2)
    m2 = (y3-y4)/(x3-x4)
    c1 = y1-x1*m1
    c2 = y3-x3*m2
    x = (c2-c1)/(m1-m2)
    y = m1*x+c1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632184921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 492, 'const': 220, 'code+const': 712}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def point(points, i):
    return points[i * 2 : i * 2 + 2]
def frame(points,i,j):
    x1, y1 = point(points, i)
    x2, y2 = point(points, j)
    return [min(x1, x2), max(y1, y2), abs(x1 - x2), abs(y1 - y2)]
def middle(points,i,j):
    x1, y1 = point(points, i)
    x2, y2 = point(points, j)
    return [(x2 + x1) / 2, (y2 + y1) / 2]
def frame_area(points,i,j):
    x1, y1 = point(points, i)
    x2, y2 = point(points, j)
    return abs(x1 - x2) * abs(y1 - y2)
def distance(points,i,j):
    x1, y1 = point(points, i)
    x2, y2 = point(points, j)
    return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
def intersection(points,p1,p2,p3,p4):
    (x1, y1), (x2, y2) = point(points, p1), point(points, p2)
    (x3, y3), (x4, y4) = point(points, p3), point(points, p4)
    m1, m2 = (y2 - y1) / (x2 - x1), (y4 - y3) / (x4 - x3)
    c1, c2 = y1 - m1 * x1, y3 - m2 * x3
    x = (c2 - c1) / (m1 - m2)
    y = m1 * x + c1
    return [x, y]

6632187821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 646, 'const': 400, 'code+const': 1046}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = points[2*i]
  yi = points[2*i + 1]
  xj = points[2*j]
  yj = points[2*j + 1]
  dx = abs(xi - xj)
  dy = abs(yi - yj)
  xtl = min(xi, xj)
  ytl = max(yi, yj)
  return [xtl, ytl, dx, dy]
def middle(points,i,j):
  xi = points[2*i]
  yi = points[2*i + 1]
  xj = points[2*j]
  yj = points[2*j + 1]
  xm = (xi + xj)/2
  ym = (yi + yj)/2
  return [xm, ym]
def frame_area(points,i,j):
  xi = points[2*i]
  yi = points[2*i + 1]
  xj = points[2*j]
  yj = points[2*j + 1]
  dx = abs(xi - xj)
  dy = abs(yi - yj)
  a = dx*dy
  return a
def distance(points,i,j):
  xi = points[2*i]
  yi = points[2*i + 1]
  xj = points[2*j]
  yj = points[2*j + 1]
  dx = abs(xi - xj)
  dy = abs(yi - yj)
  d = (dx**2 + dy**2)**0.5
  return d
def intersection(points,p1,p2,p3,p4):
  x1 = points[2*p1]
  y1 = points[2*p1 + 1]
  x2 = points[2*p2]
  y2 = points[2*p2 + 1]
  x3 = points[2*p3]
  y3 = points[2*p3 + 1]
  x4 = points[2*p4]
  y4 = points[2*p4 + 1]
  m12 = (y2 - y1)/(x2 - x1)
  m34 = (y4 - y3)/(x4 - x3)
  c12 = y1 - m12*x1
  c34 = y3 - m34*x3
  xin = -(c12 - c34)/(m12 - m34)
  yin = m12*xin + c12
  return [xin, yin]

6632190621: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 638, 'const': 400, 'code+const': 1038}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  xi=points[2*i]
  yi=points[2*i+1]
  xj=points[2*j]
  yj=points[2*j+1]
  x=min(xi,xj)
  y=max(yi,yj)
  w=abs(xi-xj)
  h=abs(yi-yj)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x=(points[2*i]+points[2*j])/2
  y=(points[2*i+1]+points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  xi=points[2*i]
  yi=points[2*i+1]
  xj=points[2*j]
  yj=points[2*j+1]
  w=abs(xi-xj)
  h=abs(yi-yj)
  a=w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  xi=points[2*i]
  yi=points[2*i+1]
  xj=points[2*j]
  yj=points[2*j+1]
  d=math.sqrt((xi-xj)**2+(yi-yj)**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  m1=(points[p1*2+1]-points[p2*2+1])/(points[p1*2]-points[p2*2])
  m2=(points[p3*2+1]-points[p4*2+1])/(points[p3*2]-points[p4*2])
  c1=points[p1*2+1]-m1*points[p1*2]
  c2=points[p3*2+1]-m2*points[p3*2]
  x=(c2-c1)/(m1-m2)
  y=m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632191221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 624, 'const': 400, 'code+const': 1024}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
   x = int(min(points[i*2],points[j*2]))
   y = int(max(points[i*2+1],points[j*2+1]))
   w=int(abs(points[i*2]-points[j*2]))
   h = int(abs(points[i*2+1]-points[j*2+1]))
   return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[i*2]+points[j*2])/2
  y = (points[i*2+1]+points[j*2+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  a = abs(points[i*2]-points[j*2])*(abs(points[i*2+1]-points[j*2+1]))
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  d = (abs(points[i*2]-points[j*2])**2+abs(points[i*2+1]-points[j*2+1])**2)**0.5
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
    x_1 = points[p1*2]; y_1 = points[p1*2+1]; x_2 = points[p2*2]; y_2 = points[p2*2+1]; x_3 = points[p3*2]; y_3 = points[p3*2+1]; x_4 = points[p4*2]; y_4 = points[p4*2+1]
    m_1 = (y_1-y_2)/(x_1-x_2); m_2 = (y_3-y_4)/(x_3-x_4)
    c_1 = y_1-x_1*m_1; c_2 = y_3-x_3*m_2
    x = (c_2-c_1)/(m_1-m_2)
    y = m_1*x+c_1
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632199321: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 636, 'const': 400, 'code+const': 1036}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x_i = points[2*i] ; y_i = points[2*i + 1]
  x_j = points[2*j] ; y_j = points[2*j+1]
  x = min(x_i,x_j)
  y = max(y_i,y_j)
  w = abs(x_i - x_j)
  h = abs(y_i - y_j)
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x_i = points[2*i] ; y_i = points[2*i + 1]
  x_j = points[2*j] ;y_j = points[2*j+1]
  x = (x_i+x_j) / 2
  y = (y_i+y_j) / 2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x_i = points[2*i] ; y_i = points[2*i + 1]
  x_j = points[2*j] ; y_j = points[2*j+1]
  w = abs(x_i - x_j)
  h = abs(y_i - y_j)
  a = w * h
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  x_i = points[2*i] ; y_i = points[2*i + 1]
  x_j = points[2*j] ; y_j = points[2*j+1]
  d = ((x_i - x_j)**2 + (y_i - y_j)**2)**(1/2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  m1 = (points[p1*2 + 1] - points[p2*2 + 1]) / (points[p1*2] - points[p2*2])
  m2 = (points[p3*2 + 1] - points[p4*2 + 1]) / (points[p3*2] - points[p4*2])
  c1 = points[p1*2 + 1] - m1*points[p1*2]
  c2 = points[p3*2 + 1] - m2*points[p3*2]
  x = (c1 - c2) / (m2 - m1)
  y = m1*x + c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632210521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 648, 'const': 400, 'code+const': 1048}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math as m
def frame(points,i,j):
  x = min(points[2*i],points[2*j])
  y = max(points[2*i+1],points[2*j+1])
  w = abs(x-max(points[2*i],points[2*j]))
  h = abs(y-min(points[2*i+1],points[2*j+1]))
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[2*i]+points[2*j])/2
  y = (points[2*i+1]+ points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  d=frame(points,i,j)
  a = d[2]*d[3]
  return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  data=frame(points,i,j)
  d = m.sqrt(data[2]**2 + data[3]**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  x1,x2,x3,x4 = points[2*p1],points[2*p2],points[2*p3],points[2*p4]
  y1,y2,y3,y4 = points[2*p1+1],points[2*p2+1],points[2*p3+1],points[2*p4+1]
  x = ((x1*y2 - y1*x2)*(x3-x4)-(x1-x2)*(x3*y4 - y3*x4))/(((x1-x2)*(y3-y4))-((y1-y2)*(x3-x4)))
  y = ((x1*y2 - y1*x2)*(y3-y4)-(y1-y2)*(x3*y4 - y3*x4))/(((x1-x2)*(y3-y4))-((y1-y2)*(x3-x4)))
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632217021: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 770, 'const': 520, 'code+const': 1290}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  points_x = points[0::2] #ย่อยx
  points_y = points[1::2] #ย่อยy
  x1, y1 = points_x[i] ,points_y[i] #เลือกxy_1
  x2, y2 = points_x[j] ,points_y[j] #เลือกxy_2
  max_x = max(x1, x2) #หาmax_x หาค.กว้าง
  max_y = max(y1, y2) #หาmax_y หาค.สูง
  min_x = min(x1, x2) #หาจุดบนซ้าย
  min_y = min(y1, y2) #หาmin_y หาค.สูง
  x = min_x
  y = max_y
  w = max_x - min_x
  h = max_y - min_y
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
    points_x = points[0::2] #ย่อยx
    points_y = points[1::2] #ย่อยy
    x1, y1 = points_x[i] ,points_y[i]
    x2, y2 = points_x[j] ,points_y[j]
    mid_x = (x1 + x2) / 2
    mid_y = (y1 + y2) / 2
    x = mid_x
    y = mid_y
    return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  points_x = points[0::2]
  points_y = points[1::2]
  x1, y1 = points_x[i] ,points_y[i]
  x2, y2 = points_x[j] ,points_y[j]
  w = abs(max(x2,x1)-min(x2,x1))
  h = abs(max(y2,y1)-min(y2,y1))
  a = ( w * h ) #ก*ย
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  points_x = points[0::2]
  points_y = points[1::2]
  x1, y1 = points_x[i] ,points_y[i]
  x2, y2 = points_x[j] ,points_y[j]
  w = abs(max(x2,x1)-min(x2,x1))#หาฐาน
  h = abs(max(y2,y1)-min(y2,y1))#หาสููง
  dis2 = pow(w,2) + pow(h,2)#พีทากอรัส
  d = math.sqrt(dis2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  points_x = points[0::2]
  points_y = points[1::2]
  x1, y1 = points_x[p1] ,points_y[p1]
  x2, y2 = points_x[p2] ,points_y[p2]
  x3, y3 = points_x[p3] ,points_y[p3]
  x4, y4 = points_x[p4] ,points_y[p4]
  p1p2_slope = (y2 - y1) / (x2 - x1)
  p3p4_slope = (y4 - y3) / (x4 - x3)
  inter_x = (p1p2_slope * x1 - p3p4_slope * x3 + y3 - y1) / (p1p2_slope - p3p4_slope)
  inter_y =  ( y1 + p1p2_slope * (inter_x - x1))
  x = inter_x
  y = inter_y
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632219221: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 618, 'const': 400, 'code+const': 1018}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  x=min((points[i*2]),(points[j*2])) #min(x)
  y=max((points[(i*2)+1]),(points[(j*2)+1])) #max(y)
  w=abs(points[i*2]-points[j*2]) #x2-x1
  h=abs(points[(i*2)+1]-points[(j*2)+1]) #y2-y1
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x=(points[i*2]+points[j*2])/2 #(x1+x2)/2
  y=(points[(i*2)+1]+points[(j*2)+1])/2 #(y1+y2)/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  a= (abs(points[i*2]-points[j*2]))*(abs(points[(i*2)+1]-points[(j*2)+1])) #wide*height
                                       #x1-x2*y2-y1
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  import math
  d=math.sqrt(((points[i*2]-points[j*2])**2)+((points[(i*2)+1]-points[(j*2)+1]))**2)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  #y=mx+c
  m1=(points[(p1*2)+1]-points[((p2*2))+1])/(points[p1*2]-points[p2*2])
  #m1=ความชันp1กับp2  y1-y2/x2-x1
  m2=(points[(p3*2)+1]-points[((p4*2))+1])/(points[p3*2]-points[p4*2])
  #m2=ความชันp3กับp4  y3-y4/x3-x4
  c1=(points[(p1*2)+1])-(m1*(points[p1*2])) #นำค่า x,y ของ p1 มาแทน
  c2=(points[(p3*2)+1])-(m2*(points[p3*2])) #นำค่า x,y ของ p3 มาแทน
  x= (c2-c1)/(m1-m2) #ค่า x ของจุดตัด
  y= (m1*x)+c1 # ค่า y ของจุดตัด
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632245521: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 762, 'const': 452, 'code+const': 1214}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
import math
def frame(points,i,j):
  x = min(points[2*i],points[2*j])
  y = max(points[2*i+1],points[2*j+1])
  x2 = max(points[2*i],points[2*j])
  y2 = min(points[2*i+1],points[2*j+1])
  w = x2-x
  h = y-y2
  return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
  x = (points[2*i]+points[2*j])/2
  y = (points[2*i+1]+points[2*j+1])/2
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
  x = min(points[2*i],points[2*j])
  y = max(points[2*i+1],points[2*j+1])
  x2 = max(points[2*i],points[2*j])
  y2 = min(points[2*i+1],points[2*j+1])
  w = x2-x
  h = y-y2
  a = w*h
  return float(a) # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
  deltaX = abs(points[2*i]-points[2*j])
  deltaY = abs(points[2*i+1]-points[2*j+1])
  d = math.sqrt(deltaX*deltaX+deltaY*deltaY)
  return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
  xArr = [points[2*p1],points[2*p2],points[2*p3],points[2*p4]]
  yArr = [points[2*p1+1],points[2*p2+1],points[2*p3+1],points[2*p4+1]]
  m1 = (yArr[1]-yArr[0])/(xArr[1]-xArr[0])
  c1 = yArr[0]-m1*xArr[0]
  m2 = (yArr[3]-yArr[2])/(xArr[3]-xArr[2])
  c2 = yArr[2]-m2*xArr[2]
  x = (c2-c1)/(m1-m2)
  y = m1*x+c1
  return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4

6632260921: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 668, 'const': 400, 'code+const': 1068}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  a = [min(xi,xj),max(yi,yj),abs(xi-xj),abs(yi-yj)]
  return a
def middle(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  x = (xj+xi)/2
  y = (yj+yi)/2
  return [x,y]
def frame_area(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  dx = abs(xj-xi)
  dy = abs(yj-yi)
  dA = dx*dy
  return dA
def distance(points,i,j):
  xi = points[2*i]
  yi = points[2*i+1]
  xj = points[2*j]
  yj = points[2*j+1]
  dx = abs(xj-xi)
  dy = abs(yj-yi)
  dl = (dx**2+dy**2)**0.5
  return dl
def intersection(points,p1,p2,p3,p4):
  x1 = points[2*p1]
  y1 = points[2*p1+1]
  x2 = points[2*p2]
  y2 = points[2*p2+1]
  x3 = points[2*p3]
  y3 = points[2*p3+1]
  x4 = points[2*p4]
  y4 = points[2*p4+1]
  m12 = (y2-y1)/(x2-x1)
  m34 = (y4-y3)/(x4-x3)
  c12 = (y2*x1-y1*x2)/(x1-x2)
  c34 = (y4*x3-y3*x4)/(x3-x4)
  x = (c12-c34)/(m34-m12)
  y = (m34*c12-m12*c34)/(m34-m12)
  return [x,y]

6632263821: HW01
testfuncscerrstu_stdoutstu_keptstu_fout
test_frame1.0
[[4, -2, -7, 4, -2, -7, 5, -7, -2, -7], [2, 3, 1, 1, 3, 2, 2, 3, 3, -3],
 [5, 6, 11, 1, 11, 16, 4, 5, 7, 12], [1, 2, 5, 4, 1, 6, 5, 7, 6, 1]]
test_middle1.0
[[6.5, 1.0, -1.5, 4.5, 3.5, 1.0, 7.0, -4.5, 1.5, -1.0],
 [1.5, 2.0, -1.5, -1.0, 2.5, -1.0, -0.5, -0.5, 0.0, -3.5]]
test_frame_area1.0
[5.0, 14.0, 63.25, 2.25, 12.0, 107.25, 24.75, 33.75, 48.75, 12.0]
test_distance1.0
[5.1, 7.28, 12.75, 4.53, 12.04, 17.73, 7.11, 8.75, 9.92, 12.04]
test_intersection1.0
[[7.89, 16.81, 5.93, 7.02, 2.04, -34.43, 1.48, 4.6, 3.22, 4.34],
 [0.53, -2.02, 1.09, 2.71, -0.44, -6.29, 0.05, 0.57, 13.03, 2.93]]
bytecount: {'code': 678, 'const': 496, 'code+const': 1174}
check_import({'allowable': ['math']}) deep: none
check_if({}) deep: none
def frame(points,i,j):
      a=points[0::2] #xi
      b=points[1::2] #yi
      c=[a[i],a[j]]
      x=min(c)
      d=[b[i],b[j]]
      y=max(d)
      w=abs(a[i]-a[j])
      h=abs(b[i]-b[j])
      return [x,y,w,h] # เมื่อ x,y เป็นพิกัดของจุดบนซ้าย w,h เป็นความกว้างและความสูงของเฟรมตามลำดับ
def middle(points,i,j):
      a=points[0::2] #xi
      b=points[1::2] #yi
      x=float((a[i]+a[j])/2)
      y=float((b[i]+b[j])/2)
      return [x,y] # เมื่อ x,y เป็นพิกัดของจุดกึ่งกลางของจุด i,j ในลิสต์ points
def frame_area(points,i,j):
      k=points[0::2] #xi
      c=points[1::2] #yi
      w=abs(k[i]-k[j])
      h=abs(c[i]-c[j])
      a=float(w*h)
      return a # เมื่อ a เป็นพื้นที่ของเฟรม
def distance(points,i,j):
      import math
      a=points[0::2] #xi
      b=points[1::2] #yi
      c=abs(a[i]-a[j])
      e=abs(b[i]-b[j])
      d=math.sqrt(c**2+e**2)
      return d # เมื่อ d เป็นระยะห่างระหว่างจุด i,j ในลิสต์ points
def intersection(points,p1,p2,p3,p4):
      a=points[0::2] #xi
      b=points[1::2] #yi
      jood1=[a[p1],b[p1]]
      jood2=[a[p2],b[p2]]
      jood3=[a[p3],b[p3]]
      jood4=[a[p4],b[p4]]
      m1=(jood2[1]-jood1[1])/(jood2[0]-jood1[0])
      m2=(jood4[1]-jood3[1])/(jood4[0]-jood3[0])
      x=(jood4[1]-jood2[1]-m2*jood4[0]+m1*jood2[0])/(m1-m2)
      y=(m1*(x-jood2[0]))+jood2[1]
      return [x,y] # เมื่อ x,y เป็นพิกัดของจุดตัดของส่วนของเส้นตรง p1,p2 กับ p3,p4