1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use super::*;

impl<T> Line<T> {
    /// Create a new line from two point
    #[inline(always)]
    pub fn new<P>(start: P, end: P) -> Self
    where
        Point<T>: From<P>,
    {
        Self { s: start.into(), e: end.into() }
    }
    /// Create a new line from anchor point and vector
    pub fn from_anchor<S, V>(start: S, v: V) -> Self
    where
        T: Clone + Add<Output = T>,
        S: Into<Point<T>>,
        V: Into<Vector<T>>,
    {
        let s = start.into();
        let Vector { dx: vx, dy: vy } = v.into();
        let e = Point { x: s.x.clone() + vx, y: s.y.clone() + vy };
        Self { s, e }
    }
}