rust/integral-geometry/src/lib.rs
changeset 14127 5c1ce63114a5
parent 14117 133f648c5fbd
child 14128 6a3bcb7c2981
equal deleted inserted replaced
14126:7e25f4800af8 14127:5c1ce63114a5
    55     pub fn transform(self, matrix: &[i32; 4]) -> Self {
    55     pub fn transform(self, matrix: &[i32; 4]) -> Self {
    56         Point::new(
    56         Point::new(
    57             matrix[0] * self.x + matrix[1] * self.y,
    57             matrix[0] * self.x + matrix[1] * self.y,
    58             matrix[2] * self.x + matrix[3] * self.y,
    58             matrix[2] * self.x + matrix[3] * self.y,
    59         )
    59         )
       
    60     }
       
    61 
       
    62     #[inline]
       
    63     pub fn rotate90(self) -> Self {
       
    64         Point::new(-self.y, self.x)
    60     }
    65     }
    61 }
    66 }
    62 
    67 
    63 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
    68 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
    64 pub struct Size {
    69 pub struct Size {
   413     }
   418     }
   414 
   419 
   415     #[inline]
   420     #[inline]
   416     pub fn center(&self) -> Point {
   421     pub fn center(&self) -> Point {
   417         (self.start + self.end) / 2
   422         (self.start + self.end) / 2
       
   423     }
       
   424 
       
   425     #[inline]
       
   426     pub fn scaled_normal(&self) -> Point {
       
   427         (self.end - self.start).rotate90()
   418     }
   428     }
   419 }
   429 }
   420 
   430 
   421 impl IntoIterator for Line {
   431 impl IntoIterator for Line {
   422     type Item = Point;
   432     type Item = Point;