ring360-0.1.0 has been yanked.
Ring360: Modular Arithmetic around a 360º circle
This crate provides a simple wrapper struct for 64-bit floats representing degrees around a circle. The type lets you perform basic arithmetic operations with +, -, * and / and calculate the shortest distances between two degrees on a circle.
/// Add and.or subtract degrees on a circle
/// The degree value represents the longitude, while the intrinsic f64 value
/// represents the distance travelled around the circumference
let longitude_1 = Ring360;
let longitude_2 = Ring360;
let longitude_3 = Ring360;
let result_1 = longitude_1 + longitude_2 + longitude_3;
println!;
let result_2 = longitude_1 - longitude_2 + longitude_3;
println!;
64-bit float values can be easily coverted to and from Ring360 values
let value_1 = 74.7;
let longitude_1 = value_1.to_360;
let longitude_2 = 291.4.to_360;
let result_1_f64 = .to_f64;
println!;
Multiplication and divsion are implemented for degrees as Ring360 values, but in practice multiplying by float values is more useful
let value_1 = 74.7;
let multiple = 4.0;
let result_1 = value_1.to_360 * multiple.to_360;
let result_2 = value_1.to_360.multiply;
println!;
println!;
The distance() and distance_f64() methods calculate the shortest distance in degrees between two longitudes in a circle.
let longitude_1 = 297.4.to_360;
let value_2: f64 = 36.2;
let longitude_2 = value_2.to_360;
let result_1 = value_1.distance;
let result_2 = value_1.distance_f64;
println!;
Dev Notes
This is crate is in its alpha stage. it's a proof of concept only.