Guest User

Untitled

a guest
May 25th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. public Circle(Vector3 center, Vector3 normal, int polyAmount, float radius)
  2. {
  3. this.normal = normal.normalized;
  4. this.center = center;
  5.  
  6. var z = Vector3.forward;
  7. var dot = Vector3.Dot(z, normal);
  8. var y = z - dot * normal;
  9.  
  10. if (dot == 1 || dot == -1)
  11. {
  12. y = Vector3.up;
  13. }
  14.  
  15. this.vertices = new Vector3[polyAmount];
  16.  
  17. var delta = 360 / polyAmount;
  18.  
  19. for (int i = 0; i < polyAmount; i++)
  20. {
  21. this.vertices[i] = Quaternion.AngleAxis(-delta * i, normal) * y.normalized * radius + center;
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment