devNotes 12-10-2016 Flight continued

sgngngngn


public static Vector3 operator *(Quaternion quat, Vector3 vec){
     float num = quat.x * 2f;
     float num2 = quat.y * 2f;
     float num3 = quat.z * 2f;
     float num4 = quat.x * num;
     float num5 = quat.y * num2;
     float num6 = quat.z * num3;
     float num7 = quat.x * num2;
     float num8 = quat.x * num3;
     float num9 = quat.y * num3;
     float num10 = quat.w * num;
     float num11 = quat.w * num2;
     float num12 = quat.w * num3;
     Vector3 result;
     result.x = (1f - (num5 + num6)) * vec.x + (num7 - num12) * vec.y + (num8 + num11) * vec.z;
     result.y = (num7 + num12) * vec.x + (1f - (num4 + num6)) * vec.y + (num9 - num10) * vec.z;
     result.z = (num8 - num11) * vec.x + (num9 + num10) * vec.y + (1f - (num4 + num5)) * vec.z;
     return result;
 }

 

 

using UnityEngine;
using System.Collections;

public class Glass_Stabilizer : MonoBehaviour
{
    public Fine_Tune_Controller_Adjuster ctrl;
    public Quaternion slerpedRotation = Quaternion.identity;
    public SteamVR_PlayArea steamVR_PlayArea;

    void OnEnable ()
    {
        ctrl = GetComponentInParent<Fine_Tune_Controller_Adjuster>();
	}
	
	// Update is called once per frame
	void Update ()
    {
        Vector3 v = ctrl.transform.forward;
        v.y = 0;

        v.Normalize();
     
        Quaternion q = Quaternion.LookRotation(ctrl.transform.forward, ctrl.transform.up);

        slerpedRotation = Quaternion.Slerp(slerpedRotation, q, 0.01f);
        transform.rotation = slerpedRotation;
    }
}

 

seagull-1081948_960_720

 

seagull