public static WVec LerpQuadratic(WVec a, WVec b, WAngle pitch, int mul, int div) { // Start with a linear lerp between the points var ret = Lerp(a, b, mul, div); if (pitch.Angle == 0) { return(ret); } // Add an additional quadratic variation to height // Uses decimal to avoid integer overflow var offset = (int)((decimal)(b - a).Length * pitch.Tan() * mul * (div - mul) / (1024 * div * div)); return(new WVec(ret.X, ret.Y, ret.Z + offset)); }
public static WPos LerpQuadratic(WPos a, WPos b, WAngle pitch, int mul, int div) { // Start with a linear lerp between the points var ret = Lerp(a, b, mul, div); if (pitch.Angle == 0) { return(ret); } // Add an additional quadratic variation to height // Uses decimal to avoid integer overflow var offset = (decimal)(b - a).Length * pitch.Tan() * mul * (div - mul) / (1024 * div * div); var clampedOffset = (int)(offset + (decimal)ret.Z).Clamp <decimal>((decimal)int.MinValue, (decimal)int.MaxValue); return(new WPos(ret.X, ret.Y, clampedOffset)); }
public static WPos LerpQuadratic(WPos a, WPos b, WAngle pitch, int mul, int div) { // Start with a linear lerp between the points var ret = Lerp(a, b, mul, div); if (pitch.Angle == 0) { return(ret); } // Add an additional quadratic variation to height // Attempts to avoid integer overflow by keeping the intermediate variables reasonably sized var offset = (int)(((((((long)(b - a).Length * mul) / div) * (div - mul)) / div) * pitch.Tan()) / 1024); return(new WPos(ret.X, ret.Y, ret.Z + offset)); }
public static WVec LerpQuadratic(WVec a, WVec b, WAngle pitch, int mul, int div) { // Start with a linear lerp between the points var ret = Lerp(a, b, mul, div); if (pitch.Angle == 0) return ret; // Add an additional quadratic variation to height // Uses fp to avoid integer overflow var offset = (int)((float)((float)(b - a).Length*pitch.Tan()*mul*(div - mul)) / (float)(1024*div*div)); return new WVec(ret.X, ret.Y, ret.Z + offset); }
public static WPos LerpQuadratic(WPos a, WPos b, WAngle pitch, int mul, int div) { // Start with a linear lerp between the points var ret = Lerp(a, b, mul, div); if (pitch.Angle == 0) return ret; // Add an additional quadratic variation to height // Attempts to avoid integer overflow by keeping the intermediate variables reasonably sized var offset = (int)(((((((long)(b - a).Length * mul) / div) * (div - mul)) / div) * pitch.Tan()) / 1024); return new WPos(ret.X, ret.Y, ret.Z + offset); }