Dogan Kirnaz
  • Welcome
  • Setup
    • Quickstart
  • Basics
    • Agent Extensions
    • Audio Extensions
    • Camera Extensions
    • Collision Extensions
    • Coroutine Extensions
    • Encryption Extensions
    • Format Extensions
    • Game Extensions
    • Json Extensions
    • List Extensions
    • Loop Extensions
    • Material Extensions
    • Math Extensions
    • GameObject Extensions
    • Physics Extensions
    • Object Pool Extensions
    • Scene Extensions
    • PlayerPrefs Extensions
  • Support
    • Support
Powered by GitBook
On this page
  1. Basics

Math Extensions

Lerp Angle

This linearly interpolates between two angles, ensuring the shortest path is taken.

float angleA = 30f;
float angleB = 350f;

float lerp = MathExtensions.LerpAngle(angleA, angleB, 0.5f);

Smooth Step

This smoothly interpolates between two values using Hermite interpolation.

float start = 0f;
float end = 1f;

float smooth = MathExtensions.SmoothStep(start, end, 0.5f);

Sinerp

This smoothly interpolates between two values using sine interpolation.

float valueA = 0f;
float valueB = 10f;

float sinerp = MathExtensions.Sinerp(valueA, valueB, 0.5f);

Round To Nearest

This rounds a number to the nearest specified increment.

float value = 7.6f;

float rounded = MathExtensions.RoundToNearest(value, 0.5f);

Shortest Difference

This calculates the shortest difference between two angles.

float angleA = 30f;
float angleB = 350f;

float difference = MathExtensions.ShortestDifference(angleA, angleB);

Average

This calculates the average of an array of floats.

float[] values = { 1f, 2f, 3f, 4f, 5f };

float average = values.Average();

Max

This retrieves the maximum value from an array of floats.

float[] values = { 1f, 2f, 3f, 4f, 5f };

float max = values.Max();

Min

This retrieves the minimum value from an array of floats.

float[] values = { 1f, 2f, 3f, 4f, 5f };

float min = values.Min();

Sum

This calculates the sum of an array of floats.

float[] values = { 1f, 2f, 3f, 4f, 5f };

float sum = values.Sum();
PreviousMaterial ExtensionsNextGameObject Extensions

Last updated 23 days ago