유니티(Unity) | Random Point Inside Circle
Programming/Unity
2017. 10. 8. 13:38
1 2 3 4 5 6 7 8 9 | public Vector3 RandomPointInsideCircle(float radius) { float u = Random.Range(0f, 1f); float theta = u * (Mathf.PI * 2f); float sqrt = Mathf.Sqrt(Random.Range(0f, 1f)); radius *= sqrt; return new Vector3(radius * Mathf.Cos(theta), radius * Mathf.Sin(theta), 0f); } | cs |