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 Segment<S: Scalar> { pub s: Point<S>, pub e: Point<S>, } impl<S: Scalar> Segment<S> { pub fn new(s: Point<S>, e: Point<S>) -> Self { Segment { s, e } } pub fn from_segment(l: Segment<S>) -> Self { Segment { s: l.s, e: l.e } } pub fn translate_x(&mut self, dx: S) { self.s.translate_x(dx); self.e.translate_x(dx); } pub fn translate_y(&mut self, dy: S) { self.s.translate_y(dy); self.e.translate_y(dy); } }