https://github.com/mirefek/geo_logic
Revision 01b27df4a0938ce8e9349d5397c85905d3bd8026 authored by mirefek on 27 March 2020, 09:32:25 UTC, committed by mirefek on 27 March 2020, 09:32:25 UTC
1 parent 1bcb6ea
Tip revision: 01b27df4a0938ce8e9349d5397c85905d3bd8026 authored by mirefek on 27 March 2020, 09:32:25 UTC
labels for pascal_out
labels for pascal_out
Tip revision: 01b27df
primitive_pred.py
from geo_object import *
import numpy as np
"""
This file contains annotated geometrical predicates.
They are loaded by primitive_tools.py, and converted into
equally named tools.
Functions here return boolean values. The resulting tools
then fail if the value here is False,
and succeed if it is True.
"""
def not_eq(a, b):
return a != b
def intersecting(cl1 : PointSet, cl2 : PointSet):
if isinstance(cl1, Circle) and isinstance(cl2, Circle):
dist = np.linalg.norm(cl1.c - cl2.c)
return intersecting_cc(cl1, cl2)
else:
if isinstance(cl1, Circle): cl1, cl2 = cl2, cl1
assert(isinstance(cl1, Line) and isinstance(cl2, Circle))
return intersecting_lc(cl1, cl2)
def oriented_as(a1 : Point, b1 : Point, c1 : Point,
a2 : Point, b2 : Point, c2 : Point):
det1 = np.linalg.det(np.stack([b1.a-a1.a, c1.a-a1.a]))
det2 = np.linalg.det(np.stack([b2.a-a2.a, c2.a-a2.a]))
if eps_bigger(det1, 0) and eps_bigger(det2, 0): return True
if eps_smaller(det1, 0) and eps_smaller(det2, 0): return True
return False
def dim_less(d1 : Ratio, d2 : Ratio):
return eps_smaller(d1.x, d2.x)
def not_on(p : Point, cl : PointSet):
return not cl.contains(p.a)
def not_collinear(A : Point, B : Point, C : Point):
return not eps_zero(np.linalg.det(np.stack([B.a-A.a, C.a-A.a])))
def lies_on(p : Point, cl : PointSet):
return cl.contains(p.a)
Computing file changes ...