Merge branch 'patch-2' of https://github.com/rkrahn/FlaxEngine into rkrahn-patch-2

This commit is contained in:
Wojtek Figat
2024-02-19 22:17:06 +01:00

View File

@@ -301,6 +301,18 @@ namespace FlaxEngine.Utilities
double randomRadian = random.NextDouble() * Mathf.RevolutionsToRadians;
return new Vector2((float)Math.Cos(randomRadian) * magnitude, (float)Math.Sin(randomRadian) * magnitude);
}
/// <summary>
/// Generates a random <see cref="Vector2"/> point on a circle of a given radius.
/// </summary>
/// <param name="random">An instance of <see cref="Random"/>.</param>
/// <param name="radius">Radius of circle. Default 1.0f./>.</param>
/// <returns>A random <see cref="Vector2"/>.</returns>
public static Vector2 NextUnitCircleVector2(this Random random, float radius = 1.0f)
{
double randomRadian = random.NextDouble() * Mathf.RevolutionsToRadians;
return new Vector2((float)Math.Cos(randomRadian) * radius, (float)Math.Sin(randomRadian) * radius);
}
/// <summary>
/// Generates a uniformly distributed random unit length vector point on a unit sphere.