Vector3D.Lerp C# (CSharp) Method

Lerp() public static method

public static Lerp ( Vector3D, from, Vector3D, to, double t ) : Vector3D,
from Vector3D,
to Vector3D,
t double
return Vector3D,
    public static Vector3D Lerp(Vector3D from, Vector3D to, double t)
    {
        t = Clamp01 (t);
        return new Vector3D (from.x + (to.x - from.x) * t, from.y + (to.y - from.y) * t, from.z + (to.z - from.z) * t);
    }

Usage Example

Esempio n. 1
0
        public CurveSample Sample(double f)
        {
            if (f <= 0)
            {
                return(new CurveSample(new Vector3D(positions[0]), tangent(0)));
            }

            int N = arc_len.Length;

            if (f >= arc_len[N - 1])
            {
                return(new CurveSample(new Vector3D(positions[N - 1]), tangent(N - 1)));
            }

            for (int k = 0; k < N; ++k)
            {
                if (f < arc_len[k])
                {
                    int a = k - 1;
                    int b = k;
                    if (arc_len[a] == arc_len[b])
                    {
                        return(new CurveSample(new Vector3D(positions[a]), tangent(a)));
                    }
                    double t = (f - arc_len[a]) / (arc_len[b] - arc_len[a]);
                    return(new CurveSample(
                               Vector3D.Lerp(positions[a], positions[b], t),
                               Vector3D.Lerp(tangent(a), tangent(b), t)));
                }
            }

            throw new ArgumentException("SampledArcLengthParam.Sample: somehow arc len is outside any possible range");
        }
All Usage Examples Of Vector3D::Lerp