Instantly share code, notes, and snippets.

# Vegard Myklebustusefulslug

• Sort options
Created Sep 11, 2015
View QuaternionExtensions.boo
 // Quaternion extensions for Unity by Vegard Myklebust. // Made available under Creative Commons license CC0. License details can be found here: // https://creativecommons.org/publicdomain/zero/1.0/legalcode.txt [Extension] public def Log(ref a as Quaternion): a0 as single = a.w a.w = 0.0 if(Mathf.Abs(a0) < 1.0): angle as single = Mathf.Acos(a0) sinAngle as single = Mathf.Sin(angle)
Created Sep 11, 2015
 // Returns a smoothed quaternion along the set of quaternions making up the spline, each quaternion is along an equidistant value in t def Spline(quaternions as (Quaternion), t as single): section as int = (quaternions.Length-1) * t alongLine as single = (quaternions.Length-1) * t - section if section == 0: return SplineSegment(quaternions[section], quaternions[section], quaternions[section+1], quaternions[section+2], alongLine) elif section == quaternions.Length - 2 and section > 0: return SplineSegment(quaternions[section-1], quaternions[section], quaternions[section+1], quaternions[section+1], alongLine) elif section >= 1 and section < quaternions.Length - 2: return SplineSegment(quaternions[section-1], quaternions[section], quaternions[section+1], quaternions[section+2], alongLine)
Last active Sep 11, 2015