Exemplo n.º 1
0
def test_angle_lines_2():
    a = 1 / math.sqrt(3)
    b = 1 / a
    l1 = Line(b, 0)
    l2 = Line(a, 0)
    angle = l2.angle(l1)
    assert close_enough(angle, math.pi / 6)
Exemplo n.º 2
0
def test_reflect_line_2():
    a = math.sqrt(3)
    l1 = Line(a, 0)
    axis = Line(1.0, 0)
    l2 = l1.reflect(axis)
    assert close_enough(1 / a, l2.m)
    assert close_enough(0, l2.b)
Exemplo n.º 3
0
def test_intersect_lines_2():
    l1 = Line(1.0, 0)
    l2 = Line(-1.0, 1)
    p = l1.intersect(l2)
    x, y = p.x, p.y
    assert close_enough(0.5, x)
    assert close_enough(0.5, y)
Exemplo n.º 4
0
 def tangent(self, point):
     """
         Returns the tangent line to this ellipse
         at the given point. For now, I'll assume
         the point always lies on the ellipse, so it
         should always return an actual tangent line.
     """
     x, y = point.x, point.y
     a, b = self.a, self.b
     m = (- (b / a) ** 2) * (x / y)
     return Line(m, y - m * x)
Exemplo n.º 5
0
def test_perpendicular():
    l1 = Line(1.0, 0)
    l2 = l1.perpendicular(Point([0.5, 0.5]))
    m, b = l2.m, l2.b
    assert close_enough(-1.0, m)
    assert close_enough(1.0, b)
Exemplo n.º 6
0
def test_rotate_line_III():
    l1 = Line(-1.0, 1.0)
    l2 = l1.rotate(Point([0.5, 0.5]), math.pi / 2)
    m, b = l2.m, l2.b
    assert close_enough(1.0, m)
    assert close_enough(0, b)
Exemplo n.º 7
0
def test_rotate_line():
    l1 = Line(1.0, 0)
    l2 = l1.rotate(origin, math.pi / 2)
    m, b = l2.m, l2.b
    assert close_enough(-1.0, m)
    assert close_enough(0, b)
Exemplo n.º 8
0
def get_line(p1, p2):
    x1, y1 = p1.x, p1.y
    x2, y2 = p2.x, p2.y
    m = (y2 - y1) / (x2 - x1)
    return Line(m, y1 - m * x1)
Exemplo n.º 9
0
from euler.geom.point import Point
from euler.geom.ellipse import Ellipse
from euler.geom.line import Line
import math

p = Point([0.0, 5.0])
e = Ellipse(2.0, 5.0)
l1 = Line(0.0, 0.0)
l2 = Line(0.0, 7.0)


def test_ellipse_has_point():
    assert e.has_point(p) == True


def test_ellipse_intersect():
    assert (len(e.intersect(l1)) == 2)
    assert (len(e.intersect(l2)) == 0)