logo
pub trait Rotate<T> {
    fn rotate_around_centroid(&self, angle: T) -> Self
    where
        T: CoordFloat
; fn rotate_around_center(&self, angle: T) -> Self
    where
        T: CoordFloat
; fn rotate(&self, angle: T) -> Self
    where
        T: CoordFloat
; }

Required Methods

Rotate a geometry around its centroid by an angle, in degrees

Positive angles are counter-clockwise, and negative angles are clockwise rotations.

Units
  • angle: degrees
Examples
use geo::Rotate;
use geo::line_string;

let line_string = line_string![
    (x: 0.0, y: 0.0),
    (x: 5.0, y: 5.0),
    (x: 10.0, y: 10.0),
];

let rotated = line_string.rotate_around_centroid(-45.0);

let expected = line_string![
    (x: -2.0710678118654755, y: 5.0),
    (x: 5.0, y: 5.0),
    (x: 12.071067811865476, y: 5.0),
];

assert_eq!(expected, rotated);

Rotate a geometry around the center of its bounding box by an angle, in degrees.

Positive angles are counter-clockwise, and negative angles are clockwise rotations.

Units
  • angle: degrees
👎 Deprecated:

Equivalent to rotate_around_centroid except for Polygon<T>, where it is equivalent to rotating around the polygon’s outer ring. Call that instead, or rotate_around_center if you’d like to rotate around the geometry’s bounding box center.

Implementors