Polar array

Hey I’m new to rhinoscripting and I’m just wonder if there is a way to polar array something around a point in python? I’ve looked at the polar() command and it looks it is meant to do something else

Welcome,

Here’s an example on how to convert cartesian to polar coordinates and vis versa:


import Rhino.Geometry as rg
import math

def to_polar(x, y):
    """Returns a radius and angle in radians from xy-coordinates."""
    return (x**2 + y**2)**0.5, math.atan2(y, x)

def to_cartesian(r, delta):
    """Returns xy-coordinates from a radius and angle in radians."""
    return r * math.cos(delta), r * math.sin(delta)

angle = 0.0
step = 0.1
radius = 10.0

points = []

while angle < 2 * math.pi:
    x, y = to_cartesian(radius, angle)
    points.append(rg.Point3d(x, y, 0.0))
    angle += step

The generated points will be organized in a circular manner.

This all happens in the XY-plane. If you want to be able to change the plane, you can transform the points from the XY-plane to another plane.

1 Like

thanks for the help