
# GeomTests.py

import math
import matplotlib.pyplot as plt

from point import Point
from segment import Segment
from vector import Vector
from GeomTools import *

'''
orig = Point(0, 0)
pt1 = Point(3, -5)
pt2 = Point(2, 6)
print("pt1, pt2:", pt1, pt2)
print("Dot product:", Vector.dot(pt1, pt2))
print("Cross product:", Vector.cross(pt1, pt2))
print(f"Angle: {math.degrees( Vector.angle(pt1, orig, pt2)):.2f} degrees")
'''

'''
seg = Segment(Point(1, 1),Point(3, 3))
p = Point(2, 3) 
print("seg, p:", seg, p)
print("Distance of p to segment:", seg.minDist(p)) 
p.draw()
seg.draw()
'''

'''
p = Point(2, 2)
q = Point(4, 4)
r = Point(2, 6)
print("p, q, r:", p, q, r)
ori = Vector.ccw(p, q, r)
if (ori == 0):
  print("colinear")
elif (ori == 1):
  print("counter-clockwise")
else:
  print("clockwise")

p.draw(label="p")
q.draw(label="q")
r.draw(label="r")
'''


seg1 = Segment(Point(1, 1), Point(10, 7)) 
seg2 = Segment(Point(1, 2), Point(10, 2))
print("seg1, seg2:", seg1, seg2)
print("Intersects?", seg1.intersects(seg2)) 
seg1.draw("seg1")
seg2.draw("seg2")


'''
seg1 = Segment( Point(5, 0), Point(0, 5)) 
seg2 = Segment( Point(1, 2), Point(7,7))
print("seg1, seg2:", seg1, seg2)
print("Intersects?", seg1.intersects(seg2)) 
ipt = seg1.intersectPt(seg2)
print("  at", ipt) 

seg1.draw("seg1")
seg2.draw("seg2")
ipt.draw()
'''

'''
segs = [ \
   Segment( Point(1,1), Point(4,3)),
   Segment( Point(2,4), Point(6,1)),
   Segment( Point(3,5), Point(6,3)),
   Segment( Point(5,1), Point(7,5))
  ]

pairs = Segment.allIntersects(segs)
print("No. of Intersections:", len(pairs))

pts = [ seg1.intersectPt(seg2) 
                      for (seg1, seg2) in pairs]
for seg in segs:
  seg.draw()
for pt in pts:
  pt.draw(color="red")
  print(" ", pt)
'''

graphing()
plt.show()


