GithubHelp home page GithubHelp logo

angulus's Introduction

angulus

github crates.io docs.rs

Unit agnostic angle.

What problem does it solve ?

Using simple floating point numbers to store an angle value is error-prone : you may add two angle with one in radians and the second in degrees or you may try to compute the cosine of a value in degrees and get an unexpected result.

angulus provides a type that represent an angle with no specific unit.

Example

use angulus::prelude::*;

// Create an angle of 90°.
let alpha = 90.0_f32.deg();

// Create an angle of π/4 rad (45°).
let beta = Angle::RAD_FRAC_PI_4;

// Add the two angle without worrying about units.
let gamma = alpha + beta;

// Print the result.
println!(
    "The cosine of {} is {}",
    Degrees(gamma), // The angle is wrapped to display the value in degrees.
    gamma.cos()     // Compute the cosine without worrying about units.
);

// Output : The cosine of 135° is -0.70710677

Features

  • std: by default angulus links to the standard library. Disable this feature to remove this dependency and be able to use angulus in #![no_std] crates.
  • libm: use the libm crate for the math methods (sin, cos, tan) when std is disabled.
  • serde: enable serialization and deserialization with the serde crate.
  • rand: enable generation of random angle with the rand crate.

Minimum Supported Rust Version

This crate requires Rust 1.61.0 or later.

License

Licensed under either of the following, at your choice:

Unless explicitly stated otherwise, any contribution intentionally submitted for inclusion in this crate, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.