rust/integral-geometry/src/lib.rs
changeset 16010 5ba4d3a0c3eb
parent 15850 44b49f255e31
equal deleted inserted replaced
16009:39ae4ed7de6e 16010:5ba4d3a0c3eb
    57         )
    57         )
    58     }
    58     }
    59 
    59 
    60     #[inline]
    60     #[inline]
    61     pub const fn rotate90(self) -> Self {
    61     pub const fn rotate90(self) -> Self {
    62         Point::new(self.y, -self.x)
    62         Self::new(self.y, -self.x)
    63     }
    63     }
    64 
    64 
    65     #[inline]
    65     #[inline]
    66     pub const fn cross(self, other: Point) -> i32 {
    66     pub const fn cross(self, other: Point) -> i32 {
    67         self.dot(other.rotate90())
    67         self.dot(other.rotate90())
    68     }
    68     }
    69 
    69 
    70     #[inline]
    70     #[inline]
    71     pub fn clamp(self, rect: &Rect) -> Point {
    71     pub fn clamp(self, rect: &Rect) -> Self {
    72         Point::new(rect.x_range().clamp(self.x), rect.y_range().clamp(self.y))
    72         Self::new(rect.x_range().clamp(self.x), rect.y_range().clamp(self.y))
    73     }
    73     }
    74 
    74 
    75     #[inline]
    75     #[inline]
    76     pub const fn line_to(self, end: Point) -> Line {
    76     pub const fn line_to(self, end: Point) -> Line {
    77         Line::new(self, end)
    77         Line::new(self, end)