Calculator
Namespace: Murder.Utilities
Assembly: Murder.dll
public static class Calculator
Calculator helper class.
⭐ Properties
LayersCount
public static int LayersCount;
Default layers count. TODO: Make this customizable.
Returns
int
TO_DEG
public static const float TO_DEG;
Returns
float
TO_RAD
public static const float TO_RAD;
Returns
float
⭐ Methods
AlmostEqual(float, float)
public bool AlmostEqual(float num1, float num2)
Parameters
num1
float
num2
float
Returns
bool
Blink(float, bool)
public bool Blink(float speed, bool scaled)
Parameters
speed
float
scaled
bool
Returns
bool
IsInteger(float)
public bool IsInteger(float value)
Parameters
value
float
Returns
bool
IsInteger(Vector2)
public bool IsInteger(Vector2 value)
Parameters
value
Vector2
Returns
bool
SameSign(float, float)
public bool SameSign(float num1, float num2)
Parameters
num1
float
num2
float
Returns
bool
SameSignOrSimilar(float, float)
public bool SameSignOrSimilar(float num1, float num2)
Parameters
num1
float
num2
float
Returns
bool
MultiplyUnsigned8Bit(byte, int)
public byte MultiplyUnsigned8Bit(byte a, int b)
Returns the result of multiplying two unsigned 8-bit values.
Returns
byte
LerpSnap(float, float, double, float)
public double LerpSnap(float origin, float target, double factor, float threshold)
Parameters
origin
float
target
float
factor
double
threshold
float
Returns
double
Approach(float, float, float)
public float Approach(float from, float target, float amount)
Parameters
from
float
target
float
amount
float
Returns
float
CatmullRom(float, float, float, float, float)
public float CatmullRom(float p0, float p1, float p2, float p3, float t)
Parameters
p0
float
p1
float
p2
float
p3
float
t
float
Returns
float
Clamp01(float)
public float Clamp01(float v)
Parameters
v
float
Returns
float
Clamp01(int)
public float Clamp01(int v)
Parameters
v
int
Returns
float
ClampNearZero(float, float)
public float ClampNearZero(float value, float minimum)
Parameters
value
float
minimum
float
Returns
float
ClampTime(float, float, float, float)
public float ClampTime(float elapsed, float inDuration, float delayDuration, float outDuration)
Normalizes elapsed time to a 0-1 range based on specified durations for an 'in', 'delay', and 'out' phase. The value goes from 0 to 1 then back to 0.
Parameters
elapsed
float
inDuration
float
delayDuration
float
outDuration
float
Returns
float
ClampTime(float, float, EaseKind)
public float ClampTime(float elapsed, float maxTime, EaseKind ease)
Normalizes and eases elapsed time into a 0-1 range based on a maximum duration and an easing function.
Parameters
elapsed
float
maxTime
float
ease
EaseKind
Returns
float
ClampTime(float, float)
public float ClampTime(float elapsed, float maxTime)
Normalizes the given elapsed time to a range of 0 to 1 based on the specified maximum time.
Parameters
elapsed
float
maxTime
float
Returns
float
ClampTime(float, float, float)
public float ClampTime(float start, float now, float duration)
Parameters
start
float
now
float
duration
float
Returns
float
ConvertLayerToLayerDepth(int)
public float ConvertLayerToLayerDepth(int layer)
Parameters
layer
int
Returns
float
DeterministicFloat(int, float, float)
public float DeterministicFloat(int seed, float min, float max)
Parameters
seed
int
min
float
max
float
Returns
float
InterpolateSmoothCurve(IList, float)
public float InterpolateSmoothCurve(IList<T> values, float t)
Parameters
values
IList<T>
t
float
Returns
float
Lerp(float, float, float)
public float Lerp(float origin, float target, float factor)
Parameters
origin
float
target
float
factor
float
Returns
float
LerpSmooth(float, float, float, float)
public float LerpSmooth(float a, float b, float deltaTime, float halfLife)
Smoothly interpolates between two float values over time using an exponential decay formula.
Parameters
a
float
b
float
deltaTime
float
halfLife
float
Returns
float
LerpSmoothAngle(float, float, float, float)
public float LerpSmoothAngle(float a, float b, float deltaTime, float halfLife)
Smoothly interpolates between two angles over time using a linear interpolation method.
Parameters
a
float
b
float
deltaTime
float
halfLife
float
Returns
float
LerpSnap(float, float, float, float)
public float LerpSnap(float origin, float target, float factor, float threshold)
Parameters
origin
float
target
float
factor
float
threshold
float
Returns
float
Max(Single[])
public float Max(Single[] values)
Parameters
values
float[]
Returns
float
Min(Single[])
public float Min(Single[] values)
Parameters
values
float[]
Returns
float
NormalizeAngle(float)
public float NormalizeAngle(float angle)
Normalizes the given angle to be within the range of 0 to 2π radians.
Parameters
angle
float
Returns
float
Remap(float, float, float, float, float)
public float Remap(float input, float inputMin, float inputMax, float min, float max)
Parameters
input
float
inputMin
float
inputMax
float
min
float
max
float
Returns
float
Remap(float, float, float)
public float Remap(float input, float min, float max)
Parameters
input
float
min
float
max
float
Returns
float
SmoothStep(float, float, float)
public float SmoothStep(float value, float min, float max)
Parameters
value
float
min
float
max
float
Returns
float
SnapAngle(float, int)
public float SnapAngle(float finalAngle, int steps)
Snap the current angle into
Parameters
finalAngle
float
steps
int
Returns
float
ToSpringOscillation(float, float)
public float ToSpringOscillation(float t, float frequency)
Converts a value to a spring oscillation.
Parameters
t
float
frequency
float
Returns
float
Wave(float, bool)
public float Wave(float speed, bool scaled)
Generates a normalized sine wave value oscillating between 0 and 1.
Parameters
speed
float
scaled
bool
Returns
float
Wave(float, float, float, bool)
public float Wave(float speed, float min, float max, bool scaled)
Generates a sinusoidal wave value oscillating between a specified minimum and maximum.
Parameters
speed
float
min
float
max
float
scaled
bool
Returns
float
CeilToInt(float)
public int CeilToInt(float v)
Parameters
v
float
Returns
int
ConvertLayerDepthToLayer(float)
public int ConvertLayerDepthToLayer(float layerDepth)
Parameters
layerDepth
float
Returns
int
DeterministicInt(int, int, int)
public int DeterministicInt(int seed, int min, int max)
Parameters
seed
int
min
int
max
int
Returns
int
FloorToInt(float)
public int FloorToInt(float v)
Parameters
v
float
Returns
int
LerpInt(float, float, float)
public int LerpInt(float origin, float target, float factor)
Parameters
origin
float
target
float
factor
float
Returns
int
ManhattanDistance(Point, Point)
public int ManhattanDistance(Point point1, Point point2)
Parameters
point1
Point
point2
Point
Returns
int
OneD(Point, int)
public int OneD(Point p, int width)
Returns
int
OneD(int, int, int)
public int OneD(int x, int y, int width)
Parameters
x
int
y
int
width
int
Returns
int
PolarSnapToInt(float)
public int PolarSnapToInt(float v)
Parameters
v
float
Returns
int
Pow(int, int)
public int Pow(int x, int y)
Returns
int
RoundToEven(float)
public int RoundToEven(float v)
Parameters
v
float
Returns
int
RoundToInt(double)
public int RoundToInt(double v)
Parameters
v
double
Returns
int
RoundToInt(float)
public int RoundToInt(float v)
Rounds and converts a number to integer with MathF.Round(System.Single).
Parameters
v
float
Returns
int
WrapAround(int, Int32&, Int32&)
public int WrapAround(int value, Int32& min, Int32& max)
Parameters
value
int
min
int&
max
int&
Returns
int
AddOnce(IList, T)
public T AddOnce(IList<T> list, T item)
Parameters
list
IList<T>
item
T
Returns
T
TryGet(IList, int)
public T? TryGet(IList<T> values, int index)
Parameters
values
IList<T>
index
int
Returns
T?
TryGet(ImmutableArray, int)
public T? TryGet(ImmutableArray<T> values, int index)
Parameters
values
ImmutableArray<T>
index
int
Returns
T?
RepeatingArray(T, int)
public T[] RepeatingArray(T value, int size)
Returns
T[]
Spring(float, float, float, float, float, float)
public ValueTuple<T1, T2> Spring(float value, float velocity, float targetValue, float damping, float frequency, float deltaTime)
Parameters
value
float
velocity
float
targetValue
float
damping
float
frequency
float
deltaTime
float
Returns
ValueTuple<T1, T2>
Approach(Vector2&, Vector2&, float)
public Vector2 Approach(Vector2& from, Vector2& target, float amount)
Parameters
from
Vector2&
target
Vector2&
amount
float
Returns
Vector2
DeterministicVector2(int, float)
public Vector2 DeterministicVector2(int seed, float radius)
Parameters
seed
int
radius
float
Returns
Vector2
DeterministicVector2InACircle(int, float)
public Vector2 DeterministicVector2InACircle(int seed, float radius)
Parameters
seed
int
radius
float
Returns
Vector2
GetPositionInSemicircle(float, Vector2, float, float, float)
public Vector2 GetPositionInSemicircle(float ratio, Vector2 center, float radius, float startAngle, float endAngle)
Parameters
ratio
float
center
Vector2
radius
float
startAngle
float
endAngle
float
Returns
Vector2
Lerp(Vector2, Vector2, float)
public Vector2 Lerp(Vector2 origin, Vector2 target, float factor)
Parameters
origin
Vector2
target
Vector2
factor
float
Returns
Vector2
LerpSmooth(Vector2, Vector2, float, float)
public Vector2 LerpSmooth(Vector2 a, Vector2 b, float deltaTime, float halfLife)
Smoothly interpolates between two vectors over time using a linear interpolation method.
Parameters
a
Vector2
b
Vector2
deltaTime
float
halfLife
float
Returns
Vector2
Normalized(Vector2&)
public Vector2 Normalized(Vector2& vector2)
Parameters
vector2
Vector2&
Returns
Vector2
RandomPointInCircleEdge()
public Vector2 RandomPointInCircleEdge()
Returns
Vector2
RandomPointInsideCircle()
public Vector2 RandomPointInsideCircle()
Returns
Vector2
Populate(T[], T)
public void Populate(T[] arr, T value)
⚡