Skip to content

Add clamp and wraparound methods #487

Open
@faulesocke

Description

@faulesocke

These methods are quite useful whenever you have to make sure that a value stays inside a specified range. Although there is f32::clamp and f64::clamp these are not stabilized yet so it would be nice to have them inside cgmath.

wraparound should have a signature like this:

fn wraparound<S>(x: S, min: S, max: S) -> S

See also https://stackoverflow.com/questions/4633177/c-how-to-wrap-a-float-to-the-interval-pi-pi#

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions