gloss-1.13.2.1: Painless 2D vector graphics, animations and simulations.
Safe HaskellNone
LanguageHaskell2010

Graphics.Gloss.Geometry.Line

Description

Geometric functions concerning lines and segments.

A Line is taken to be infinite in length, while a Seg is finite length line segment represented by its two endpoints.

Synopsis

Documentation

segClearsBox Source #

Arguments

:: Point

P1 First point of segment.

-> Point

P2 Second point of segment.

-> Point

P3 Lower left point of box.

-> Point

P4 Upper right point of box.

-> Bool 

Check if line segment (P1-P2) clears a box (P3-P4) by being well outside it.

Closest points

closestPointOnLine Source #

Arguments

:: Point

P1

-> Point

P2

-> Point

P3

-> Point

the point on the line P1-P2 that is closest to P3

Given an infinite line which intersects P1 and P1, return the point on that line that is closest to P3

closestPointOnLineParam Source #

Arguments

:: Point

P1

-> Point

P2

-> Point

P3

-> Float 

Given an infinite line which intersects P1 and P2, let P4 be the point on the line that is closest to P3.

Return an indication of where on the line P4 is relative to P1 and P2.

     if P4 == P1 then 0
     if P4 == P2 then 1
     if P4 is halfway between P1 and P2 then 0.5
       |
      P1
       |
    P4 +---- P3
       |
      P2
       |

Line-Line intersection

intersectLineLine Source #

Arguments

:: Point

P1

-> Point

P2

-> Point

P3

-> Point

P4

-> Maybe Point 

Given four points specifying two lines, get the point where the two lines cross, if any. Note that the lines extend off to infinity, so the intersection point might not line between either of the two pairs of points.

    \      /
     P1  P4
      \ /
       +
      / \
     P3  P2
    /     \

Seg-Line intersection

intersectSegLine Source #

Arguments

:: Point

P1

-> Point

P2

-> Point

P3

-> Point

P4

-> Maybe Point 

Get the point where a segment P1-P2 crosses an infinite line P3-P4, if any.

intersectSegHorzLine Source #

Arguments

:: Point

P1 First point of segment.

-> Point

P2 Second point of segment.

-> Float

y value of line.

-> Maybe Point 

Get the point where a segment crosses a horizontal line, if any.

               + P1
              /
      -------+---------
            /        y0
        P2 +

intersectSegVertLine Source #

Arguments

:: Point

P1 First point of segment.

-> Point

P2 Second point of segment.

-> Float

x value of line.

-> Maybe Point 

Get the point where a segment crosses a vertical line, if any.

             |
             |   + P1
             | /
             +
           / |
      P2 +   |
             | x0

Seg-Seg intersection

intersectSegSeg Source #

Arguments

:: Point

P1

-> Point

P2

-> Point

P3

-> Point

P4

-> Maybe Point 

Get the point where a segment P1-P2 crosses another segement P3-P4, if any.

intersectSegHorzSeg Source #

Arguments

:: Point

P1 First point of segment.

-> Point

P2 Second point of segment.

-> Float

(y3) y value of horizontal segment.

-> Float

(xa) Leftmost x value of horizontal segment.

-> Float

(xb) Rightmost x value of horizontal segment.

-> Maybe Point

(x3, y3) Intersection point, if any.

Check if an arbitrary segment intersects a horizontal segment.

                + P2
               /
(xa, y3)  +---+----+ (xb, y3)
             /
         P1 +

intersectSegVertSeg Source #

Arguments

:: Point

P1 First point of segment.

-> Point

P2 Second point of segment.

-> Float

(x3) x value of vertical segment

-> Float

(ya) Lowest y value of vertical segment.

-> Float

(yb) Highest y value of vertical segment.

-> Maybe Point

(x3, y3) Intersection point, if any.

Check if an arbitrary segment intersects a vertical segment.

     (x3, yb) +
              |   + P1
              | /
              +
            / |
       P2 +   |
              + (x3, ya)