Table of Contents

Class MBMath

Namespace
TaleWorlds.Library
Assembly
TaleWorlds.Library.dll
public static class MBMath
Inheritance
MBMath
Inherited Members

Fields

DegreesToRadians

public const float DegreesToRadians = 0.017453292

Field Value

float

E

public const float E = 2.7182817

Field Value

float

Epsilon

public const float Epsilon = 1E-05

Field Value

float

HalfPI

public const float HalfPI = 1.5707964

Field Value

float

PI

public const float PI = 3.1415927

Field Value

float

RadiansToDegrees

public const float RadiansToDegrees = 57.295776

Field Value

float

TwoPI

public const float TwoPI = 6.2831855

Field Value

float

Methods

ApproximatelyEquals(float, float, float)

public static bool ApproximatelyEquals(float first, float second, float epsilon = 1E-05)

Parameters

first float
second float
epsilon float

Returns

bool

ApproximatelyEqualsTo(float, float, float)

public static bool ApproximatelyEqualsTo(this float f, float comparedValue, float epsilon = 1E-05)

Parameters

f float
comparedValue float
epsilon float

Returns

bool

BilinearLerp(float, float, float, float, float, float)

public static float BilinearLerp(float topLeft, float topRight, float botLeft, float botRight, float x, float y)

Parameters

topLeft float
topRight float
botLeft float
botRight float
x float
y float

Returns

float

CheckLineToLineSegmentIntersection(Vec2, Vec2, Vec2, Vec2, out float, out Vec2)

public static bool CheckLineToLineSegmentIntersection(Vec2 lineOrigin, Vec2 lineDirection, Vec2 segmentA, Vec2 segmentB, out float t, out Vec2 intersect)

Parameters

lineOrigin Vec2
lineDirection Vec2
segmentA Vec2
segmentB Vec2
t float
intersect Vec2

Returns

bool

ClampAngle(float, float, float)

public static float ClampAngle(float angle, float restrictionCenter, float restrictionRange)

Parameters

angle float
restrictionCenter float
restrictionRange float

Returns

float

ClampFloat(float, float, float)

public static float ClampFloat(float value, float minValue, float maxValue)

Parameters

value float
minValue float
maxValue float

Returns

float

ClampIndex(int, int, int)

public static int ClampIndex(int value, int minValue, int maxValue)

Parameters

value int
minValue int
maxValue int

Returns

int

ClampInt(int, int, int)

public static int ClampInt(int value, int minValue, int maxValue)

Parameters

value int
minValue int
maxValue int

Returns

int

ClampUnit(ref float)

public static void ClampUnit(ref float value)

Parameters

value float

ColorFromRGBA(float, float, float, float)

public static uint ColorFromRGBA(float red, float green, float blue, float alpha)

Parameters

red float
green float
blue float
alpha float

Returns

uint

DistributeShares<T>(int, IEnumerable<T>, Func<T, int>)

public static IEnumerable<(T, int)> DistributeShares<T>(int totalAward, IEnumerable<T> stakeHolders, Func<T, int> shareFunction)

Parameters

totalAward int
stakeHolders IEnumerable<T>
shareFunction Func<T, int>

Returns

IEnumerable<(T, int)>

Type Parameters

T

GammaCorrectRGB(float, Vec3)

public static Vec3 GammaCorrectRGB(float gamma, Vec3 rgb)

Parameters

gamma float
rgb Vec3

Returns

Vec3

GetClosestPointInLineSegmentToPoint(Vec2, Vec2, Vec2)

public static Vec2 GetClosestPointInLineSegmentToPoint(Vec2 point, Vec2 lineSegmentBegin, Vec2 lineSegmentEnd)

Parameters

point Vec2
lineSegmentBegin Vec2
lineSegmentEnd Vec2

Returns

Vec2

GetClosestPointInLineSegmentToPoint(Vec3, Vec3, Vec3)

public static Vec3 GetClosestPointInLineSegmentToPoint(Vec3 point, Vec3 lineSegmentBegin, Vec3 lineSegmentEnd)

Parameters

point Vec3
lineSegmentBegin Vec3
lineSegmentEnd Vec3

Returns

Vec3

GetClosestPointOnLineSegment(Vec2, Vec2, Vec2, out Vec2)

public static float GetClosestPointOnLineSegment(Vec2 point, Vec2 segmentA, Vec2 segmentB, out Vec2 closest)

Parameters

point Vec2
segmentA Vec2
segmentB Vec2
closest Vec2

Returns

float

GetNumberOfBitsToRepresentNumber(uint)

public static int GetNumberOfBitsToRepresentNumber(uint value)

Parameters

value uint

Returns

int

GetNumberOfBitsToRepresentNumber(ulong)

public static int GetNumberOfBitsToRepresentNumber(ulong value)

Parameters

value ulong

Returns

int

GetRayPlaneIntersectionPoint(in Vec3, in Vec3, in Vec3, in Vec3, out float)

public static bool GetRayPlaneIntersectionPoint(in Vec3 planeNormal, in Vec3 planeCenter, in Vec3 rayOrigin, in Vec3 rayDirection, out float t)

Parameters

planeNormal Vec3
planeCenter Vec3
rayOrigin Vec3
rayDirection Vec3
t float

Returns

bool

GetSmallestDifferenceBetweenTwoAngles(float, float)

public static float GetSmallestDifferenceBetweenTwoAngles(float fromAngle, float toAngle)

Parameters

fromAngle float
toAngle float

Returns

float

HSBtoRGB(float, float, float, float)

public static Color HSBtoRGB(float hue, float saturation, float brightness, float outputAlpha)

Parameters

hue float
saturation float
brightness float
outputAlpha float

Returns

Color

IndexOfMax<T>(MBReadOnlyList<T>, Func<T, int>)

public static int IndexOfMax<T>(MBReadOnlyList<T> array, Func<T, int> func)

Parameters

array MBReadOnlyList<T>
func Func<T, int>

Returns

int

Type Parameters

T

IntersectRayWithBoundaryList(Vec2, Vec2, List<Vec2>, out Vec2)

public static bool IntersectRayWithBoundaryList(Vec2 rayOrigin, Vec2 rayDir, List<Vec2> boundaries, out Vec2 intersectionPoint)

Parameters

rayOrigin Vec2
rayDir Vec2
boundaries List<Vec2>
intersectionPoint Vec2

Returns

bool

InverseLerp(float, float, float)

public static float InverseLerp(float valueFrom, float valueTo, float value)

Parameters

valueFrom float
valueTo float
value float

Returns

float

IsBetween(int, int, int)

public static bool IsBetween(int value, int minValue, int maxValue)

Parameters

value int
minValue int
maxValue int

Returns

bool

IsBetween(float, float, float)

public static bool IsBetween(float numberToCheck, float bottom, float top)

Parameters

numberToCheck float
bottom float
top float

Returns

bool

IsBetweenInclusive(float, float, float)

public static bool IsBetweenInclusive(float numberToCheck, float bottom, float top)

Parameters

numberToCheck float
bottom float
top float

Returns

bool

IsValidValue(float)

public static bool IsValidValue(float f)

Parameters

f float

Returns

bool

Lerp(float, float, float, float)

public static float Lerp(float valueFrom, float valueTo, float amount, float minimumDifference = 1E-05)

Parameters

valueFrom float
valueTo float
amount float
minimumDifference float

Returns

float

Lerp(ref Mat3, ref Mat3, float, float)

public static Mat3 Lerp(ref Mat3 matFrom, ref Mat3 matTo, float amount, float minimumDifference)

Parameters

matFrom Mat3
matTo Mat3
amount float
minimumDifference float

Returns

Mat3

Lerp(Vec2, Vec2, float, float)

public static Vec2 Lerp(Vec2 vecFrom, Vec2 vecTo, float amount, float minimumDifference)

Parameters

vecFrom Vec2
vecTo Vec2
amount float
minimumDifference float

Returns

Vec2

Lerp(Vec3, Vec3, float, float)

public static Vec3 Lerp(Vec3 vecFrom, Vec3 vecTo, float amount, float minimumDifference)

Parameters

vecFrom Vec3
vecTo Vec3
amount float
minimumDifference float

Returns

Vec3

LerpRadians(float, float, float, float, float)

public static float LerpRadians(float valueFrom, float valueTo, float amount, float minChange, float maxChange)

Parameters

valueFrom float
valueTo float
amount float
minChange float
maxChange float

Returns

float

LinearExtrapolation(float, float, float)

public static float LinearExtrapolation(float valueFrom, float valueTo, float amount)

Parameters

valueFrom float
valueTo float
amount float

Returns

float

Map(float, float, float, float, float)

public static float Map(float input, float inputMinimum, float inputMaximum, float outputMinimum, float outputMaximum)

Parameters

input float
inputMinimum float
inputMaximum float
outputMinimum float
outputMaximum float

Returns

float

MaxElement<T>(IEnumerable<T>, Func<T, float>)

public static T MaxElement<T>(IEnumerable<T> collection, Func<T, float> func)

Parameters

collection IEnumerable<T>
func Func<T, float>

Returns

T

Type Parameters

T

MaxElements2<T>(IEnumerable<T>, Func<T, float>)

public static (T, T) MaxElements2<T>(IEnumerable<T> collection, Func<T, float> func)

Parameters

collection IEnumerable<T>
func Func<T, float>

Returns

(T, T)

Type Parameters

T

MaxElements3<T>(IEnumerable<T>, Func<T, float>)

public static (T, T, T) MaxElements3<T>(IEnumerable<T> collection, Func<T, float> func)

Parameters

collection IEnumerable<T>
func Func<T, float>

Returns

(T, T, T)

Type Parameters

T

MaxElements4<T>(IEnumerable<T>, Func<T, float>)

public static (T, T, T, T) MaxElements4<T>(IEnumerable<T> collection, Func<T, float> func)

Parameters

collection IEnumerable<T>
func Func<T, float>

Returns

(T, T, T, T)

Type Parameters

T

MaxElements5<T>(IEnumerable<T>, Func<T, float>)

public static (T, T, T, T, T) MaxElements5<T>(IEnumerable<T> collection, Func<T, float> func)

Parameters

collection IEnumerable<T>
func Func<T, float>

Returns

(T, T, T, T, T)

Type Parameters

T

RGBtoHSB(Color)

public static Vec3 RGBtoHSB(Color rgb)

Parameters

rgb Color

Returns

Vec3

SmoothStep(float, float, float)

public static float SmoothStep(float edge0, float edge1, float value)

Parameters

edge0 float
edge1 float
value float

Returns

float

SplitLerp(float, float, float, float, float, float)

public static float SplitLerp(float value1, float value2, float value3, float cutOff, float amount, float minimumDifference)

Parameters

value1 float
value2 float
value3 float
cutOff float
amount float
minimumDifference float

Returns

float

ToDegrees(float)

public static float ToDegrees(this float f)

Parameters

f float

Returns

float

ToOrdinal(int)

public static string ToOrdinal(int number)

Parameters

number int

Returns

string

ToRadians(float)

public static float ToRadians(this float f)

Parameters

f float

Returns

float

TopologySort<T>(IEnumerable<T>, Func<T, IEnumerable<T>>)

public static IList<T> TopologySort<T>(IEnumerable<T> source, Func<T, IEnumerable<T>> getDependencies)

Parameters

source IEnumerable<T>
getDependencies Func<T, IEnumerable<T>>

Returns

IList<T>

Type Parameters

T

WrapAngle(float)

public static float WrapAngle(float angle)

Parameters

angle float

Returns

float

This page was last modified at 09/01/2024 16:12:00 +00:00 (UTC).