unit circle point calcuaot any radius code example

Example 1: circumference of a circle with a radius of 23.56

const number = 23 //or any number you like
Math.floor(number * (2 * Math.PI)

Example 2: get random point within radius

/// <summary>
/// Returns a random point within a certain radius
/// of a given point
/// </summary>
/// <param name="centerPoint"></param>
/// <param name="radius"></param>
/// <returns></returns>
public Vector3 GetRandomPointInsideCircle(Vector3 centerPoint, float radius)
{
    Vector3 point = Random.insideUnitSphere * radius;
    point.z = 0;
    point += centerPoint;
    return point;
}

Tags:

Misc Example