Vector3D.Clamp C# (CSharp) Метод

Clamp() статический приватный Метод

static private Clamp ( double value, double min, double max ) : double
value double
min double
max double
Результат double
    static double Clamp(double value, double min, double max)
    {
        return (value < min) ? min : (value > max) ? max : value;
    }

Usage Example

Пример #1
0
        private static bool FindClosestPointOnFracturedTree(Vector3D fromPositionFractureLocal, MyFracturedPiece fracture, out Vector3D closestPoint)
        {
            // Marko: HACK: skip stumps
            closestPoint = default(Vector3D);
            if (fracture == null)
            {
                return(false);
            }

            Vector4 minFour, maxFour;

            fracture.Shape.GetShape().GetLocalAABB(0, out minFour, out maxFour);
            var min = new Vector3D(minFour);
            var max = new Vector3D(maxFour);

            closestPoint = Vector3D.Clamp(fromPositionFractureLocal, min, max);

            closestPoint.X = (closestPoint.X + 2 * (max.X + min.X) / 2) / 3;
            closestPoint.Y = MathHelper.Clamp(closestPoint.Y + 0.25f * (closestPoint.Y - min.Y < max.Y - closestPoint.Y ? 1 : -1), min.Y, max.Y);
            closestPoint.Z = (closestPoint.Z + 2 * (max.Z + min.Z) / 2) / 3;

            closestPoint = Vector3D.Transform(closestPoint, fracture.PositionComp.WorldMatrix);

            return(true);
        }
All Usage Examples Of Vector3D::Clamp