Exemple #1
0
    /// <summary>
    /// Makes vectors normalized and orthognal to each other.
    /// </summary>
    /// <param name="normal">Vector to normalize</param>
    /// <param name="tangent">Tangent to make orthogonal to normal</param>
    public static void OrthoNormalize(ref Vector3 normal, ref DebugVector3 tangent)
    {
        DebugVector3 n = (DebugVector3)normal;

        OrthoNormalize(ref n, ref tangent);
        normal = n.v3;
    }
Exemple #2
0
    /// <summary>
    /// Makes vectors normalized and orthognal to each other.
    /// </summary>
    /// <param name="normal">Vector to normalize</param>
    /// <param name="tangent">Tangent to make orthogonal to normal</param>
    public static void OrthoNormalize(ref DebugVector3 normal, ref Vector3 tangent)
    {
        DebugVector3 t = (DebugVector3)tangent;

        OrthoNormalize(ref normal, ref t);
        tangent = t.v3;
    }
Exemple #3
0
 /// <summary>
 /// Makes vectors normalized and orthognal to each other.
 /// </summary>
 /// <param name="normal">Vector to normalize</param>
 /// <param name="tangent">Tangent to make orthogonal to normal</param>
 public static void OrthoNormalize(ref DebugVector3 normal, ref DebugVector3 tangent)
 {
     DrawVector(origin, origin + normal, DrawVectorColorA, DrawPermanentChangeTime);
     DrawVector(origin, origin + tangent, DrawVectorColorB, DrawPermanentChangeTime);
     Vector3.OrthoNormalize(ref normal.v3, ref tangent.v3);
     DrawVector(origin, origin + normal, DrawResultColor, DrawPermanentChangeTime);
     DrawVector(origin, origin + tangent, DrawResultColor, DrawPermanentChangeTime);
 }
    // Update is called once per frame
    void Update()
    {
        DebugVector3.ShowOperatorResult = ShowOperatorResult;
        DebugVector3.ShowOperatorInputs = ShowOperatorInputs;
        DebugVector3.ShowMethodInputs   = ShowMethodInputs;
        DebugVector3.ShowMethodResult   = ShowMethodResult;
        DebugVector3.origin             = transform.position;
        Vector3      t      = Vector3.one;
        DebugVector3 result = DebugVector3.zero;
        float        f      = 0.0f;

        if (DoDebugAdd)
        {
            result = vector1 + vector2;
        }

        if (DoDebugMinus)
        {
            result = vector1 - vector2;
        }

        if (DoDebugMultiply)
        {
            result = vector1 * MultiplierDivider;
        }

        if (DoDebugDivide)
        {
            result = vector1 / MultiplierDivider;
        }

        if (DoAngle)
        {
            f = DebugVector3.Angle(vector1, vector2);
        }

        if (DoClampMagnitude)
        {
            result = DebugVector3.ClampMagnitude(vector1, MaxMagnitude);
        }

        if (DoDebugCross)
        {
            result = DebugVector3.Cross(vector1, vector2);
        }

        if (DoDebugDistance)
        {
            f = DebugVector3.Distance(vector1, vector2);
        }

        if (DoDebugDot)
        {
            f = DebugVector3.Dot(vector1, vector2);
        }

        if (DoDebugLerp)
        {
            result = DebugVector3.Lerp(vector1, vector2, Lerp);
        }

        if (DoDebugLerpUnclamped)
        {
            result = DebugVector3.LerpUnclamped(vector1, vector2, Lerp);
        }

        if (DoDebugMax)
        {
            result = DebugVector3.Max(vector1, vector2);
        }

        if (DoDebugMin)
        {
            result = DebugVector3.Min(vector1, vector2);
        }

        if (DoDebugMoveTowards)
        {
            result = DebugVector3.MoveTowards(vector1, vector2, MoveTowardsDistance);
        }

        if (DoDebugStaticNormalize)
        {
            result = DebugVector3.Normalize(vector1);
        }

        if (DoDebugInstNormalize)
        {
            vector1.Normalize();
            DoDebugInstNormalize = false;
        }

        if (DoOrthoNormalize)
        {
            DebugVector3.OrthoNormalize(ref vector1, ref vector2);
            DoOrthoNormalize = false;
        }

        if (DoDebugProject)
        {
            result = DebugVector3.Project(vector1, vector2);
        }

        if (DoDebugProjectOnPlane)
        {
            result = (DebugVector3)DebugVector3.ProjectOnPlane(vector1, PlaneNormal);
        }

        if (DoDebugReflect)
        {
            result = DebugVector3.Reflect(vector1, PlaneNormal);
        }

        if (DoDebugRotateTowards)
        {
            result = DebugVector3.RotateTowards(vector1, vector2, MaxRotateDelta, MaxMagnitudeDelta);
        }

        if (DoDebugScale)
        {
            result = DebugVector3.Scale(vector1, vector2);
        }

        if (DoDebugSignedAngle)
        {
            f = DebugVector3.SignedAngle(vector1, vector2, signedAngleAxis);
        }

        if (DoDebugSlerp)
        {
            result = DebugVector3.Slerp(vector1, vector2, Slerp);
        }

        if (DoDebugSlerpUnclamped)
        {
            result = DebugVector3.SlerpUnclamped(vector1, vector2, Slerp);
        }

        if (DoDebugSmoothDamp)
        {
            result = DebugVector3.SmoothDamp(vector1, vector2, ref SmoothDampVel, SmoothDampTime);
        }

        // ignore errors with not using result and f.
        if (result != Vector3.zero)
        {
        }
        if (f > 0)
        {
        }
    }
Exemple #5
0
 /// <summary>
 /// Gradually changes a vector towards a desired goal over time. The vector is smoothed by some spring-damper function which will never overshoot.
 /// </summary>
 /// <param name="current">Current position</param>
 /// <param name="target">Target position</param>
 /// <param name="currentVelocity">Current velocity, value is modified by the function every time you call it</param>
 /// <param name="smoothTime">Approximately the time it will take to reach the target, smaller reaches target faster</param>
 /// <param name="maxSpeed">Optionally allows you to clamp maximum speed</param>
 /// <returns>Next smoothed position from current position to target</returns>
 public static DebugVector3 SmoothDamp(Vector3 current, Vector3 target,
                                       ref DebugVector3 currentVelocity, float smoothTime, float maxSpeed = Mathf.Infinity)
 {
     return(SmoothDamp(current, target, ref currentVelocity.v3, smoothTime, maxSpeed, Time.deltaTime));
 }