Last active
May 21, 2018 05:52
-
-
Save mosluce/494213158200381bfb370cfcd088c92d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment