def create_problem(): p_a = Point('A') p_b = Point('B') p_c = Point('C') p_d = Point('D') p_e = Point('E') line_ab = Line('AB', ends=[p_a, p_b], length=None) line_ae = Line('AE', ends=[p_a, p_e], length=None) line_eb = Line('EB', ends=[p_e, p_b], length=None) line_cd = Line('CD', ends=[p_c, p_d], length=None) line_ec = Line('EC', ends=[p_e, p_c], length=None) angle_aec = Angle('AEC', sides=[line_ae, line_ec], vertex=p_e, angle=None) angle_dce = Angle('DCE', sides=[line_ec, line_cd], vertex=p_c, angle=30) r1 = Collineation('Collineation AEB', points=[p_a, p_e, p_b]) r2 = Parallel('Parallel AB and CD', line1=line_ab, line2=line_cd, colllineation1=r1) entity = Entity('Parallel problem') entity.add_entity(p_a, p_b, p_c, p_d, p_e) entity.add_entity(line_ab, line_ae, line_eb, line_cd, line_ec) entity.add_entity(angle_aec, angle_dce) problem = Problem(entity=entity, relationships=[r1, r2]) print('Create a triangle successfully!') print(problem) return problem
def create_problem(): p_o = Point('O') p_a = Point('A') p_b = Point('B') p_c = Point('C') p_d = Point('D') line_oa = Line('OA', ends=[p_o, p_a], length=None) line_ob = Line('OB', ends=[p_o, p_b], length=None) line_oc = Line('OC', ends=[p_o, p_c], length=None) line_od = Line('OD', ends=[p_o, p_d], length=None) angle_aob = Angle('AOB', sides=[line_oa, line_ob], vertex=p_o, angle=40) angle_cod = Angle('COD', sides=[line_oc, line_od], vertex=p_o, angle=None) r = OppositeVerticalAngle('vertical angle', angle1=angle_aob, angle2=angle_cod, vertex=p_o) entity = Entity('Vertical angle problem') entity.add_entity(p_o, p_a, p_b, p_c, p_d) entity.add_entity(line_oa, line_ob, line_oc, line_od) entity.add_entity(angle_aob, angle_cod) problem = Problem(entity=entity, relationships=[r]) print('Create a triangle successfully!') print(problem) return problem
def create_problem(): p_a = Point('A') p_b = Point('B') p_c = Point('C') p_d = Point('D') line_ba = Line('BA', ends=[p_b, p_a], length=None) line_bc = Line('BC', ends=[p_b, p_c], length=None) line_bd = Line('BD', ends=[p_b, p_d], length=None) angle_bac = Angle('ABD', sides=[line_ba, line_bd], vertex=p_b, angle=50) angle_cad = Angle('CBD', sides=[line_bc, line_bd], vertex=p_b, angle=None) r = SupplementaryAngle('CommonVertexAngle ABD and CBD', angle1=angle_bac, angle2=angle_cad) entity = Entity('SupplementaryAngle problem') entity.add_entity(p_a, p_b, p_c, p_d) entity.add_entity(line_ba, line_bc, line_bd) entity.add_entity(angle_bac, angle_cad) problem = Problem(entity=entity, relationships=[r]) print('Create a triangle successfully!') print(problem) return problem
def create_problem(): p_a = Point('A') p_b = Point('B') p_c = Point('C') line_ab = Line('AB', ends=[p_a, p_b], length=4) line_bc = Line('BC', ends=[p_b, p_c], length=3) line_ac = Line('AC', ends=[p_a, p_c], length=5) angle_abc = Angle('ABC', sides=[line_ab, line_bc], vertex=p_b, angle=None) angle_bac = Angle('BAC', sides=[line_ab, line_ac], vertex=p_a, angle=None) angle_acb = Angle('ACB', sides=[line_ac, line_bc], vertex=p_c, angle=None) triangle_abc = Triangle('ABC', vertexes=[p_a, p_b, p_c], sides=[line_ab, line_bc, line_ac], angles=[angle_acb, angle_bac, angle_abc], area=None) entity = Entity('Proof right triangle problem') entity.add_entity(p_a, p_b, p_c) entity.add_entity(line_ab, line_bc, line_ac) entity.add_entity(triangle_abc) problem = Problem(entity=entity) print('Create a triangle successfully!') print(problem) return problem
def create_problem(): p_a = Point('A') p_b = Point('B') p_c = Point('C') p_d = Point('D') line_ab = Line('AB', ends=[p_a, p_b], length=None) line_ac = Line('AC', ends=[p_a, p_c], length=None) line_ad = Line('AD', ends=[p_a, p_d], length=None) angle_bac = Angle('BAC', sides=[line_ab, line_ac], vertex=p_a, angle=40) angle_cad = Angle('CAD', sides=[line_ac, line_ad], vertex=p_a, angle=30) angle_bad = Angle('BAD', sides=[line_ab, line_ad], vertex=p_a, angle=None) r = CommonVertexAngle('common vertex A', vertex=p_a, lines=[line_ab, line_ac, line_ad]) entity = Entity('CommonVertexAngle problem') entity.add_entity(p_a, p_b, p_c, p_d) entity.add_entity(line_ab, line_ac, line_ad) entity.add_entity(angle_bac, angle_cad, angle_bad) problem = Problem(entity=entity, relationships=[r]) print('Create a triangle successfully!') print(problem) return problem
def create_problem2(): p_a = Point('A') p_b = Point('B') p_c = Point('C') p_e = Point('E') line_ab = Line('AB', ends=[p_a, p_b], length=None) line_ae = Line('AE', ends=[p_a, p_e], length=None) line_be = Line('BE', ends=[p_b, p_e], length=None) line_ce = Line('CE', ends=[p_c, p_e], length=None) angle_bac = Angle('AEC', sides=[line_ae, line_ce], vertex=p_e, angle=None) angle_bec = Angle('BEC', sides=[line_be, line_ce], vertex=p_e, angle=None) col = Collineation('Collineation AEB', points=[p_a, p_e, p_b]) perp = Perpendicular('Perpendicular AB CE', line1=line_ab, line2=line_ce, foot_point=p_e) entity = Entity('Perpendicular problem') entity.add_entity(p_a, p_b, p_c, p_e) entity.add_entity(line_ab, line_ae, line_be, line_ce) entity.add_entity(angle_bac, angle_bec) problem = Problem(entity=entity, relationships=[col, perp]) print('Create a triangle successfully!') print(problem) return problem
def create_problem(): pa = Point('A') pb = Point('B') pc = Point('C') line_ab = Line('AB', ends=[pa, pb], length=None) line_bc = Line('BC', ends=[pb, pc], length=None) line_ac = Line('AC', ends=[pa, pc], length=None) angle_abc = Angle('ABC', sides=[line_ab, line_bc], vertex=pb, angle=90) angle_acb = Angle('ACB', sides=[line_ac, line_bc], vertex=pc, angle=30) angle_bac = Angle('BAC', sides=[line_ab, line_ac], vertex=pa, angle=None) triangle = Triangle('ABC', vertexes=[pa, pb, pc], sides=[line_ab, line_ac, line_bc], angles=[angle_abc, angle_acb, angle_bac], area=None) entity = Entity('basic problem: test triangle angle reduction.') entity.add_entity(triangle) problem = Problem(entity=entity) print('Create a triangle successfully!') print(problem) return problem
def test_angle(): p1 = Point('A') p2 = Point('B') p3 = Point('C') line1 = Line('AB', ends=[p1, p2], length=34.5) line2 = Line('BC', ends=[p2, p3], length=13.2) angle = Angle('ABC', sides=[line1, line2], vertex=p2, angle=60) print(angle)
def create_problem(): p_a = Point('A') p_b = Point('B') p_c = Point('C') p_d = Point('D') p_e = Point('E') line_ab = Line('AB', ends=[p_a, p_b], length=None) line_ac = Line('AC', ends=[p_a, p_c], length=None) line_ae = Line('AE', ends=[p_a, p_e], length=None) line_bc = Line('BC', ends=[p_b, p_c], length=None) line_bd = Line('BD', ends=[p_b, p_d], length=210) line_be = Line('BE', ends=[p_b, p_e], length=None) line_ce = Line('CE', ends=[p_c, p_e], length=None) line_de = Line('DE', ends=[p_d, p_e], length=None) angle_abd = Angle('ABD', sides=[line_ab, line_bd], vertex=p_b, angle=120) angle_dbe = Angle('DBE', sides=[line_bd, line_be], vertex=p_b, angle=None) angle_bde = Angle('BDE', sides=[line_bd, line_de], vertex=p_d, angle=30) angle_aed = Angle('AED', sides=[line_ae, line_de], vertex=p_e, angle=None) triangle_bde = Triangle('BDE', vertexes=[p_b, p_d, p_e], sides=[line_bd, line_be, line_de], angles=[angle_aed, angle_bde, angle_dbe], area=None) collineation_abce = Collineation('collineation_abce', points=[p_a, p_b, p_c, p_e]) supplementary_angle_abd_dbe = SupplementaryAngle( 'supplementary_angle_abd_dbe', angle1=angle_abd, angle2=angle_dbe) perpendicular_ae_de = Perpendicular('perpendicular_ae_de', line1=line_ae, line2=line_de, foot_point=p_e) entities = [] relationships = [] entity_prefix = ('p_', 'line_', 'angle_', 'triangle_') relationship_prefix = ('collineation_', 'supplementary_angle_', 'perpendicular_') for name, var in locals().items(): if name.startswith(entity_prefix): entities.append(var) elif name.startswith(relationship_prefix): relationships.append(var) entity = Entity('Example') entity.add_entity(*entities) problem = Problem(entity=entity, relationships=relationships) print('Create problem successfully!') print(problem) return problem
def create_problem(): p_a = Point('A') p_b = Point('B') p_c = Point('C') p_m = Point('M') p_n = Point('N') line_ab = Line('AB', ends=[p_a, p_b], length=5) line_ac = Line('AC', ends=[p_a, p_c], length=5) line_an = Line('AN', ends=[p_a, p_n], length=None) line_bc = Line('BC', ends=[p_b, p_c], length=6) line_bm = Line('BM', ends=[p_b, p_m], length=None) line_cm = Line('CM', ends=[p_c, p_m], length=None) line_cn = Line('CN', ends=[p_c, p_n], length=None) line_mn = Line('MN', ends=[p_m, p_n], length=None) angle_bac = Angle('BAC', sides=[line_ab, line_ac], vertex=p_a, angle=None) angle_abc = Angle('ABC', sides=[line_ab, line_bc], vertex=p_b, angle=None) angle_acb = Angle('ACB', sides=[line_ac, line_bc], vertex=p_c, angle=None) angle_anm = Angle('ANM', sides=[line_an, line_mn], vertex=p_n, angle=None) angle_cnm = Angle('CNM', sides=[line_cn, line_mn], vertex=p_n, angle=None) angle_bmn = Angle('BMN', sides=[line_bm, line_mn], vertex=p_m, angle=None) angle_cmn = Angle('CMN', sides=[line_cm, line_mn], vertex=p_m, angle=None) triangle_abc = Triangle('ABC', vertexes=[p_a, p_b, p_c], sides=[line_ab, line_ac, line_bc], angles=[angle_acb, angle_abc, angle_bac], area=None) triangle_cmn = Triangle('CMN', vertexes=[p_c, p_m, p_n], sides=[line_cm, line_cn, line_mn], angles=[angle_cnm, angle_cmn, angle_acb], area=None) collineation_bmc = Collineation('collineation_bmc', points=[p_b, p_m, p_c]) collineation_anc = Collineation('collineation_anc', points=[p_a, p_n, p_c]) supplementary_angle_amn_cmn = SupplementaryAngle('supplementary_angle_amn_cmn', angle1=angle_bmn, angle2=angle_cmn) supplementary_angle_anm_cnm = SupplementaryAngle('supplementary_angle_anm_cnm', angle1=angle_anm, angle2=angle_cnm) perpendicular_mn_cn = Perpendicular('perpendicular_mn_cn', line1=line_mn, line2=line_cn, foot_point=p_n) n_line_sector_bc_m = NLineSector('n_angle_sector_bac_ae', line=line_bc, point=p_m, ratio=1/2) entities = [] relationships = [] entity_prefix = ('p_', 'line_', 'angle_', 'triangle_') relationship_prefix = ('collineation_', 'supplementary_angle_', 'perpendicular_', 'n_angle_sector_', 'n_line_sector_') for name, var in locals().items(): if name.startswith(entity_prefix): entities.append(var) elif name.startswith(relationship_prefix): relationships.append(var) entity = Entity('Example') entity.add_entity(*entities) problem = Problem(entity=entity, relationships=relationships) print('Create problem successfully!') print(problem) return problem
def test_triangle(): pa = Point('A') pb = Point('B') pc = Point('C') line_ab = Line('AB', ends=[pa, pb], length=None) line_bc = Line('BC', ends=[pb, pc], length=None) line_ac = Line('AC', ends=[pa, pc], length=None) angle_abc = Angle('ABC', sides=[line_ab, line_bc], vertex=pb, angle=90) angle_acb = Angle('ACB', sides=[line_ac, line_bc], vertex=pc, angle=40) angle_bac = Angle('BAC', sides=[line_ab, line_ac], vertex=pa, angle=None) triangle = Triangle('ABC', vertexes=[pa, pb, pc], sides=[line_ab, line_ac, line_bc], angles=[angle_abc, angle_acb, angle_bac], area=6) print(triangle)
def create_problem(): p_a = Point('A') p_b = Point('B') p_c = Point('C') line_ab = Line('AB', ends=[p_a, p_b], length=1) line_bc = Line('BC', ends=[p_b, p_c], length=2) line_ac = Line('AC', ends=[p_a, p_c], length=None) r_collineation = Collineation('ABC collineation', [p_a, p_b, p_c]) entity = Entity('Collineation problem') entity.add_entity(p_a, p_b, p_c) entity.add_entity(line_ab, line_bc, line_ac) problem = Problem(entity=entity, relationships=[r_collineation]) print('Create a triangle successfully!') print(problem) return problem
def create_problem(): p_a = Point('A') p_b = Point('B') p_c = Point('C') p_d = Point('D') p_e = Point('E') p_f = Point('F') line_ab = Line('AB', ends=[p_a, p_b], length=2) line_ac = Line('AC', ends=[p_a, p_c], length=None) line_bc = Line('BC', ends=[p_b, p_c], length=4) line_de = Line('DE', ends=[p_d, p_e], length=1) line_df = Line('DF', ends=[p_d, p_f], length=None) line_ef = Line('EF', ends=[p_e, p_f], length=None) angle_abc = Angle('ABC', sides=[line_ab, line_bc], vertex=p_b, angle=60) angle_acb = Angle('ACB', sides=[line_ac, line_bc], vertex=p_c, angle=30) angle_bac = Angle('BAC', sides=[line_ab, line_ac], vertex=p_a, angle=90) angle_def = Angle('DEF', sides=[line_de, line_ef], vertex=p_e, angle=60) angle_dfe = Angle('DFE', sides=[line_df, line_ef], vertex=p_f, angle=30) angle_edf = Angle('EDF', sides=[line_de, line_df], vertex=p_d, angle=90) triangle1 = Triangle('ABC', vertexes=[p_a, p_b, p_c], sides=[line_ab, line_ac, line_bc], angles=[angle_acb, angle_abc, angle_bac], area=None) triangle2 = Triangle('DEF', vertexes=[p_d, p_e, p_f], sides=[line_de, line_df, line_ef], angles=[angle_dfe, angle_def, angle_edf], area=None) entity = Entity('Similar triangle problem') entity.add_entity(p_a, p_b, p_c, p_d, p_e, p_f) entity.add_entity(line_ab, line_ac, line_bc, line_de, line_df, line_ef) entity.add_entity(angle_abc, angle_acb, angle_bac, angle_def, angle_dfe, angle_edf) entity.add_entity(triangle1, triangle2) problem = Problem(entity=entity) print('Create a triangle successfully!') print(problem) return problem
def get_problem(self) -> Problem: """This function is used to generate entities automatically.""" if self.problem is not None: return self.problem print('Using intelligent parser...') def sort_string(str_): return ''.join(sorted(str_)) # Generate points. points = {pid: Point(pid) for pid in self._points} # Generate lines. lines = {} for lid in self._lines: lid = sort_string(lid) ends = [points[pid] for pid in lid] length = self._look_up_length(lid) line = Line(lid, ends=ends, length=length) lines[lid] = line def find_line_by_ends(pid1, pid2): return lines[sort_string(''.join([pid1, pid2]))] # Generate angles. angles = {} for vertex, adj_nodes in self._adj_table.items(): n_adj = len(adj_nodes) for i in range(n_adj): for j in range(i + 1, n_adj): node1, node2 = adj_nodes[i], adj_nodes[j] node1 = self._line_alias[node1 + vertex][0] node2 = self._line_alias[vertex + node2][1] # Angle with zero degree if node1 == node2: continue # Flat angle if self._is_collineation(node1, vertex, node2): continue node1, node2 = sorted([node1, node2]) aid = ''.join([node1, vertex, node2]) line1 = find_line_by_ends(node1, vertex) line2 = find_line_by_ends(node2, vertex) sides = [line1, line2] degree = self._look_up_degree(aid) angles[aid] = Angle(aid, sides=sides, vertex=points[vertex], angle=degree) def find_angle_by_points(pid1, vertex, pid2): return angles[self._extend_angle(pid1, vertex, pid2)] # Generate triangle. triangles = {} triangle_ids = self._analyse_triangle() for tid in triangle_ids: t_vertexes = [points[v] for v in tid] t_side1 = find_line_by_ends(tid[0], tid[1]) t_side2 = find_line_by_ends(tid[1], tid[2]) t_side3 = find_line_by_ends(tid[0], tid[2]) t_sides = [t_side1, t_side2, t_side3] t_angle1 = find_angle_by_points(tid[0], tid[2], tid[1]) t_angle2 = find_angle_by_points(tid[1], tid[0], tid[2]) t_angle3 = find_angle_by_points(tid[0], tid[1], tid[2]) t_angles = [t_angle1, t_angle2, t_angle3] triangles[tid] = Triangle(tid, vertexes=t_vertexes, sides=t_sides, angles=t_angles, area=None) print('points: ', sorted(points.keys())) print('lines', sorted(lines.keys())) print('angles: ', sorted(angles.keys())) print('triangles: ', sorted(triangles.keys())) # Generate relationships. collineations = {} for col in self._collineation_list: col_id = 'Collineation ' + ''.join([p for p in col]) ps = [points[pid] for pid in col] collineations[col_id] = Collineation(col_id, points=ps) # Generate opposite vertival angles. opposite_angles = {} n_cols = len(self._collineation_list) for i in range(n_cols): for j in range(i + 1, n_cols): col1 = self._collineation_list[i] col2 = self._collineation_list[j] common = list(set(col1) & set(col2)) if len(common) != 1: continue vertex = common[0] if vertex in [col1[0], col1[-1], col2[0], col2[-1]]: continue angle1_1 = find_angle_by_points(col1[0], vertex, col2[0]) angle1_2 = find_angle_by_points(col1[-1], vertex, col2[-1]) rid = ' '.join(['OppositeAngle', angle1_1.id, angle1_2.id]) opposite_angles[rid] = OppositeVerticalAngle(rid, angle1=angle1_1, angle2=angle1_2, vertex=vertex) angle2_1 = find_angle_by_points(col1[0], vertex, col2[-1]) angle2_2 = find_angle_by_points(col1[-1], vertex, col2[0]) rid = ' '.join(['OppositeAngle', angle2_1.id, angle2_2.id]) opposite_angles[rid] = OppositeVerticalAngle(rid, angle1=angle2_1, angle2=angle2_2, vertex=vertex) # Generate supplementary angles. supplementary_angles = {} for col in self._collineation_list: for p in col[1:-1]: for adj_p in self._adj_table[p]: if adj_p in col: continue angle1 = find_angle_by_points(col[0], p, adj_p) angle2 = find_angle_by_points(col[-1], p, adj_p) rid = ' '.join( ['SupplementaryAngle', angle1.id, angle2.id]) supplementary_angles[rid] = \ SupplementaryAngle(rid, angle1=angle1, angle2=angle2) # Generate common vertex angles. common_vertex_angles = {} for v, arounds in self._common_vertex: vertex = points[v] lines_ = [] for pid in arounds: lines_.append(find_line_by_ends(v, pid)) rid = ' '.join(['CommonVertexAngle', v, ''.join(arounds)]) r = CommonVertexAngle(rid, vertex=vertex, lines=lines_) common_vertex_angles[rid] = r # Generate n angles sector. n_angles_sector = {} for aid, lid, ratio in self._angle_split: near_line = find_line_by_ends(*self._line_alias[aid[:2]]) angle_ = find_angle_by_points(*aid) line_ = find_line_by_ends(*lid) rid = ' '.join([angle_.id, line_.id, str(ratio), near_line.id]) r = NAngleSector(rid, angle=angle_, line=line_, ratio=ratio, nearer_line=near_line) n_angles_sector[rid] = r n_line_sector = {} for lid, pid, ratio in self._line_split: rid = ' '.join(['NLineSector', lid, pid, str(ratio)]) r = NLineSector(rid, line=lines[lid], point=points[pid], ratio=ratio, nearer_point=points[lid[0]]) n_line_sector[rid] = r # Generate perpendicular relationship. perpendiculars = {} for lid1, lid2 in self._perpendicular_pairs: rid = ' '.join(['Perpendicular', lid1, lid2]) r = Perpendicular(rid, line1=lines[lid1], line2=lines[lid2], foot_point=None) perpendiculars[rid] = r # Generate parallel relationship. parallels = {} for line_ids in self._parallel_sets: line_num = len(line_ids) for i in range(line_num): for j in range(i + 1, line_num): line1 = lines[line_ids[i]] line2 = lines[line_ids[j]] rid = ' '.join(['Parallel', line_ids[i], line_ids[j]]) parallels[rid] = Parallel(rid, line1, line2) print('collineations: ', sorted(collineations.keys())) print('opposite angles: ', sorted(opposite_angles.keys())) print('supplementary angles: ', sorted(supplementary_angles.keys())) print('common vertex angles: ', sorted(common_vertex_angles.keys())) print('n angles sector: ', sorted(n_angles_sector.keys())) print('n line sector: ', sorted(n_line_sector.keys())) print('perpendiculars: ', sorted(perpendiculars.keys())) print('parallels: ', sorted(parallels.keys())) relationships = [] relationships += collineations.values() relationships += opposite_angles.values() relationships += supplementary_angles.values() relationships += common_vertex_angles.values() relationships += n_angles_sector.values() relationships += perpendiculars.values() relationships += n_line_sector.values() relationships += parallels.values() self.env['points'] = points self.env['lines'] = lines self.env['angles'] = angles self.env['triangles'] = triangles self.env['relationships'] = relationships self.entity_container.add_entity(*(points.values())) self.entity_container.add_entity(*(lines.values())) self.entity_container.add_entity(*(angles.values())) self.entity_container.add_entity(*(triangles.values())) self.problem = Problem(entity=self.entity_container, relationships=relationships) return self.problem
def create_problem(): p_a = Point('A') p_b = Point('B') p_c = Point('C') p_d = Point('D') p_e = Point('E') line_ab = Line('AB', ends=[p_a, p_b], length=None) line_ac = Line('AC', ends=[p_a, p_c], length=None) line_ad = Line('AD', ends=[p_a, p_d], length=None) line_ae = Line('AE', ends=[p_a, p_e], length=None) line_bc = Line('BC', ends=[p_b, p_c], length=None) line_bd = Line('BD', ends=[p_b, p_d], length=None) line_be = Line('BE', ends=[p_b, p_e], length=None) line_ce = Line('CE', ends=[p_c, p_e], length=None) line_de = Line('DE', ends=[p_d, p_e], length=None) angle_bac = Angle('BAC', sides=[line_ab, line_ac], vertex=p_a, angle=60) angle_bad = Angle('BAD', sides=[line_ab, line_ad], vertex=p_a, angle=90) angle_cad = Angle('CAD', sides=[line_ac, line_ad], vertex=p_a, angle=None) angle_abc = Angle('ABC', sides=[line_ab, line_bc], vertex=p_b, angle=90) angle_abd = Angle('ABD', sides=[line_ab, line_bd], vertex=p_b, angle=45) angle_cbd = Angle('CBD', sides=[line_bc, line_bd], vertex=p_b, angle=None) angle_acb = Angle('ACB', sides=[line_ac, line_ab], vertex=p_c, angle=30) angle_adb = Angle('ADB', sides=[line_ad, line_bd], vertex=p_d, angle=45) angle_aeb = Angle('AEB', sides=[line_ae, line_be], vertex=p_e, angle=None) angle_aed = Angle('AED', sides=[line_ae, line_de], vertex=p_e, angle=None) angle_bec = Angle('BEC', sides=[line_be, line_ce], vertex=p_e, angle=None) angle_ced = Angle('CED', sides=[line_ce, line_de], vertex=p_e, angle=None) triangle_abc = Triangle('ABC', vertexes=[p_a, p_b, p_c], sides=[line_ab, line_bc, line_ac], angles=[angle_bac, angle_abc, angle_acb], area=None) triangle_abe = Triangle('ABE', vertexes=[p_a, p_b, p_e], sides=[line_ab, line_be, line_ae], angles=[angle_bac, angle_abd, angle_aeb], area=None) triangle_abd = Triangle('ABD', vertexes=[p_a, p_b, p_d], sides=[line_ab, line_bd, line_ad], angles=[angle_bad, angle_abd, angle_adb], area=None) triangle_ade = Triangle('ADE', vertexes=[p_a, p_d, p_e], sides=[line_ad, line_ae, line_de], angles=[angle_cad, angle_aed, angle_adb], area=None) triangle_bce = Triangle('BCE', vertexes=[p_b, p_c, p_e], sides=[line_bc, line_be, line_ce], angles=[angle_cbd, angle_bec, angle_acb], area=None) collineation_aec = Collineation('collineation_aec', points=[p_a, p_e, p_c]) collineation_bed = Collineation('collineation_bed', points=[p_b, p_e, p_d]) vertical_angle_bfd_cfe = OppositeVerticalAngle('vertical_angle_aed_bec', angle1=angle_aed, angle2=angle_bec, vertex=p_e) vertical_angle_dfe_bfc = OppositeVerticalAngle('vertical_angle_aeb_ced', angle1=angle_aeb, angle2=angle_ced, vertex=p_e) supplementary_angle_adc_bdc = SupplementaryAngle( 'suoolementary_angle_aeb_bec', angle1=angle_aeb, angle2=angle_bec) supplementary_angle_bfd_bfc = SupplementaryAngle( 'supplementary_angle_aeb_aed', angle1=angle_aeb, angle2=angle_aed) supplementary_angle_dfe_cfe = SupplementaryAngle( 'supplementary_angle_aed_ced', angle1=angle_aed, angle2=angle_ced) supplementary_angle_bfd_dfe = SupplementaryAngle( 'supplementary_angle_ced_bec', angle1=angle_ced, angle2=angle_bec) entities = [] relationships = [] for name, var in locals().items(): if name.startswith(('p', 'line', 'angle', 'triangle')): entities.append(var) elif name.startswith( ('collineation', 'vertical_angle', 'supplementary_angle')): relationships.append(var) entity = Entity('Example') entity.add_entity(*entities) problem = Problem(entity=entity, relationships=relationships) print('Create problem successfully!') print(problem) return problem
def create_problem(): p_a = Point('A') p_b = Point('B') p_c = Point('C') p_d = Point('D') p_e = Point('E') p_f = Point('F') line_ab = Line('AB', ends=[p_a, p_b], length=None) line_ac = Line('AC', ends=[p_a, p_c], length=None) line_ad = Line('AD', ends=[p_a, p_d], length=None) line_ae = Line('AE', ends=[p_a, p_e], length=None) line_bc = Line('BC', ends=[p_b, p_c], length=None) line_bd = Line('BD', ends=[p_b, p_d], length=None) line_be = Line('BE', ends=[p_b, p_e], length=None) line_bf = Line('BF', ends=[p_b, p_f], length=None) line_cd = Line('CD', ends=[p_c, p_d], length=None) line_ce = Line('CE', ends=[p_c, p_e], length=None) line_cf = Line('CF', ends=[p_c, p_f], length=None) line_df = Line('DF', ends=[p_d, p_f], length=None) line_ef = Line('EF', ends=[p_e, p_f], length=None) angle_bac = Angle('BAC', sides=[line_ab, line_ac], vertex=p_a, angle=45) angle_abc = Angle('ABC', sides=[line_ab, line_bc], vertex=p_b, angle=None) angle_abe = Angle('ABE', sides=[line_ab, line_be], vertex=p_b, angle=40) angle_cbe = Angle('CBE', sides=[line_bc, line_be], vertex=p_b, angle=None) angle_acb = Angle('ACB', sides=[line_ac, line_ab], vertex=p_c, angle=None) angle_acd = Angle('ACD', sides=[line_ac, line_cd], vertex=p_c, angle=20) angle_bcd = Angle('BCD', sides=[line_bc, line_cd], vertex=p_c, angle=None) angle_bdc = Angle('BDC', sides=[line_bd, line_cd], vertex=p_d, angle=None) angle_adc = Angle('ADC', sides=[line_ad, line_cd], vertex=p_d, angle=None) angle_aeb = Angle('AEB', sides=[line_ae, line_be], vertex=p_e, angle=None) angle_bec = Angle('BEC', sides=[line_be, line_ce], vertex=p_e, angle=None) angle_bfd = Angle('BFD', sides=[line_df, line_bf], vertex=p_f, angle=None) angle_dfe = Angle('DFE', sides=[line_df, line_ef], vertex=p_f, angle=None) angle_cfe = Angle('CFE', sides=[line_cf, line_ef], vertex=p_f, angle=None) angle_bfc = Angle('BFC', sides=[line_bf, line_cf], vertex=p_f, angle=None) triangle_abc = Triangle('ABC', vertexes=[p_a, p_b, p_c], sides=[line_ab, line_bc, line_ac], angles=[angle_bac, angle_abc, angle_acb], area=None) triangle_abe = Triangle('ABE', vertexes=[p_a, p_b, p_e], sides=[line_ab, line_be, line_ae], angles=[angle_bac, angle_abe, angle_aeb], area=None) triangle_acd = Triangle('ACD', vertexes=[p_a, p_c, p_d], sides=[line_ad, line_ac, line_cd], angles=[angle_bac, angle_adc, angle_acd], area=None) triangle_bcd = Triangle('BCD', vertexes=[p_b, p_c, p_d], sides=[line_bc, line_bd, line_cd], angles=[angle_abc, angle_bdc, angle_bcd], area=None) triangle_bdf = Triangle('BDF', vertexes=[p_b, p_d, p_f], sides=[line_bd, line_bf, line_df], angles=[angle_abe, angle_bdc, angle_bfd], area=None) triangle_bce = Triangle('BCE', vertexes=[p_b, p_c, p_e], sides=[line_bc, line_be, line_ce], angles=[angle_cbe, angle_bec, angle_acb], area=None) triangle_bcf = Triangle('BCF', vertexes=[p_b, p_c, p_f], sides=[line_bc, line_bf, line_cf], angles=[angle_cbe, angle_bcd, angle_bfc], area=None) triangle_cef = Triangle('CEF', vertexes=[p_c, p_e, p_f], sides=[line_ce, line_cf, line_ef], angles=[angle_acd, angle_cfe, angle_bec], area=None) collineation_adb = Collineation('collineation_adb', points=[p_a, p_d, p_b]) collineation_aec = Collineation('collineation_aec', points=[p_a, p_e, p_c]) collineation_cfd = Collineation('collineation_cfd', points=[p_c, p_f, p_d]) collineation_bfe = Collineation('collineation_bfe', points=[p_b, p_f, p_e]) vertical_angle_bfd_cfe = OppositeVerticalAngle('vertical_angle_bfd_cfe', angle1=angle_bfd, angle2=angle_cfe, vertex=p_f) vertical_angle_dfe_bfc = OppositeVerticalAngle('vertical_angle_dfe_bfc', angle1=angle_dfe, angle2=angle_bfc, vertex=p_f) supplementary_angle_adc_bdc = SupplementaryAngle( 'suoolementary_angle_adc_bdc', angle1=angle_adc, angle2=angle_bdc) supplementary_angle_bec_aeb = SupplementaryAngle( 'supplementary_angle_bec_aeb', angle1=angle_bec, angle2=angle_aeb) supplementary_angle_bfd_bfc = SupplementaryAngle( 'supplementary_angle_bfd_bfc', angle1=angle_bfd, angle2=angle_bfc) supplementary_angle_dfe_cfe = SupplementaryAngle( 'supplementary_angle_dfe_cfe', angle1=angle_dfe, angle2=angle_cfe) supplementary_angle_bfd_dfe = SupplementaryAngle( 'supplementary_angle_bfd_dfe', angle1=angle_bfd, angle2=angle_dfe) supplementary_angle_bfc_cfe = SupplementaryAngle( 'supplementary_angle_bfc_cfe', angle1=angle_bfc, angle2=angle_cfe) entities = [] relationships = [] for name, var in locals().items(): if name.startswith(('p', 'line', 'angle', 'triangle')): entities.append(var) elif name.startswith( ('collineation', 'vertical_angle', 'supplementary_angle')): relationships.append(var) entity = Entity('Example') entity.add_entity(*entities) problem = Problem(entity=entity, relationships=relationships) print('Create problem successfully!') print(problem) return problem
def test_line(): p1 = Point('A') p2 = Point('B') line = Line('AB', ends=[p1, p2], length=34.5) print(line)
def create_problem(): p_a = Point('A') p_b = Point('B') p_c = Point('C') p_d = Point('D') p_e = Point('F') line_ab = Line('AB', ends=[p_a, p_b], length=None) line_ac = Line('AC', ends=[p_a, p_c], length=None) line_ad = Line('AD', ends=[p_a, p_d], length=None) line_ae = Line('AF', ends=[p_a, p_e], length=None) line_bc = Line('BC', ends=[p_b, p_c], length=None) line_bd = Line('BD', ends=[p_b, p_d], length=None) line_be = Line('BF', ends=[p_b, p_e], length=None) line_cd = Line('CD', ends=[p_c, p_d], length=None) line_ce = Line('CF', ends=[p_c, p_e], length=None) line_de = Line('DF', ends=[p_d, p_e], length=None) angle_bae = Angle('BAF', sides=[line_ab, line_ae], vertex=p_a, angle=None) angle_bad = Angle('BAD', sides=[line_ab, line_ad], vertex=p_a, angle=None) angle_bac = Angle('BAC', sides=[line_ab, line_ac], vertex=p_a, angle=None) angle_dae = Angle('DAF', sides=[line_ad, line_ae], vertex=p_a, angle=None) angle_cae = Angle('CAF', sides=[line_ac, line_ae], vertex=p_a, angle=None) angle_cad = Angle('CAD', sides=[line_ad, line_cd], vertex=p_a, angle=None) angle_abc = Angle('ABC', sides=[line_ab, line_bc], vertex=p_b, angle=36) angle_acb = Angle('ACB', sides=[line_ac, line_bc], vertex=p_c, angle=76) angle_adc = Angle('ADC', sides=[line_ad, line_cd], vertex=p_d, angle=None) angle_adb = Angle('ADB', sides=[line_ad, line_bd], vertex=p_d, angle=None) angle_aeb = Angle('AFB', sides=[line_ae, line_be], vertex=p_e, angle=None) angle_aec = Angle('AFC', sides=[line_ae, line_ce], vertex=p_e, angle=None) triangle_abc = Triangle('ABC', vertexes=[p_a, p_b, p_c], sides=[line_ab, line_ac, line_bc], angles=[angle_acb, angle_abc, angle_bac], area=None) triangle_abd = Triangle('ABD', vertexes=[p_a, p_b, p_d], sides=[line_ab, line_ad, line_bd], angles=[angle_adb, angle_abc, angle_bad], area=None) triangle_abe = Triangle('ABF', vertexes=[p_a, p_b, p_e], sides=[line_ab, line_ae, line_be], angles=[angle_aeb, angle_abc, angle_bae], area=None) triangle_acd = Triangle('ACD', vertexes=[p_a, p_c, p_d], sides=[line_ac, line_ad, line_cd], angles=[angle_adc, angle_acb, angle_cad], area=None) triangle_ace = Triangle('ACF', vertexes=[p_a, p_c, p_e], sides=[line_ac, line_ae, line_ce], angles=[angle_aec, angle_acb, angle_cae], area=None) triangle_ade = Triangle('ADF', vertexes=[p_a, p_d, p_e], sides=[line_ad, line_ae, line_de], angles=[angle_aec, angle_adb, angle_dae], area=None) collineation_bedc = Collineation('collineation_bedc', points=[p_b, p_e, p_d, p_c]) supplementary_angle_aeb_aec = SupplementaryAngle( 'supplementary_angle_aeb_aec', angle1=angle_aeb, angle2=angle_aec) supplementary_angle_adb_adc = SupplementaryAngle( 'supplementary_angle_adb_adc', angle1=angle_adb, angle2=angle_adc) perpendicular_ad_bd = Perpendicular('perpendicular_ad_bd', line1=line_ad, line2=line_bd, foot_point=p_d) n_angle_sector_bac_ae = NAngleSector('n_angle_sector_bac_ae', angle=angle_bac, line=line_ae, ratio=1 / 2) common_vertex_angle_a = CommonVertexAngle( 'common_vertex_angle_a', vertex=p_a, lines=[line_ab, line_ae, line_ad, line_ac]) entities = [] relationships = [] entity_prefix = ('p_', 'line_', 'angle_', 'triangle_') relationship_prefix = ('collineation_', 'supplementary_angle_', 'perpendicular_', 'n_angle_sector_', 'n_line_sector_') for name, var in locals().items(): if name.startswith(entity_prefix): entities.append(var) elif name.startswith(relationship_prefix): relationships.append(var) entity = Entity('Example') entity.add_entity(*entities) problem = Problem(entity=entity, relationships=relationships) print('Create problem successfully!') print(problem) return problem