// -*- coding: utf-8 -*- // // Copyright 2021 Michael Büsch // // Licensed under the Apache License version 2.0 // or the MIT license, at your option. // SPDX-License-Identifier: Apache-2.0 OR MIT // use std::f32::consts::PI; use std::ops::{Add, Div, Shr}; #[inline] pub fn radians(deg: f32) -> f32 { (deg * PI) / 180.0 } #[inline] pub fn degrees(rad: f32) -> f32 { (rad * 180.0) / PI } #[allow(unused)] #[inline] pub fn div_round(a: T, b: T) -> T where T: Add + Div + Shr + Copy, { (a + (b >> 1)) / b } // vim: ts=4 sw=4 expandtab