- Home /

# Get Vertices of Circle Facing Any Direction

Been trying to figure this out on my own, but stuck, and not finding any resources which help me with this (or i lack the correct terminology to ask the right question). Trying to get the vertices of a circle facing any direction (x, y, z). Found lots of help on doing this in 2D space, or 3D if one vector is static, but needing help with facing in any direction in 3D space.

```
private void createCircle(Vector3 center, Vector3 next, float radius, int vertCount, int count)
{
// get direction of plane
Vector3 heading = next - center;
// get vertices of circle facing heading (x, y, z), and add them to vertices[]
int arrayCount = (count - 1) * vertCount;
for (int d = 0; d < vertCount; d++)
{
// get each vertex of cicle
Vector3 vertex;
// add vertex to array
vertices[arrayCount] = vertex;
}
}
```

The center of the circle will be at 'center' and 'next' will be the where the circle will face. Then I'll add each vertex to my array. Need help with the equation to define 'vertex'

**Answer** by Namey5
·
Jun 22, 2020 at 12:05 AM

I'm sure you could do it with some 3D trigonometry, but to make things a bit simpler you can also get the same result by finding one vertex and rotating it around the centre. Something like this should work;

```
private void createCircle(Vector3 center, Vector3 next, float radius, int vertCount, int count)
{
// get direction of plane
Vector3 normal = (next - center).normalized;
//Cross product will always return a vector perpendicular to its inputs, so anything will do for the second input so long as it isn't equal to normal
Vector3 tangent = Vector3.Cross (normal, (normal == Vector3.up) ? Vector3.forward : Vector3.up).normalized;
// get vertices of circle facing heading (x, y, z), and add them to vertices[]
int arrayCount = (count - 1) * vertCount;
for (int d = 0; d < vertCount; d++)
{
//Rotate the tangent around the circle and scale by radius
Vector3 vertex = centre + (Quaternion.AngleAxis ((d / (float)vertCount) * 360f, normal) * tangent) * radius;
// add vertex to array
vertices[arrayCount] = vertex;
}
}
```

Was looking for the 3D Trig option, but this helps, and works well. Thank you!

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.