def chk_tri_ell_hy(myck): """[summary] Arguments: myck (type): [description] K (type): [description] Raises: NotImplementedError -- [description] NotImplementedError -- [description] """ a1 = pg_point([33, 121, 54]) a2 = pg_point([33, 564, 34]) a3 = pg_point([34, 64, -62]) temp = myck.perp(a1) triangle = [a1, a2, a3] trilateral = tri_dual(triangle) l1, _, _ = trilateral Q = myck.tri_quadrance(triangle) S = myck.tri_spread(trilateral) a4 = plucker(2, a1, 3, a2) collin = [a1, a2, a4] Q2 = myck.tri_quadrance(collin) assert myck.perp(temp) == a1 assert myck.perp(myck.perp(l1)) == l1 assert myck.quadrance(a1, a1) == 0 assert myck.spread(l1, l1) == 0 assert check_cross_law(S, Q[2]) == 0 assert check_cross_law(Q, S[2]) == 0 assert check_cross_TQF(Q2) == 0
def test_persp(): Ire = pg_point([0, 1, 1]) Iim = pg_point([1, 0, 0]) l_inf = pg_line([0, -1, 1]) P = persp_euclid_plane(Ire, Iim, l_inf) chk_ck(P, pg_point) chk_degenerate(P)
def chk_euclid(K): """[summary] Arguments: K (type): [description] Raises: NotImplementedError -- [description] NotImplementedError -- [description] """ a1 = pg_point([31, -53, 1]) a2 = pg_point([6, 23, 21]) a3 = pg_point([5, -43, 31]) triangle = [a1, a2, a3] trilateral = tri_dual(triangle) l1, l2, l3 = trilateral t1, t2, t3 = tri_altitude(triangle) t4 = harm_conj(t1, t2, t3) o = orthocenter(triangle) tau = reflect(l1) m23, m13, m12 = tri_midpoint(triangle) mt1 = a1 * m23 mt2 = a2 * m13 mt3 = a3 * m12 q1, q2, q3 = tri_quadrance(triangle) s1, s2, s3 = tri_spread(trilateral) tqf = ((q1 + q2 + q3)**2) - 2 * (q1 * q1 + q2 * q2 + q3 * q3) tsf = (s1 + s2 + s3)**2 - 2 * (s1 * s1 + s2 * s2 + s3 * s3) - 4 * s1 * s2 * s3 c3 = ((q1 + q2 - q3)**2) / (4 * q1 * q2) a4 = plucker(3, a1, 4, a2) qq1, qq2, qq3 = tri_quadrance([a1, a2, a4]) tqf2 = Ar(qq1, qq2, qq3) # get 0 assert not is_parallel(l1, l2) assert not is_parallel(l2, l3) assert is_perpendicular(t1, l1) assert spread(t1, l1) == 1 # get 1 assert coincident(t1, t2, t3) assert R(t1, t2, t3, t4) == -1 assert o == meet(t2, t3) assert a1 == orthocenter([o, a2, a3]) assert tau(tau(a1)) == a1 assert coincident(mt1, mt2, mt3) assert spread(l1, l1) == 0 assert quadrance(a1, a1) == 0 assert cross_s(l1, l2) == c3 assert c3 + s3 == 1 # get the same assert tqf == Ar(q1, q2, q3) assert tsf == 0 assert tqf2 == 0
def test_special_case(px, py, pz, Lx, Ly, Lz): p = pg_point([px, py, pz]) L = pg_line([Lx, Ly, Lz]) # L_inf = pg_line([0, 0, 1]) L_nan = pg_line([0, 0, 0]) p_nan = pg_point([0, 0, 0]) assert L_nan.is_NaN() assert L_nan == L_nan assert L_nan == p * p # join two equal points assert p_nan == L * L assert L_nan == p_nan * p assert p_nan == L_nan * L assert p.incident(L_nan) assert L.incident(p_nan) assert p_nan.incident(L_nan)
def chk_degenerate(myck): """[summary] Arguments: myck (type): [description] K (type): [description] Raises: NotImplementedError -- [description] NotImplementedError -- [description] """ a1 = pg_point([-1, 2, 3]) a2 = pg_point([4, -1, 1]) a3 = pg_point([0, -1, 1]) triangle = [a1, a2, a3] trilateral = tri_dual(triangle) l1, l2, l3 = trilateral m23, m13, m12 = myck.tri_midpoint(triangle) t1 = a1 * m23 t2 = a2 * m13 t3 = a3 * m12 q1, q2, q3 = myck.tri_quadrance(triangle) s1, s2, s3 = myck.tri_spread(trilateral) tqf = ((q1 + q2 + q3)**2) - 2 * (q1 * q1 + q2 * q2 + q3 * q3) tsf = (s1 + s2 + s3)**2 - 2 * (s1 * s1 + s2 * s2 + s3 * s3) - 4 * s1 * s2 * s3 a4 = plucker(3, a1, 4, a2) qq1, qq2, qq3 = myck.tri_quadrance([a1, a2, a4]) tqf2 = Ar(qq1, qq2, qq3) # get 0 assert not myck.is_parallel(l1, l2) assert not myck.is_parallel(l2, l3) assert coincident(t1, t2, t3) assert tqf == Ar(q1, q2, q3) assert tsf == 0 assert tqf2 == 0
def no_test_symbolic(): import sympy sympy.init_printing() pv = sympy.symbols("p:3", integer=True) qv = sympy.symbols("q:3", integer=True) lambda1, mu1 = sympy.symbols("lambda1 mu1", integer=True) p = pg_point(pv) q = pg_point(qv) r = plucker(lambda1, p, mu1, q) sv = sympy.symbols("s:3", integer=True) tv = sympy.symbols("t:3", integer=True) lambda2, mu2 = sympy.symbols("lambda2 mu2", integer=True) s = pg_point(sv) t = pg_point(tv) u = plucker(lambda2, s, mu2, t) # Prove Pappus Theorem G = meet(join(p, t), join(q, s)) H = meet(join(p, u), join(r, s)) J = meet(join(q, u), join(r, t)) ans = G.dot(join(H, J)) ans = sympy.simplify(ans) assert ans == 0 # p, q, s, t lambda3, mu3 = sympy.symbols("lambda3 mu3", integer=True) p2 = plucker(lambda1, p, mu1, t) q2 = plucker(lambda2, q, mu2, t) s2 = plucker(lambda3, s, mu3, t) # Prove Desargue Theorem G = meet(join(p, q), join(p2, q2)) H = meet(join(q, s), join(q2, s2)) J = meet(join(s, p), join(s2, p2)) ans = G.dot(join(H, J)) ans = sympy.simplify(ans) assert ans == 0