예제 #1
0
        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));
        }
예제 #2
0
파일: WPos.cs 프로젝트: boyuezh/OpenRA
        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));
        }
예제 #3
0
파일: WPos.cs 프로젝트: xbayrockx/OpenRA
        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));
        }
예제 #4
0
파일: WVec.cs 프로젝트: RunCraze/OpenRA
        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);
        }
예제 #5
0
파일: WPos.cs 프로젝트: RunCraze/OpenRA
        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);
        }