Skip to content

Commit

Permalink
docs: more docs for 'Rotate' trait
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkirk committed Oct 18, 2021
1 parent b6d68e5 commit c538e8a
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions geo/src/algorithm/rotate.rs
Expand Up @@ -19,20 +19,6 @@ where
)
}

// Rotate a single point "angle" degrees about an origin. Origin can be an
// arbitrary point. Pass Point::new(0., 0.) for the actual origin.
fn rotate_one<T: CoordFloat>(angle: T, origin: Point<T>, point: Point<T>) -> Point<T> {
let (sin_theta, cos_theta) = angle.to_radians().sin_cos();
rotate_inner(
point.x(),
point.y(),
origin.x(),
origin.y(),
sin_theta,
cos_theta,
)
}

// Rotate an iterator of points "angle" degrees about an origin. Origin can be
// an arbitrary point. Pass Point::new(0., 0.) for the actual origin.
fn rotate_many<T>(
Expand All @@ -49,7 +35,7 @@ where
}

pub trait Rotate<T> {
/// Rotate a Geometry around its centroid by an angle, in degrees
/// Rotate a geometry around its [centroid](Centroid) by an angle, in degrees
///
/// Positive angles are counter-clockwise, and negative angles are clockwise rotations.
///
Expand Down Expand Up @@ -79,6 +65,22 @@ pub trait Rotate<T> {
///
/// assert_eq!(expected, rotated);
/// ```
fn rotate_around_centroid(&self, angle: T) -> Self
where
T: CoordFloat;

/// Rotate a geometry around the center of its [bounding box](BoundingRect) by an angle, in
/// degrees.
///
/// Positive angles are counter-clockwise, and negative angles are clockwise rotations.
///
/// # Units
///
/// - `angle`: degrees
fn rotate_around_center(&self, angle: T) -> Self
where
T: CoordFloat;

#[deprecated(
note = "Equivalent to `rotate_around_centroid` except for `Polygon<T>`,
where it is equivalent to rotating around the polygon's outer ring.
Expand All @@ -88,14 +90,6 @@ pub trait Rotate<T> {
fn rotate(&self, angle: T) -> Self
where
T: CoordFloat;

fn rotate_around_centroid(&self, angle: T) -> Self
where
T: CoordFloat;

fn rotate_around_center(&self, angle: T) -> Self
where
T: CoordFloat;
}

pub trait RotatePoint<T> {
Expand Down

0 comments on commit c538e8a

Please sign in to comment.