I hope this helps you . What you need is a new coordinate system to place the circle. As any common coordinate system, we'll want the base vectors to be orthogonal to each other, and have length 1 each. I'll name the base vectors v1, v2, and v3, which correspond to x, y, and z in order.

The new base vector that replaces z, which is v3 is given by the normal vector of the circle. If it's not normalized yet, you'll want to normalize it here:

code :

```
[ v3x ]
v3 = [ v3y ] = normalize(circleNormal)
[ v3z ]
```

```
[ v3z ]
v1 = normalize([ 0 ])
[ -v3x]
```

```
v2 = v3 x v1
```

```
p = centerPoint + R * (cos(a) * v1 + sin(a) * v2)
```

```
// Only needed if normal vector (nx, ny, nz) is not already normalized.
float s = 1.0f / (nx * nx + ny * ny + nz * nz);
float v3x = s * nx;
float v3y = s * ny;
float v3z = s * nz;
// Calculate v1.
s = 1.0f / (v3x * v3x + v3z * v3z);
float v1x = s * v3z;
float v1y = 0.0f;
float v1z = s * -v3x;
// Calculate v2 as cross product of v3 and v1.
// Since v1y is 0, it could be removed from the following calculations. Keeping it for consistency.
float v2x = v3y * v1z - v3z * v1y;
float v2y = v3z * v1x - v3x * v1z;
float v2z = v3x * v1y - v3y * v1x;
// For each circle point.
px = cx + r * (v1x * cos(a) + v2x * sin(a))
py = cy + r * (v1y * cos(a) + v2y * sin(a))
pz = cz + r * (v1z * cos(a) + v2z * sin(a))
```