Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Circle(Vector3 center, Vector3 normal, int polyAmount, float radius)
- {
- this.normal = normal.normalized;
- this.center = center;
- var z = Vector3.forward;
- var dot = Vector3.Dot(z, normal);
- var y = z - dot * normal;
- if (dot == 1 || dot == -1)
- {
- y = Vector3.up;
- }
- this.vertices = new Vector3[polyAmount];
- var delta = 360 / polyAmount;
- for (int i = 0; i < polyAmount; i++)
- {
- this.vertices[i] = Quaternion.AngleAxis(-delta * i, normal) * y.normalized * radius + center;
- }
- }
- }
Add Comment
Please, Sign In to add comment