forked from Priyansh-15/3-D-Image-Build-from-Multiple-Images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrotate_translate.py
82 lines (68 loc) · 2.33 KB
/
rotate_translate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python
# coding: utf-8
# In[1]:
class node:
t = 0
ro = 0
tx = 0
ty = 0
tz = 0
rx = 0
ry = 0
rz = 0
def __init__(self, shape='set', operation='None',l=0, b=0, h=0,fn=12, fa=12, fs=2, r=0, r1=0,center="true"):
self.left = 'None'
self.right = 'None'
self.string = ''
self.operation = operation
self.shape = shape
self.l = l
self.b = b
self.h = h
self.fn = fn
self.fa = fa
self.fs = fs
self.r = r
self.r1 = r1
self.center = center
def translate(self, x=0, y=0, z=0):
self.tx = x
self.ty = y
self.tz = z
self.t = 1
def rotate(self, x=0, y=0, z=0):
self.rx = x
self.ry = y
self.rz = z
self.ro = 1
def name(self):
if(self.t == 1):
self.string = 'translate([' + str(self.tx) + ',' + str(self.ty) + ',' + str(self.tz) + ']){\n\t'
if(self.ro == 1):
if(self.t == 1):
self.string = self.string + 'rotate([' + str(self.rx) + ',' + str(self.ry) + ',' + str(self.rz) + ']){\n\t\t'
else:
self.string = self.string +'rotate([' + str(self.rx) + ',' + str(self.ry) +',' + str(self.rz) + ']){\n\t'
if(self.shape == "cube"):
self.string = self.string + 'cube([' + str(self.l) + ',' + str(self.b) + ',' + str(self.h) + '], center = ' + self.center + ');\n'
if(self.shape == "cylinder"):
self.string = self.string + 'cylinder($fn = ' +str(self.fn)+', h = '+str(self.h)+', r1 = '+str(self.r)+', r2 = ' + str(self.r1) + ', center = ' + self.center + ');\n'
if(self.shape == "sphere"):
self.string = self.string + 'sphere($fn = ' + str(self.fn) + ', $fa = ' + str(self.fa) + ', $fs = ' + str(self.fs) + \
'r = ' + str(self.r) + ');\n'
if(self.ro == 1 and self.t == 1):
self.string = self.string + "\t}\n"
if(self.ro == 1 or self.t == 1):
self.string = self.string + "}\n"
def setr(self, r):
self.r = r
def setl(self, l):
self.l = l
def setb(self, b):
self.b = b
def seth(self, h):
self.h = h
def setr1(self, r):
self.r1 = r
def setoperation(self, operation):
self.operation = operation