[][src]Function nannou::geom::line::join::intersections

pub fn intersections<S>(
    a: Point2<S>,
    b: Point2<S>,
    c: Point2<S>,
    half_thickness: S
) -> Option<(Point2<S>, Point2<S>)> where
    S: BaseFloat

Given three points that describe two lines and half the thickness of the line, return the two points that intersect on either side of the line.

The following diagram describes the expected arguments as well as the left L and right R fields of the tuple result.

This example is not tested
   -------------------------------    L       ^
                                              | half_thickness
 a -------------------------------  b         v
                                        \
   ------------------------------R   \   \
                                  \   \   \
           Line 1                  \   \   \
                                    \   \   \
                           Line 2    \   \   \
                                      \   \   \

                                           c

Example



use nannou::prelude::*;
use nannou::geom::line;

fn main() {
    // Find `L` and `R`.
    //
    //         |  c  |  ^
    //         |  |  |  |
    //         |  |  |  | 2.0
    // --------L  |  |  |
    //            |  |  |
    // a----------b  |  v
    //               |
    // --------------R
    //
    // <---------->
    //     2.0

    let a = pt2(0.0, 0.0);
    let b = pt2(2.0, 0.0);
    let c = pt2(2.0, 2.0);
    let half_thickness = 1.0;
    let result = line::join::intersections(a, b, c, half_thickness);
    assert_eq!(Some((pt2(1.0, 1.0), pt2(3.0, -1.0))), result);
}