SCNVector3
and more.# Swift 4.0
github "DJBen/MathUtil" ~> 0.3.0
This version is compatible with Swift 4. To use Swift 3.x compatible version, use 0.1.x
instead.
# Swift 3.x
github "DJBen/MathUtil" ~> 0.1.0
RadianAngle(degreeAngle: DegreeAngle(30)).value // 0.523...
DegreeAngle(radianAngle: RadianAngle(Double.Pi / 2)).value // 90
// Sirius' right ascension is 6h 45m 9s
let deg = DegreeAngle(hour: 6, minute: 45, second: 9)
deg.value // 101.2875
let hourAngle = HourAngle(value: deg)
// Use any custom number formatters for different decimal lengths
hourAngle.compoundDecimalNumberFormatter = NumberFormatter()
print(hourAngle.compoundDescription) // 6h 45m 9s
// Antares' right ascension is −26.432002 degrees
let degreeAngle = DegreeAngle(-26.432002)
print(degreeAngle.compoundDescription) // -26° 25′ 55″
See documentation for VectorMath.
// Starts at 2.1; ends at 7.5; wants to know 85% value.
let interp = Easing(startValue: 2.1, endValue: 7.5)
interp.value(at: 0.85) // 6.69
The following easing functions are available and here is their mathematic definitions.
public enum EasingFunction {
case linear
case quadraticEaseIn
case quadraticEaseOut
case quadraticEaseInOut
case cubicEaseIn
case cubicEaseOut
case cubicEaseInOut
}
Just pass in the function when initializing Easing
and take advantage of it!
Easing(easingMethod: .cubicEaseInOut, startValue: 21, endValue: -9)
CGVector
and SCNVector3
.MathUtil/VectorMath**
are based on
@nicklockwood's VectorMath. Great thanks!