Table of Contents

Class NumberExtensions

Namespace
MLEM.Extended.Maths
Assembly
MLEM.Extended.dll

A set of extension methods that convert MLEM types to MonoGame.Extended types and vice versa.

public static class NumberExtensions
Inheritance
NumberExtensions
Inherited Members

Methods

FromPercentage(Range<int>, float)

Returns a value within the given range's MonoGame.Extended.Range<T>.Min and MonoGame.Extended.Range<T>.Max values based on the given percentage into the range. Note that, if the percentage is outside the 0 to 1 range, a correct value outside the range will still be returned. This method is the reverse action of GetPercentage(Range<int>, float).

public static float FromPercentage(this Range<int> range, float percentage)

Parameters

range Range<int>

The range to query.

percentage float

The percentage to query.

Returns

float

The value.

FromPercentage(Range<float>, float)

Returns a value within the given range's MonoGame.Extended.Range<T>.Min and MonoGame.Extended.Range<T>.Max values based on the given percentage into the range. Note that, if the percentage is outside the 0 to 1 range, a correct value outside the range will still be returned. This method is the reverse action of GetPercentage(Range<float>, float).

public static float FromPercentage(this Range<float> range, float percentage)

Parameters

range Range<float>

The range to query.

percentage float

The percentage to query.

Returns

float

The value.

GetPercentage(Range<int>, float)

Returns how far between the given range's MonoGame.Extended.Range<T>.Min and MonoGame.Extended.Range<T>.Max value the given value is, as a number between 0 and 1. Note that, if the value is outside the given range, a correct proportional value outside the 0 to 1 range will still be returned. This method is the reverse action of FromPercentage(Range<int>, float).

public static float GetPercentage(this Range<int> range, float value)

Parameters

range Range<int>

The range to query.

value float

The value to query.

Returns

float

The percentage.

GetPercentage(Range<float>, float)

Returns how far between the given range's MonoGame.Extended.Range<T>.Min and MonoGame.Extended.Range<T>.Max value the given value is, as a number between 0 and 1. Note that, if the value is outside the given range, a correct proportional value outside the 0 to 1 range will still be returned. This method is the reverse action of FromPercentage(Range<float>, float).

public static float GetPercentage(this Range<float> range, float value)

Parameters

range Range<float>

The range to query.

value float

The value to query.

Returns

float

The percentage.

Penetrate(RectangleF, RectangleF, out Vector2, out float)

Calculates the amount that the rectangle rect is penetrating the rectangle other by. If a penetration on both axes is occuring, the one with the lower value is returned. This is useful for collision detection, as it can be used to push colliding objects out of each other.

public static bool Penetrate(this RectangleF rect, RectangleF other, out Vector2 normal, out float penetration)

Parameters

rect RectangleF

The rectangle to do the penetration

other RectangleF

The rectangle that should be penetrated

normal Vector2

The direction that the penetration occured in

penetration float

The amount that the penetration occured by, in the direction of normal

Returns

bool

Whether or not a penetration occured

ToExtended(RectangleF)

Converts a MLEM RectangleF to a MonoGame.Extended MonoGame.Extended.RectangleF.

public static RectangleF ToExtended(this RectangleF rect)

Parameters

rect RectangleF

The rectangle to convert

Returns

RectangleF

The converted rectangle

ToMlem(RectangleF)

Converts a MonoGame.Extended MonoGame.Extended.RectangleF to a MLEM RectangleF.

public static RectangleF ToMlem(this RectangleF rect)

Parameters

rect RectangleF

The rectangle to convert

Returns

RectangleF

The converted rectangle