Skip to content
Snippets Groups Projects
obj.py 625 B
Newer Older
Djalim Simaila's avatar
Djalim Simaila committed
import random
import math

def circle_points(r, cx, cy):
    cpt = 0
    angles = []
    while cpt < 2*math.pi:
        angles.append(cpt)
        cpt += 1/6*math.pi
    return [[round(r * math.cos(angle) + cx,6), round(r * math.sin(angle) + cy,6)] for angle in angles]

cylindre = []
for i in range(10):
    points = circle_points(random.randint(2,20),5,5)
    for point in points:
        point.append(i)
    cylindre.append(points)

with open("test_cylindre.xyz",'w') as f:
    for couches in cylindre:
        for points in couches:
            x,y,z = points[0],points[1],points[2]
            f.write(f"{x} {y} {z}\n")