This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if UNITY_EDITOR | |
using System; | |
using System.Collections.Generic; | |
using System.Globalization; | |
using System.Text; | |
using UnityEditor; | |
using UnityEditor.Compilation; | |
using UnityEngine; | |
/// <summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// deconstruct our rotation into angle/axis formation. | |
float rotationAngle; | |
Vector3 rotationAxis; | |
transform.rotation.ToAngleAxis(out rotationAngle, out rotationAxis); | |
// construct a new rotation from axis and angle. | |
// Qv,θ = |v * sin(θ/2), cos(θ/2)|, where v = axis, θ = angle in radians. | |
float sinThetaOver2 = Mathf.Sin((rotationAngle * Mathf.Deg2Rad) / 2f); | |
float cosThetaOver2 = Mathf.Cos((rotationAngle * Mathf.Deg2Rad) / 2f); | |
Quaternion newRotation = new Quaternion( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
/// <summary>A Kalman filter implementation for <c>float</c> values.</summary> | |
public class KalmanFilterFloat { | |
//----------------------------------------------------------------------------------------- | |
// Constants: | |
//----------------------------------------------------------------------------------------- | |
public const float DEFAULT_Q = 0.000001f; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class QuaternionExtensions { | |
//----------------------------------------------------------------------------------------- | |
// Public Methods: | |
//----------------------------------------------------------------------------------------- | |
/// <summary>Returns a <c>Quaternion</c> with the same orientation but with a magnitude of 1.</summary> | |
public static Quaternion Normalise(this Quaternion self) { | |
// work out the magnitude, and if it's too small, return identity. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public static class QuaternionExtensions { | |
//----------------------------------------------------------------------------------------- | |
// Public Methods: | |
//----------------------------------------------------------------------------------------- | |
/// <summary>Returns a <c>Vector3</c> angular velocity representation of this <c>Quaternion</c>.</summary> | |
public static Vector3 ToAngularVelocity(this Quaternion self) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text.RegularExpressions; | |
using UnityEngine; | |
#if UNITY_EDITOR | |
using UnityEditor; | |
[InitializeOnLoad] | |
#endif |