Placing points in circle

I need to place vector points in circle by setting their relative positions. It must be done among one axis(like in 2D). I need it to have it’s local offset only among Y and Z axis.


Here you can see the overall idea, but note that this is inaccurate image. The offset angle a is the same all over the circle. I can calculate it in loop doing (i + 1) * a. All of the red lines(they’re imaginary, I don’t need them to be somehow calculated) are the same length of x. What I need are those points. The coordinates I typed there are not calculated. They’re just approximate what my eye see. However, they should give you an overall idea of the coordinate system required.
How to calculate the local offset for each of those points?

Attachments


Found it:
https://www.desmos.com/calculator/u9hl0tcbqm

I plotted it in graph. It shows the 2 functions - one for each of the axis. In 3D one axis stays 0.

For n points, at a radius r:


from math import radians, sin, cos

def circle_points(origin, n, r):
    step = radians(360) / n
    for i in range(n):
        y = r*sin(step * i)
        x = r*cos(step * i)
        point = Vector((x, y, 0)) + origin
        yield point


test_origin = Vector((0,1,0))
all_points = circle_points(test_origin, 12, 1.0)

for point in points:
    print(point)


For n points, at a radius r:


from mathutils import Vector
from math import radians, sin, cos


def circle_points(origin, n, r):
    step = radians(360) / n
    for i in range(n):
        y = r*sin(step * i)
        x = r*cos(step * i)
        point = Vector((x, y, 0)) + origin
        yield point

test_origin = Vector((0,1,0))
all_points = circle_points(test_origin, 12, 1.0)

for point in points:
    print(point)


For n points, at a radius r:


from mathutils import Vector
from math import radians, sin, cos


def circle_points(origin, n, r):
    step = radians(360) / n
    for i in range(n):
        y = r*sin(step * i)
        x = r*cos(step * i)
        point = Vector((x, y, 0)) + origin
        yield point

test_origin = Vector((0,1,0))
all_points = circle_points(test_origin, 12, 1.0)

for point in points:
    print(point)


For n points, at a radius r:


from mathutils import Vector
from math import radians, sin, cos


def circle_points(origin, n, r):
    step = radians(360) / n
    for i in range(n):
        y = r*sin(step * i)
        x = r*cos(step * i)
        point = Vector((x, y, 0)) + origin
        yield point

test_origin = Vector((0,1,0))
all_points = circle_points(test_origin, 12, 1.0)

for point in points:
    print(point)


To illustrate the agoose77 function, you can take a look at this: http://www.pasteall.org/pic/show.php?id=103593
for a given angle, cos(angle) gives you X coordinate and sin(angle) gives you Y coordinate of a point on the circle…

You could also just create a Vector and rotate it a bit each time using the Vector.rotate() function. No need to do it manually, is there?

It’s probably useful to demonstrate the function behind it (after all, Vector.rotate will accept a rotation matrix which rotates the components in the same way). You also have to call copy() which is a little awkward itself. I would probably use rotate() myself.