Beispiel #1
0
        /// <summary>
        /// This function is used to ensure that a FPing point number is
        /// not a NaN or infinity.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <returns>
        ///     <c>true</c> if the specified x is valid; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsValid(FP x)
        {
            if (FP.IsNaN(x))
            {
                // NaN.
                return(false);
            }

            return(!FP.IsInfinity(x));
        }
Beispiel #2
0
        private FP GetPercent(FP distance, FP radius)
        {
            //(1-(distance/radius))^power-1
            // TODO - PORT
            // FP percent = (FP)Math.Pow(1 - ((distance - radius) / radius), Power) - 1;
            FP percent = (FP)Math.Pow((1 - ((distance - radius) / radius)).AsFloat(), Power.AsFloat()) - 1;

            if (FP.IsNaN(percent))
            {
                return(0f);
            }

            return(TSMath.Clamp(percent, 0f, 1f));
        }
Beispiel #3
0
        public void ApplyTorque(FP torque)
        {
            Debug.Assert(!FP.IsNaN(torque));
            bool flag = this._bodyType == BodyType.Dynamic;

            if (flag)
            {
                bool flag2 = !this.Awake;
                if (flag2)
                {
                    this.Awake = true;
                }
                this._torque += torque;
            }
        }
Beispiel #4
0
        private FP GetPercent(FP distance, FP radius)
        {
            FP   value = Math.Pow((double)(1 - (distance - radius) / radius).AsFloat(), (double)this.Power.AsFloat()) - 1;
            bool flag  = FP.IsNaN(value);
            FP   result;

            if (flag)
            {
                result = 0f;
            }
            else
            {
                result = MathHelper.Clamp(value, 0f, 1f);
            }
            return(result);
        }
Beispiel #5
0
        public void ApplyForce(ref TSVector2 force, ref TSVector2 point)
        {
            Debug.Assert(!FP.IsNaN(force.x));
            Debug.Assert(!FP.IsNaN(force.y));
            Debug.Assert(!FP.IsNaN(point.x));
            Debug.Assert(!FP.IsNaN(point.y));
            bool flag = this._bodyType == BodyType.Dynamic;

            if (flag)
            {
                bool flag2 = !this.Awake;
                if (flag2)
                {
                    this.Awake = true;
                }
                this._force  += force;
                this._torque += (point.x - this._sweep.C.x) * force.y - (point.y - this._sweep.C.y) * force.x;
            }
        }
Beispiel #6
0
        public static bool IsValid(FP x)
        {
            bool flag = FP.IsNaN(x);

            return(!flag && !FP.IsInfinity(x));
        }