Skip to content

Instantly share code, notes, and snippets.

View thebeardphantom's full-sized avatar

Mika Notarnicola thebeardphantom

View GitHub Profile
@thebeardphantom
thebeardphantom / Normalizer.cs
Last active August 29, 2015 14:11
Ever need to normalize an angle of 1748 or -191857 degrees to 0...360 or -180...180? Now you can!
namespace BSGTools.Math {
public static class Normalizer {
public static float NormalizeAngle(float value) {
return Normalize(value, 0f, 360f);
}
public static float Normalize(float value, float start, float end) {
float width = end - start;
float offsetValue = value - start; // value relative to 0