// Copyright 2016 The G3N Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package math32 implements basic math functions which operate // directly on float32 numbers without casting and contains // types of common entities used in 3D Graphics such as vectors, // matrices, quaternions and others. package math32 import ( "math" ) const Pi = math.Pi const degreeToRadiansFactor = math.Pi / 180 const radianToDegreesFactor = 180.0 / math.Pi var Infinity = float32(math.Inf(1)) func DegToRad(degrees float32) float32 { return degrees * degreeToRadiansFactor } func RadToDeg(radians float32) float32 { return radians * radianToDegreesFactor } func Clamp(x, a, b float32) float32 { // Clamp value to range if x < a { return a } if x > b { return b } return x } func ClampInt(x, a, b int) int { if x < a { return a } if x > b { return b } return x } func ClampBotton(x, a float32) float32 { // Clamp value to range