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

#[derive(Debug, Clone, Copy)]
pub struct Line<S: Scalar> {
  pub s: Point<S>,
  pub t: Point<S>,
}

impl<S: Scalar> Line<S> {
  pub fn new(s: Point<S>, t: Point<S>) -> Self {
    Line { s, t }
  }
  pub fn from_line(l: Line<S>) -> Self {
    Line { s: l.s, t: l.t }
  }
  pub fn translate_x(&mut self, dx: S) {
    self.s.translate_x(dx);
    self.t.translate_x(dx);
  }
  pub fn translate_y(&mut self, dy: S) {
    self.s.translate_y(dy);
    self.t.translate_y(dy);
  }
}