private static MyVector2 GetLerpedMidpoint(MyVector2 v1, float weight1, MyVector2 v2, float weight2)
        {
            float weight = (1f - weight1) / (weight2 - weight1);

            //MyVector2 interpolatedPos =  v1 + (v2 - v1) * weight;

            MyVector2 interpolatedPos = BezierLinear.GetPosition(v1, v2, weight);

            //float interX = _Interpolation.Sinerp(v1.x, v2.x, weight);
            //float interY = _Interpolation.Sinerp(v1.y, v2.y, weight);

            //MyVector2 interpolatedPos = new MyVector2(interX, interY);

            return(interpolatedPos);
        }
Esempio n. 2
0
        //
        // Alternative 1.5. Similar to Alternative 1, but we know the up vector at both the start and end position
        //

        public static InterpolationTransform GetTransform_InterpolateBetweenUpVectors(
            _Curve curve, float t, Vector3 upRefStart, Vector3 upRefEnd)
        {
            //Position on the curve at point t
            Vector3 pos = curve.GetPosition(t);

            //Forward direction (tangent) on the curve at point t
            Vector3 forwardDir = curve.GetTangent(t);

            //Interpolate between the start and end up vector to get an up vector at a t position
            Vector3 interpolatedUpDir = Vector3.Normalize(BezierLinear.GetPosition(upRefStart, upRefEnd, t));

            MyQuaternion orientation = InterpolationTransform.GetOrientation_UpRef(forwardDir, interpolatedUpDir);

            InterpolationTransform trans = new InterpolationTransform(pos, orientation);

            return(trans);
        }