geom2d-0.2.2: package for geometry in euklidean 2d space

Geom2d.Line

Contents

Description

This module describes what lines are defines functions to work with lines.

Synopsis

# Infinite lines

data InfLine p a Source

This type modells a infinite line.

Instances

 Functor p => Functor (InfLine p) Source `InfLine` is a `Functor` where the function is mapped over both points which define the `InfLine`. Translate p => Translate (InfLine p) Source Translate a line by a given vector. (Point p, Eq a, Fractional a) => Intersect (p a) (InfLine p a) Source (Eq (p a), Eq a, RealFloat a, Num (p a), Point p) => Eq (InfLine p a) Source Two lines are equal when they have the same root and the same slope. If the two lines do not have a root, that means that the lines are parallel to the x-axis. In this case we compare their y-value. Read (p a) => Read (InfLine p a) Source Show (p a) => Show (InfLine p a) Source (Eq (p a), Arbitrary (p a)) => Arbitrary (InfLine p a) Source This `Arbitrary` instance should only produce valid `InfLine`s. (Point p, Eq a, Fractional a) => Intersect (InfLine p a) (p a) Source (Eq (p a), Point p, Num (p a), RealFloat a) => Intersect (FinLine p a) (InfLine p a) Source (Eq (p a), Point p, Num (p a), RealFloat a) => Intersect (InfLine p a) (FinLine p a) Source (Eq (p a), Num (p a), Num a, RealFloat a, Point p) => Intersect (InfLine p a) (InfLine p a) Source

mkInfLine :: Eq (p a) => p a -> p a -> Maybe (InfLine p a) Source

Construct an infinit line by specifiying two points. We won't get a line when the given points are equal.

lineF :: (Eq a, Fractional a, Point p) => InfLine p a -> Maybe (a -> a) Source

Get a function describing the line. We won't get a function if the line is vertical.

parallel :: (Num a, Num (p a), Point p, Eq a) => InfLine p a -> InfLine p a -> Bool Source

Check if two lines are paralllel to each other. This function assumes lines parallel to themselves.

slope :: (Fractional a, Point p, Eq a) => InfLine p a -> Maybe a Source

Calculate the slope of a line. We won't get a value for the slope if, and only if, the line is vertical.

root :: (Eq a, Fractional a, Point p) => InfLine p a -> Maybe a Source

Calculate the point where a line meets the x-axis. We won't get a value if, and only if the line is parallel to the x-axis.

intersection :: (Eq (p a), Num (p a), RealFloat a, Point p) => InfLine p a -> InfLine p a -> Maybe (p a) Source

Calculate the point where two lines intersect.

# Finite lines

data FinLine p a Source

Modells a finite line stretching between two points.

Instances

 Point p => Distance p (FinLine p) Source Translate p => Translate (FinLine p) Source Translate a `FinLine` by a fiven vector Point p => Distance (FinLine p) p Source Eq (p a) => Eq (FinLine p a) Source Two lines are equal if their end points are equal.`FinLine a b == FinLine b a` Read (p a) => Read (FinLine p a) Source Show (p a) => Show (FinLine p a) Source (Eq (p a), Arbitrary (p a)) => Arbitrary (FinLine p a) Source This `Arbitrary` instance should only produce valid `FinLine`s. AEq (p a) => AEq (FinLine p a) Source Two lines are almost equal if their ending points are almost equal. (Eq (p a), Point p, Num (p a), RealFloat a) => Intersect (FinLine p a) (InfLine p a) Source (Eq (p a), Point p, Num (p a), RealFloat a) => Intersect (FinLine p a) (FinLine p a) Source (Point p, RealFloat a, Ord a, Eq (p a)) => Intersect (FinLine p a) (Shape p a) Source (RealFloat a, Eq a, Eq (p a), Point p) => Intersect (FinLine p a) (Polygon p a) Source (Distance p (FinLine p), Floating a, Ord a) => Intersect (FinLine p a) (Circle p a) Source (Eq (p a), Point p, Num (p a), RealFloat a) => Intersect (InfLine p a) (FinLine p a) Source (Point p, RealFloat a, Ord a, Eq (p a)) => Intersect (Shape p a) (FinLine p a) Source (RealFloat a, Eq a, Eq (p a), Point p) => Intersect (Polygon p a) (FinLine p a) Source (Distance p (FinLine p), Floating a, Ord a) => Intersect (Circle p a) (FinLine p a) Source

mkFinLine :: Eq (p a) => p a -> p a -> Maybe (FinLine p a) Source

mkFinLine returns a valid finite line, if any.

lineLength :: (Point p, Num (p a), Floating a) => FinLine p a -> a Source

Get the length of a finite line.