32 lines
735 B
C#
32 lines
735 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace Voxus.Random
|
|
{
|
|
public static class RandomHelpers
|
|
{
|
|
public static int Range(float random, int min, int max)
|
|
{
|
|
return (int)(random * (float)(max - min)) + min;
|
|
}
|
|
|
|
public static Vector3 OnUnitSphere(float random1, float random2)
|
|
{
|
|
float f = random1 * 2f * MathF.PI;
|
|
float f2 = Mathf.Acos(2f * random2 - 1f);
|
|
float num = Mathf.Sin(f2);
|
|
float x = num * Mathf.Cos(f);
|
|
float y = num * Mathf.Sin(f);
|
|
float z = Mathf.Cos(f2);
|
|
return new Vector3(x, y, z);
|
|
}
|
|
|
|
public static Vector3 OnUnitSphere(RandomLinear randomGenerator)
|
|
{
|
|
float random = randomGenerator.Get();
|
|
float random2 = randomGenerator.Get();
|
|
return OnUnitSphere(random, random2);
|
|
}
|
|
}
|
|
}
|