Would be great to have a class with some custom objects.
See some illustration below...
It can be called by
from openpyscad.custom2dshapes import Custom2dShapes as c2d
triangle = c2d.regular_polygon(3,10)
triangle.write('triangle.scad')
from math import cos, sin, pi
from openpyscad.shapes_2d import *
class Custom2dShapes(object):
@staticmethod
def regular_polygon(num, r):
points = list()
for i in range(num):
a_deg = i * 360 / num
a_rad = a_deg * 2 * pi / 360
points += [[r * cos(a_rad), r * sin(a_rad)]]
regular_poly = Polygon(points)
return(regular_poly)
What do you think... at the moment I just put it in a separate file custom2dshapes.py but was wondering if you think of a better way to organize this kind of objects....
Would be great to have a class with some custom objects. See some illustration below... It can be called by
What do you think... at the moment I just put it in a separate file custom2dshapes.py but was wondering if you think of a better way to organize this kind of objects....