pub trait Rotate<DegreesT> {
    // Required methods
    fn rotate_around_centroid(&self, degrees: &DegreesT) -> Self;
    fn rotate_around_center(&self, degrees: &DegreesT) -> Self;
    fn rotate_around_point(&self, degrees: &DegreesT, point: Point) -> Self;
}
Expand description

Rotate geometries around a point by an angle, in degrees.

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

Performance

If you will be performing multiple transformations, like Scale, Skew, Translate, or Rotate, it is more efficient to compose the transformations and apply them as a single operation using the AffineOps trait.

Required Methods§

source

fn rotate_around_centroid(&self, degrees: &DegreesT) -> Self

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

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

Examples
use geo::Rotate;
use geo::line_string;
use approx::assert_relative_eq;

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.071067811865475, y: 5.0),
    (x: 5.0, y: 5.0),
    (x: 12.071067811865476, y: 5.0),
];

assert_relative_eq!(expected, rotated);
source

fn rotate_around_center(&self, degrees: &DegreesT) -> Self

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.

source

fn rotate_around_point(&self, degrees: &DegreesT, point: Point) -> Self

Rotate a Geometry around an arbitrary point by an angle, given in degrees

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

Examples
use geo::Rotate;
use geo::{line_string, point};

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

let rotated = ls.rotate_around_point(
    -45.0,
    point!(x: 10.0, y: 0.0),
);

assert_eq!(rotated, line_string![
    (x: 2.9289321881345245, y: 7.071067811865475),
    (x: 10.0, y: 7.0710678118654755),
    (x: 17.071067811865476, y: 7.0710678118654755)
]);

Object Safety§

This trait is not object safe.

Implementors§