Python Forum
Optimizations For tkinter Canvas
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Optimizations For tkinter Canvas
#1
I hope everyone is doing well. I tried making a simple graphics engine using tkinter and it's canvas, heavily inspired from,
https://github.com/hnhaefliger/PyEngine3D

However, the code is too slow for a large number of polygons, I had earlier read that tkinter canvas can easily manage thousands of shapes at once. I have also profiled the code and it seems that the majority of the bottleneck is due to tkinter itself?

import tkinter
import math
import time
import cProfile


class Engine_3d:
    def __init__(self, width, height, fps=60, bgc=None, plc=None, pfc=None, frame_adjust=1):
        self.application = tkinter.Tk()
        self.application.title('hmEngine_3d')
        self.width = width
        self.height = height
        self.fps = fps
        self.bgc = bgc
        self.plc = plc
        self.pfc = pfc
        self.shape = None
        self.polygons = {}
        self.z_buffer = {}
        self.fps_counter = 0
        self.fps_timer = 0
        if self.bgc is None:
            self.bgc = 'white'
        if self.plc is None:
            self.plc = 'black'
        if self.pfc is None:
            self.pfc = 'grey'
        self.frame_adjust = frame_adjust
        self.mspf = math.ceil(1 / self.fps * (1000 * self.frame_adjust))
        self.canvas = tkinter.Canvas(self.application, width=self.width, height=self.height, bg=self.bgc)
        self.canvas.pack()

    def mainloop(self):
        self.update_screen()
        self.application.mainloop()

    def buffer_flush(self):
        sorted_polygons = [each_poly for each_poly, _ in sorted(self.z_buffer.items(), key=lambda x:x[1], reverse=True)]
        for polygon_id in sorted_polygons:
            self.canvas.coords(polygon_id, *self.z_buffer[polygon_id][1])
            self.canvas.lift(polygon_id)

    def load_data(self, shape):
        self.shape = shape
        for poly_ref in self.shape.polygons:
            poly_coordinate = []
            poly_points = []
            for poly_point_reference in poly_ref:
                poly_points.append(poly_point_reference)
                poly_coordinate.extend([self.shape.points[poly_point_reference].p_x + self.width / 2,
                                        (self.shape.points[poly_point_reference].p_y * -1) + self.height / 2])
            poly_id = self.canvas.create_polygon(poly_coordinate, outline=self.plc, fill=self.pfc)
            self.polygons[poly_id] = poly_points
        self.canvas.update()
        self.fps_timer = time.time()

    def update_polygons(self):
        for poly_ref, poly_points in self.polygons.items():
            poly_coordinate = []
            poly_total_z = 0
            for poly_point_reference in poly_points:
                poly_coordinate.extend([self.shape.points[poly_point_reference].p_x + self.width / 2,
                                        (self.shape.points[poly_point_reference].p_y * -1) + self.height / 2])
                poly_total_z += self.shape.points[poly_point_reference].z
            self.z_buffer[poly_ref] = (poly_total_z / len(poly_points), poly_coordinate)
        self.buffer_flush()

    def activity(self):
        pass

    def update_screen(self):
        self.activity()
        self.update_polygons()
        self.fps_measure()
        self.application.after(self.mspf, self.update_screen)

    def fps_measure(self):
        self.fps_counter += 1
        if time.time() - self.fps_timer >= 1:
            self.frame_cycle()
            self.fps_counter = 0
            self.fps_timer = time.time()

    def frame_cycle(self):
        print('Frames per second', self.fps_counter)


class Shape:
    def __init__(self, points, polygon_references, scale, distance):
        self.scale = scale
        self.distance = distance
        self.points = points
        for each_point in self.points:
            each_point.project(self.scale, self.distance)
        self.polygons = polygon_references

    def shape_details(self):
        return [each_point.coordinates() for each_point in self.points], self.scale, self.distance

    def rotate_x(self, angle):
        angle = angle * math.pi / 180
        for each_point in self.points:
            y = each_point.y * math.cos(angle) - each_point.z * math.sin(angle)
            z = each_point.z * math.cos(angle) + each_point.y * math.sin(angle)
            x = each_point.x
            each_point.x = x
            each_point.y = y
            each_point.z = z
            each_point.project(self.scale, self.distance)

    def rotate_y(self, angle):
        angle = angle * math.pi / 180
        for each_point in self.points:
            x = each_point.x * math.cos(angle) - each_point.z * math.sin(angle)
            z = each_point.z * math.cos(angle) + each_point.x * math.sin(angle)
            y = each_point.y
            each_point.x = x
            each_point.y = y
            each_point.z = z
            each_point.project(self.scale, self.distance)

    def rotate_z(self, angle):
        angle = angle * math.pi / 180
        for each_point in self.points:
            x = each_point.x * math.cos(angle) - each_point.y * math.sin(angle)
            y = each_point.y * math.cos(angle) + each_point.x * math.sin(angle)
            z = each_point.z
            each_point.x = x
            each_point.y = y
            each_point.z = z
            each_point.project(self.scale, self.distance)

    def translate_x(self, distance):
        for each_point in self.points:
            each_point.x += distance / self.scale
            each_point.project(self.scale, self.distance)

    def translate_y(self, distance):
        for each_point in self.points:
            each_point.y += distance / self.scale
            each_point.project(self.scale, self.distance)

    def translate_z(self, distance):
        for each_point in self.points:
            each_point.z += distance / self.scale
            each_point.project(self.scale, self.distance)


class Point:
    def __init__(self, coordinates):
        self.x, self.y, self.z = coordinates
        self.p_x, self.p_y = None, None

    def coordinates(self):
        return self.x, self.y, self.z

    def project(self, scale, distance):
        p_x = int(((self.x * distance) / (self.z + distance)) * scale)
        p_y = int(((self.y * distance) / (self.z + distance)) * scale)
        self.p_x, self.p_y = p_x, p_y


def main():
    coordinate_list = [[-0.882874981647, 0.0619377276454, -1.0172296094], [-0.885267403409, 0.0826732120202, -1.008889957], [-0.872664321894, 0.0831680587449, -1.0228108383], [-0.869513534328, 0.0599433155869, -1.0313346306], [-0.860334777645, 0.0817991658968, -1.0368828288], [-0.856164333315, 0.0572535992958, -1.0411191873], [-0.857710843634, 0.07800206439, -1.0348392537], [-0.849681193587, 0.0791114179411, -1.042906816], [-0.899060530638, 0.0630004089158, -1.0068004508], [-0.900607040957, 0.08374887401, -1.0005205172], [-0.889260031547, 0.0845784114367, -1.0135807851], [-0.909785797641, 0.0618930237011, -0.994972319], [-0.912323352259, 0.0845168468546, -0.98596164074], [-0.917550285131, 0.0606723277052, -0.97506124356], [-0.919329473946, 0.0808068920755, -0.9662347052], [-0.907953457141, 0.0825040997656, -0.98112874193], [-0.928723656, 0.0584194962775, -0.95916335974], [-0.931051563981, 0.0800735724598, -0.95066204859], [-0.931039194338, 0.055626959169, -0.93632055499], [-0.936159926332, 0.0751965065953, -0.9441754698], [-0.92842762997, 0.0762764709541, -0.94861847347], [-0.864320871826, 0.00151414891247, -0.7906100813], [-0.863699646177, -0.0194018217269, -0.78503115691], [-0.855006704751, -0.00947516340606, -0.77190977417], [-0.873040828332, 0.00832406982923, -0.8073723918], [-0.874700740461, -0.00984182443397, -0.80638361663], [-0.881709007272, 0.0197746264626, -0.82503720778], [-0.881855086717, 0.000240483077571, -0.82109998439], [-0.891257616309, 0.0286620421679, -0.8436985715], [-0.89055086158, 0.009648347016, -0.83837576178], [-0.899824695132, 0.0365503117929, -0.86042150585], [-0.898744567869, 0.0207656921257, -0.85513734148], [-0.906166178258, 0.0476853359604, -0.8739385495], [-0.907102479293, 0.0286664535158, -0.87149862273], [-0.914446758397, 0.0541553330859, -0.88985507976], [-0.918056536345, 0.0317759192974, -0.89138528584], [-0.921856993444, 0.0597695014526, -0.90406213474], [-0.923022730914, 0.0447802678725, -0.90288807518], [-0.928493494163, 0.0699777869658, -0.91789723832], [-0.930724325219, 0.0520476400482, -0.9179630131], [-0.936634630057, 0.0762567444858, -0.93746472801], [-0.934979994083, 0.0630119828857, -0.92778292885], [-0.670069478096, -0.0028197023566, -0.99821989737], [-0.684330402318, -0.0129491974714, -1.00456859], [-0.690535872605, 0.00776358382722, -1.0033535171], [-0.70768258595, -0.00384004579261, -1.010896216], [-0.708863536815, 0.0142222982463, -1.0084286827], [-0.723796303189, 0.00591607160274, -1.0147125734], [-0.728202885121, 0.0252844765288, -1.0131118413], [-0.742698994411, 0.014951749213, -1.0195711135], [-0.748614188175, 0.0337755400329, -1.0185584333], [-0.761051306203, 0.025698806927, -1.0239758164], [-0.766906114998, 0.0413088218944, -1.023451871], [-0.778946910869, 0.0332521792581, -1.0287337746], [-0.781718372965, 0.052135051752, -1.026666157], [-0.800663178942, 0.0359687955876, -1.0355294109], [-0.799121460498, 0.0582725339228, -1.0314842114], [-0.813288394821, 0.0486936527255, -1.0377149616], [-0.814654344708, 0.0635912982794, -1.0358104207], [-0.829777925839, 0.0556404788641, -1.0421014073], [-0.829807687186, 0.0734884477881, -1.0392850269], [-0.84055375907, 0.0663666521539, -1.04398899], [-0.995431803116, -0.0988726055141, -0.96122093484], [-0.991427501391, -0.086598373526, -0.96518596722], [-0.99086311955, -0.099250270452, -0.97144274709], [-0.984610024639, -0.0833475216008, -0.97893595288], [-0.984387960996, -0.0985872307503, -0.9854486295], [-0.979294957324, -0.0836533269992, -0.99075492777], [-0.976327608626, -0.0994506817839, -1.0035399693], [-0.970087702819, -0.075885639651, -1.0079591984], [-0.968298656439, -0.0977856848335, -1.020563459], [-0.962551210231, -0.0810844399933, -1.0266132196], [-0.961079754671, -0.0995774544198, -1.0371777586], [-0.955187636935, -0.0820323868618, -1.0432122095], [-0.947681885293, -0.0991751694398, -1.054370585], [-0.887943858097, -0.0954947760532, -1.0966019916], [-0.882289627889, -0.0826159120862, -1.0979076239], [-0.878815528447, -0.0946175516969, -1.1030369518], [-0.900444276595, -0.0955245309975, -1.0875317565], [-0.894549214507, -0.0800606038622, -1.0884582719], [-0.916599162272, -0.0972715250132, -1.0761751631], [-0.905101563749, -0.0809464548827, -1.0809807997], [-0.931787509806, -0.0964527961692, -1.0649644816], [-0.920418215748, -0.0740727325998, -1.068361941], [-0.937098570907, -0.0801559976951, -1.057565894], [-0.988874666357, -0.0927567148806, -0.93972792185], [-0.993893727904, -0.0839554484234, -0.9504248838], [-1.00012505164, -0.0968508537547, -0.95859130614], [-0.973864610231, -0.0853415823007, -0.91498734631], [-0.978207611268, -0.0744404618092, -0.92494816275], [-0.954348195943, -0.0787896237223, -0.88215290552], [-0.96058744161, -0.0622420150962, -0.89661517406], [-0.937236094641, -0.0695166701755, -0.85412080764], [-0.943016512768, -0.052542466438, -0.86790595957], [-0.919512009858, -0.0626983948513, -0.82448772724], [-0.926499080114, -0.0454679428487, -0.84044601894], [-0.902583692597, -0.0557951488849, -0.79626930864], [-0.911296392492, -0.0414352226136, -0.8146375137], [-0.889136828712, -0.0462283466093, -0.77473070024], [-0.895622491959, -0.0392970659661, -0.78759721457], [-0.878700746406, -0.0925122197722, -1.1076434873], [-0.869863133788, -0.0795206738792, -1.1026467645], [-0.858140902327, -0.0880775203141, -1.1001014345], [-0.842118083258, -0.0695660102258, -1.0918379033], [-0.831187254109, -0.0802270327376, -1.089888429], [-0.811276741325, -0.0568853549486, -1.0795877698], [-0.795399066203, -0.0730821487171, -1.0768496952], [-0.780002988885, -0.0466861599532, -1.0675471144], [-0.764865382811, -0.063319696953, -1.065144164], [-0.750080517998, -0.0391228553419, -1.0563935987], [-0.732570764718, -0.0559696745061, -1.0532349478], [-0.721943788857, -0.0346190753609, -1.046318633], [-0.70182082817, -0.0485624681946, -1.0418311325], [-0.692451764105, -0.0319758980243, -1.0360873494], [-0.678374563145, -0.0386307150819, -1.0324574732], [1.44066686028, 0.536004561763, 2.0330843676], [1.49555464667, 0.512673676645, 2.396029823], [1.46179423899, 0.876519151122, 2.4628768358], [1.45462365645, 0.814339809706, 2.31390466], [1.45814769352, 0.541667040831, 2.031169088], [1.47647909089, 0.539944412127, 2.0297304717], [1.50125369912, 0.463235125089, 2.3988617495], [1.51211449747, 0.484943797941, 2.0308303475], [1.51177952588, 0.456779288442, 2.032983559], [1.51065993425, 0.432810816245, 2.034888917], [1.50217843159, 0.392055625377, 2.0386901016], [1.50484552372, 0.516478897172, 2.0290727938], [1.51752075329, 0.400799310528, 2.2823372641], [1.48061867239, 0.348202227065, 2.0438419921], [1.4185455613, 0.47465062559, 2.0396068933], [1.42533224501, 0.447269371079, 2.041092132], [1.43192145678, 0.424149161848, 2.0422710021], [1.44954363089, 0.386265931008, 2.0436286239], [1.41839843016, 0.506969872391, 2.0371809568], [1.47770196544, 0.396416950044, 2.286068048], [0.609576626818, -0.297949626482, 0.23629786532], [0.78970360449, -0.251511684799, 0.43608707947], [0.766604321133, -0.284587851148, 0.41453875438], [0.570402301775, -0.299584125574, 0.28080119965], [0.44634273045, -0.348444759232, 0.097953160887], [0.517557636054, -0.258477573806, -0.0066382712937], [0.851072589612, -0.164152340178, 0.34970680309], [0.354917968587, -0.264411704491, 0.19114634247], [0.708730581619, -0.170092540623, 0.51141198859], [-0.891230035683, -0.228149146842, -0.76703904572], [-0.881415856967, -0.199428636793, -0.74670041689], [-1.00121736663, -0.240430709143, -0.96977882148], [-0.992628466379, -0.302017600759, -0.97364977675], [-0.877387540372, -0.25513307437, -0.75215289555], [-0.858332797756, -0.262494710667, -0.72557365915], [-0.786894414812, -0.277027116924, -0.66530047058], [-0.812338585618, -0.1106991853, -0.6687930509], [-0.857264357013, -0.196335679609, -0.71047022401], [-0.83923586094, -0.241917018977, -0.6932181999], [-0.862230613835, -0.244339000679, -0.75292199704], [-0.866446773442, -0.236182085369, -0.75883703887], [-0.172150081897, -0.13716144676, -0.76115563463], [-0.556252137481, -0.101354887995, -0.98021757134], [-0.177833059641, 0.0364113633152, -0.7900227653], [-0.543007397203, -0.268128985771, -0.961889158], [-0.884162979174, -0.236159510895, -1.1121276562], [-0.643415092128, -0.190744164869, -1.0361311144], [-0.664415054932, -0.219873288299, -1.0428667136], [-0.884484325754, -0.298072283463, -1.1051627815], [-0.646343759997, -0.246702896626, -1.0331231733], [-0.616373002987, -0.253665898915, -1.019818874], [-0.603301739537, -0.187068602116, -1.0193120291], [-0.581551885626, -0.232514478016, -1.0065854493], [-0.651337015296, -0.228333497746, -1.0204300534], [-0.644480429267, -0.23639357199, -1.0177261133], [-1.01183937089, -0.26330054045, -1.009457483], [-0.924456836133, -0.26011164037, -1.1157227147], [-0.84682838997, -0.029001211904, -0.73068413963], [-0.812687512341, -0.0234255287047, -0.68633939074], [-0.985144881005, -0.33314685381, -0.9943054936], [-0.749634382031, -0.350437125677, -0.69521838893], [-0.969626187802, -0.353561545357, -1.0208820336], [-0.701035497702, -0.398622859042, -0.74403342072], [-0.948447876328, -0.360156157659, -1.0493442016], [-0.648495793092, -0.41424898911, -0.80431467027], [-0.924831538396, -0.351927279019, -1.0753563712], [-0.600014208322, -0.394936661498, -0.86688454911], [-0.902374958482, -0.330126458819, -1.0949613269], [-0.562971568097, -0.343626415443, -0.9222173444], [-0.626026693791, -0.0209443743756, -0.9991991857], [-0.576094472112, -0.0147927839057, -0.97405809226], [-0.206801202185, 0.161171501358, -0.7806983012], [-0.198505764326, -0.246832840757, -0.7023884192], [-0.248255279666, -0.349747161872, -0.62107402898], [-0.312360995733, -0.424461373255, -0.52821492152], [-0.393208228783, -0.355036319486, -0.44479799954], [-0.466343571382, -0.256605933379, -0.376673172], [-0.522096931915, -0.149930752681, -0.33558825806], [-0.556612848669, 0.0225903937068, -0.32939198622], [-0.55674834781, 0.148402811488, -0.35513069422], [-1.02323831705, -0.286449947823, -1.0441843314], [-1.025716752, -0.31384017324, -1.0686474002], [-1.02409664429, -0.334931109784, -1.0913078845], [-1.01458167262, -0.341553178416, -1.1031686093], [-1.00498818732, -0.334233970934, -1.1145454922], [-0.983700468628, -0.312307649252, -1.1197429161], [-0.960037420049, -0.284143514646, -1.12104246], [0.215772492998, 0.128702244768, -0.51055820561], [0.380675391732, 0.339312981069, -0.3931669798], [0.591708802861, 0.237302500493, -0.19832783823], [0.559187593501, 0.376483504216, -0.18767820393], [0.183337566334, 0.26774504265, -0.49998439672], [0.557951555267, 0.410254685423, -0.24944743688], [0.0318310575329, 0.200420429624, -0.60766094989], [-0.12652016126, 0.162208794159, -0.72276990777], [-0.0977395433737, 0.0473760464076, -0.75294904858], [-0.0940400497089, -0.115407312445, -0.72395669808], [-0.112983779855, -0.221967993032, -0.65069716641], [-0.095570743751, 0.0521361015152, -0.73143275239], [-0.0511146711275, 0.178836379959, -0.66831885836], [-0.0188568509122, 0.0616891366612, -0.69664150964], [-0.0918706887312, -0.11064795681, -0.70244093632], [-0.0154952553732, -0.0985520824187, -0.66831093737], [-0.0391039993375, -0.216584034342, -0.59410497598], [-0.0166875101334, 0.0664487470574, -0.6751259341], [0.0583251547816, 0.0792745644144, -0.64212706129], [-0.013325970786, -0.0937927397969, -0.64679523883], [0.0637584291355, -0.0815444199503, -0.61216330528], [0.0371528264207, -0.214028184625, -0.53387033162], [0.0604938891052, 0.0840346944654, -0.62061087564], [0.111262117655, 0.21354170143, -0.55131972542], [0.138494252725, 0.0904506914182, -0.58435842706], [0.143521695563, -0.0711175930893, -0.55457589306], [0.0659271114544, -0.0767846430292, -0.59064693662], [0.116897964421, -0.208017351927, -0.47290609591], [0.140663071077, 0.0952108357838, -0.56284217189], [0.213517608214, 0.134959990557, -0.5297329944], [0.145690438995, -0.066357805756, -0.53305947383], [0.213175565783, -0.0277557408447, -0.5037552537], [0.191004275662, -0.19549684948, -0.41387721086], [-0.484428263443, 0.149149477905, -0.28752102129], [-0.34201322477, 0.186779701154, -0.15303222882], [-0.505071796272, 0.0325137899086, -0.2575959796], [-0.471135917906, -0.129167535752, -0.26537515892], [-0.399826910808, -0.232434579579, -0.3018697066], [-0.435002847704, 0.0465053231641, -0.1905702904], [-0.416920943898, 0.165489014362, -0.22346510477], [-0.483692154451, 0.0379748445154, -0.25944182662], [-0.401855734684, -0.112649843361, -0.19846146717], [-0.449756893632, -0.123706049448, -0.26722034846], [-0.330184970935, -0.227203803951, -0.24012437163], [-0.367117519402, 0.0637520090459, -0.1247503166], [-0.413624087125, 0.0519659038723, -0.1924151331], [-0.331950832389, -0.0959828806953, -0.13094493364], [-0.380476169254, -0.107188801768, -0.20030737739], [-0.256426762067, -0.224740552256, -0.17685088716], [-0.295274623105, 0.0746244260764, -0.056856139294], [-0.271769642913, 0.199566337064, -0.085518315748], [-0.345738156555, 0.0692121554548, -0.1265958293], [-0.31057125932, -0.0905218378009, -0.13279083755], [-0.260341619461, -0.0858526763683, -0.063441492149], [-0.181379814591, -0.218900769136, -0.1101731429], [-0.228490570772, 0.118832741716, 0.0077891090408], [-0.209068725963, 0.253427115849, -0.022782597634], [-0.273895168589, 0.0800845881007, -0.058701576175], [-0.109514777517, -0.206461362861, -0.048418804777], [-0.198294789875, -0.042768677966, -0.0033699383162], [-0.238962164945, -0.0803925143443, -0.065286929029], [0.873826247139, 0.421575299929, 0.20895759056], [0.901413122352, 0.29917296981, 0.20189289783], [0.59836919117, 0.0400985408452, -0.16577676506], [0.908141210901, 0.126137363831, 0.22831049899], [0.571664976219, -0.128263313925, -0.098839993805], [0.887223255842, -0.0216674133177, 0.2809366916], [0.27114592304, -0.139227827307, 0.26661841228], [0.639989359175, -0.0319851002531, 0.56180153922], [0.205722148133, 0.0257722521895, 0.31171772185], [0.585112506533, 0.112655905339, 0.59527633992], [0.166709892986, 0.221795371524, 0.31850954861], [0.551773777109, 0.28458213545, 0.59909654008], [0.166761339048, 0.36216561216, 0.28954771384], [0.55079747546, 0.40809419555, 0.57592343995], [-0.209066452766, 0.113201508851, 0.0060845357522], [-0.174938552425, -0.0414612833652, -0.0033194952018], [-0.0257429192741, -0.331646132628, -0.12389046444], [0.0656821534021, -0.415678381125, -0.21708418766], [0.136896935497, -0.325711109359, -0.32167548835], [0.217708490613, -0.0271349947095, -0.48081398212], [-0.0682172785276, 0.322933705033, 0.15272746291], [0.104955880052, 0.393726293275, 0.3014365117], [1.3954248477, 0.531834942552, 1.83342812], [1.34463861259, 0.583155286769, 1.828851947], [1.35862488995, 0.505684463308, 1.737686726], [1.2209843541, 0.562519923657, 1.4835035273], [1.18742271187, 0.610091178509, 1.49174222], [1.17616431919, 0.563892487738, 1.4370683322], [1.26980824818, 0.506550717413, 1.4741477141], [1.18390735247, 0.47897581701, 1.3519122472], [1.48085807062, 0.517572390397, 1.7024347398], [1.52680217045, 0.600872496416, 1.7763237394], [1.49617975489, 0.541634593781, 1.8043766259], [1.44902882609, 0.586773767125, 1.3025412055], [1.47919868233, 0.634556025369, 1.347876476], [1.45895002445, 0.582473048345, 1.3661746464], [1.38860272857, 0.496139854984, 1.2509871569], [1.42979231106, 0.519965633984, 1.3952662964], [1.466515789, 0.170936449185, 1.7673554924], [1.437742819, 0.23687907145, 1.6898302852], [1.46885208995, 0.277625059332, 1.8114356109], [1.47857950368, 0.178480122275, 1.8117378825], [1.48729775621, 0.141840504679, 1.8296125518], [0.810629099771, 0.319516268533, 0.8429661704], [0.810667877551, 0.425563460368, 0.82467750669], [0.839957340929, 0.173390721806, 0.84119661861], [0.88938563556, 0.0508743202347, 0.81693452883], [0.953061783351, -0.0438722219187, 0.77481402948], [1.02312995863, -0.112150736969, 0.72228765921], [1.07653470099, -0.0370287820835, 0.66036101604], [1.11753553566, 0.063520611413, 0.60545339337], [1.13805304722, 0.189914346748, 0.56488623647], [1.13327848851, 0.337399443478, 0.54388356548], [1.10876351266, 0.442086746129, 0.5483672804], [0.984474002919, 0.352415212835, 1.0855303435], [0.986076460419, 0.441857241056, 1.0725043115], [1.01054214248, 0.231215377326, 1.0863028987], [1.05640903985, 0.13028078091, 1.0725018322], [1.11670364802, 0.0511422035519, 1.0471391127], [1.18398686965, -0.00917398917632, 1.0150555632], [1.23619948202, 0.0602612724115, 0.97447259073], [1.27720476345, 0.147130077124, 0.93822884986], [1.2990252312, 0.253230113663, 0.91086515911], [1.29672768882, 0.376244208811, 0.89564071212], [1.27455938056, 0.46387117407, 0.89706694101], [1.41206728031, 0.484016847668, 1.2603577351], [1.42975887758, 0.415287441537, 1.2601823467], [1.43107386458, 0.320375451773, 1.2710775389], [1.41298156633, 0.238303144173, 1.2897954462], [1.37977102764, 0.168293135932, 1.3143501062], [1.33815911536, 0.10659601419, 1.341936226], [1.28316322133, 0.160191659721, 1.3619770998], [1.2344789545, 0.223335113145, 1.3778033057], [1.19785421344, 0.300819511138, 1.3860693347], [1.17731699465, 0.394119510756, 1.38464106], [1.17884762918, 0.464460907032, 1.3753495309], [1.31879580254, 0.483243897234, 1.6988871149], [1.3168300966, 0.43604789876, 1.7040500044], [1.33109127134, 0.377387896621, 1.7058208787], [1.35789256726, 0.329088663106, 1.7030705064], [1.39474252056, 0.28492490187, 1.6971173385], [1.46874542126, 0.292122897459, 1.6757779496], [1.49462806481, 0.342387436178, 1.6636385867], [1.50973663441, 0.394761448857, 1.6542930227], [1.51020457947, 0.454854752333, 1.648284977], [1.49744135291, 0.500618342054, 1.6473588488], [1.49287689911, 0.531098930128, 2.0289942933], [1.42671158342, 0.523820613115, 2.035198128], [-0.806998022768, 0.167612186208, -0.86290414067], [-0.822434485461, 0.0145514516282, -0.8341651454], [-0.777991776197, 0.147577025961, -0.70928643849], [-0.742033511083, 0.197151709942, -0.76295136046], [-0.724062218644, 0.0181406761513, -0.953794755], [-0.5969109636, 0.154183697419, -0.92949709664], [-0.753759200842, 0.169554548811, -0.92764735916], [-0.64403336132, 0.200727477376, -0.88212846745], [-0.789560951531, 0.176898322513, -0.90257650589], [-0.694993555776, 0.215815759766, -0.82364544771], [-0.473488408466, 0.317768861686, -0.49062627118], [-0.403717878753, 0.343708948976, -0.58029005577], [-0.328535478079, 0.323057930042, -0.66690225961], [-0.259387670326, 0.258958841683, -0.73727602058], [-0.527225593287, 0.249186546548, -0.41156079773], [-0.892345710263, 0.107240858643, -0.96602898307], [-0.927142186717, 0.0845011286096, -0.96957856642], [-0.878364201314, 0.0867345738405, -1.0219706484], [-0.869634749825, 0.108069137938, -0.99364750023], [-0.880661525071, 0.11021583927, -0.97949072682], [0.500291528485, 0.48621426609, -0.13908920853], [0.36086145443, 0.409279359354, -0.38362506557], [0.124576348172, 0.377251143323, -0.45151212077], [0.260093502199, 0.551993501911, 0.1376663413], [0.626472684658, 0.57506845777, 0.45776023413], [0.690709268183, 0.600790323946, 0.38025620223], [0.338377127824, 0.581098350945, 0.037062241452], [0.4227329844, 0.557927762105, -0.060118075227], [0.760273136321, 0.580651846712, 0.30575552969], [0.824574109867, 0.517720166773, 0.24560312296], [0.199778000125, 0.475249421707, 0.22636258851], [0.577340213201, 0.507402479836, 0.52646797051], [-0.115763657997, 0.443399225158, -0.17466091566], [-0.176133993767, 0.366279105301, -0.085820977927], [0.0468763668292, 0.449332696623, -0.37244582561], [-0.0374793024422, 0.472504178045, -0.27526591907], [-0.0647549311026, 0.393750050267, 0.13396315585], [0.83597937713, 0.51068112416, 0.7868144227], [0.881858676946, 0.569159862636, 0.73465654481], [1.06412957922, 0.52332689718, 0.57533302895], [1.00533169573, 0.576003784466, 0.62020330989], [0.941331902865, 0.592099200707, 0.67615492471], [1.01188433541, 0.513624022004, 1.0473901117], [1.05716877511, 0.563718404752, 1.0135616702], [1.2326801714, 0.530473853767, 0.91311688333], [1.17666460911, 0.572837473612, 0.94089514821], [1.11503124471, 0.584511079744, 0.9761650154], [1.2368263116, 0.559135073669, 1.3358437831], [1.28367356292, 0.575695897933, 1.3112072573], [1.3334341179, 0.56723654988, 1.2882167895], [1.37851539669, 0.535042557219, 1.2703573318], [1.2000134024, 0.520074094495, 1.3583645339], [1.36459900434, 0.544453981148, 1.6801158813], [1.3358432702, 0.518924077476, 1.6906351933], [1.47257876775, 0.532222850548, 1.6512032737], [1.43860171773, 0.551651084155, 1.6587769025], [1.40068365259, 0.555945496838, 1.6689292899], [1.49633963525, 0.272123087274, 2.1222367159], [1.5173144433, 0.147619043362, 2.1998533056], [1.55316442307, -0.0731694874502, 2.3231870062], [1.59710856066, -0.311398347677, 2.5122987947], [1.62020684094, -0.3978732492, 2.6571533], [1.60628761315, -0.284991515849, 2.6411321414], [1.56863147518, -0.0446132293555, 2.5215487995], [0.530890811608, -0.484665251345, 0.16339015092], [0.617825801639, -0.620070433033, 0.27124890693], [0.682890061705, -0.680979205082, 0.32628575523], [0.784975028488, -0.75321199996, 0.41349348923], [0.862151351822, -0.7921296365, 0.4800033908], [0.839759862991, -0.697157470464, 0.46378069906], [0.834497665387, -0.561662041651, 0.46412494356], [0.812780325369, -0.375660782679, 0.45184050101], [0.830602034671, -0.342401110929, 0.46874961485], [0.822143564453, -0.305444742435, 0.46266213834], [-0.866140173973, -0.225875892249, -0.7600352843], [-0.861391235358, -0.21618000929, -0.75619787154], [-0.853473332192, -0.209694281457, -0.74835148862], [-0.844508046667, -0.208154421225, -0.7385994441], [-0.836897547821, -0.211975347397, -0.72955374821], [-0.832681200909, -0.220131370124, -0.72363911652], [-0.832987987682, -0.230438455826, -0.72244046095], [-0.837737502898, -0.240133576335, -0.72627891592], [-0.84565559337, -0.246620196751, -0.7341248887], [-0.854619927685, -0.248159034269, -0.74387671122], [-0.652756456918, -0.218089873993, -1.0195293599], [-0.648358801032, -0.208407376098, -1.0152646385], [-0.639322113421, -0.201879805085, -1.0087790097], [-0.62806818028, -0.200257165585, -1.0018100194], [-0.617611927539, -0.203973304665, -0.99622521561], [-0.610755837588, -0.212034055643, -0.9935205366], [-0.609336334212, -0.222277722565, -0.9944212958], [-0.613734815758, -0.231960307423, -0.99868658355], [-0.622771194596, -0.238488094284, -1.005172541], [-0.634024116812, -0.240110776331, -1.012141162], [-0.956828158542, -0.106087269016, -1.047430877], [-0.878607143853, -0.0968333492875, -1.1069935403], [-0.999737126269, -0.101441253855, -0.958858653], [0.675974766251, 0.569890643921, -0.65196358131], [0.489974558199, 0.473450011857, -0.62784955133], [0.892605889893, 0.671781321109, -0.6780210361], [1.05137564162, 0.737944851098, -0.66033505749], [1.10370710844, 0.746132324679, -0.61426547911], [1.0137504157, 0.699583284204, -0.53614595487], [0.900601145417, 0.608806490066, -0.46864963366], [0.741872264579, 0.50225040369, -0.36421603122], [0.697047904131, 0.478857426313, -0.31832904435], [0.624966862491, 0.429163022572, -0.22331110136], [0.143004370225, 0.411577375593, 0.36279920311], [0.0623204054533, 0.455697628096, 0.45355745283], [0.0253126046218, 0.476104517484, 0.50718587757], [-0.0594940682377, 0.573773684078, 0.69891388253], [-0.1014479848, 0.658894397646, 0.82003649754], [-0.164872157381, 0.699845362463, 0.92844240575], [-0.212071408998, 0.691845295922, 0.87612997413], [-0.263210439433, 0.62960795267, 0.72755701924], [-0.281606184135, 0.534950757021, 0.51254211879], [-0.281139626205, 0.445314590435, 0.30989541835]]
    polygons = [[0, 1, 2], [3, 2, 4], [5, 6, 7], [8, 9, 10], [11, 12, 9], [13, 14, 15], [16, 17, 14], [18, 19, 20], [21, 22, 23], [24, 25, 21], [26, 27, 24], [28, 29, 26], [30, 31, 28], [32, 33, 30], [34, 35, 32], [36, 37, 34], [38, 39, 36], [40, 41, 38], [42, 43, 44], [44, 45, 46], [46, 47, 48], [48, 49, 50], [50, 51, 52], [52, 53, 54], [54, 55, 56], [56, 57, 58], [58, 59, 60], [60, 61, 7], [62, 63, 64], [64, 65, 66], [66, 67, 68], [68, 69, 70], [70, 71, 72], [72, 73, 74], [75, 76, 77], [78, 79, 75], [80, 81, 78], [82, 83, 80], [74, 84, 82], [85, 86, 87], [88, 89, 85], [90, 91, 88], [92, 93, 90], [94, 95, 92], [96, 97, 94], [98, 99, 96], [100, 101, 102], [102, 103, 104], [104, 105, 106], [106, 107, 108], [108, 109, 110], [110, 111, 112], [112, 113, 114], [115, 116, 117], [115, 117, 118], [118, 119, 115], [120, 117, 116], [120, 118, 117], [120, 119, 118], [121, 122, 116], [121, 123, 122], [121, 124, 123], [121, 125, 124], [116, 122, 126], [127, 125, 121], [127, 125, 121], [127, 128, 125], [116, 129, 121], [129, 130, 121], [130, 131, 121], [131, 132, 121], [133, 129, 116], [134, 132, 121], [121, 132, 134], [132, 128, 134], [135, 136, 137], [137, 136, 138], [139, 140, 135], [136, 135, 141], [141, 135, 140], [138, 142, 139], [143, 138, 136], [142, 138, 143], [144, 145, 146], [144, 146, 147], [148, 144, 147], [149, 148, 147], [149, 147, 150], [146, 145, 151], [151, 145, 152], [151, 152, 153], [151, 153, 150], [153, 149, 150], [154, 155, 148], [156, 157, 158], [159, 157, 156], [160, 161, 162], [163, 160, 162], [163, 162, 164], [163, 164, 165], [159, 163, 165], [157, 161, 160], [166, 161, 157], [167, 166, 157], [159, 167, 157], [159, 165, 167], [164, 168, 169], [170, 146, 160], [170, 160, 171], [172, 146, 151], [172, 151, 173], [147, 174, 175], [147, 175, 150], [174, 176, 177], [174, 177, 175], [176, 178, 179], [176, 179, 177], [178, 180, 181], [178, 181, 179], [180, 182, 183], [180, 183, 181], [182, 163, 159], [182, 159, 183], [160, 184, 185], [160, 185, 157], [157, 185, 186], [157, 186, 158], [183, 159, 156], [183, 156, 187], [181, 183, 187], [181, 187, 188], [179, 181, 188], [179, 188, 189], [177, 179, 189], [177, 189, 190], [175, 177, 190], [175, 190, 191], [150, 175, 191], [150, 191, 192], [151, 150, 192], [151, 192, 193], [173, 151, 193], [173, 193, 194], [170, 195, 147], [170, 147, 146], [195, 196, 174], [195, 174, 147], [196, 197, 176], [196, 176, 174], [197, 198, 178], [197, 178, 176], [198, 199, 180], [198, 180, 178], [199, 200, 182], [199, 182, 180], [200, 201, 163], [200, 163, 182], [201, 171, 160], [201, 160, 163], [201, 195, 170], [201, 170, 171], [196, 195, 201], [196, 201, 200], [197, 196, 200], [197, 200, 199], [198, 197, 199], [202, 203, 204], [204, 203, 205], [203, 202, 206], [207, 205, 203], [208, 209, 186], [158, 186, 209], [158, 209, 210], [156, 158, 210], [156, 210, 211], [187, 156, 211], [187, 211, 212], [213, 209, 214], [213, 214, 215], [216, 213, 215], [216, 215, 217], [212, 216, 217], [212, 217, 218], [219, 214, 208], [219, 208, 220], [221, 219, 220], [221, 220, 222], [218, 221, 222], [218, 222, 223], [224, 208, 225], [224, 225, 226], [224, 226, 227], [224, 227, 228], [228, 227, 229], [228, 229, 223], [230, 225, 206], [230, 206, 231], [232, 233, 234], [232, 234, 229], [230, 231, 233], [230, 233, 232], [187, 229, 234], [187, 223, 229], [187, 218, 223], [187, 212, 218], [206, 208, 186], [206, 225, 208], [194, 235, 236], [237, 235, 194], [237, 194, 193], [238, 237, 193], [238, 193, 192], [239, 238, 192], [239, 192, 191], [240, 241, 235], [240, 235, 242], [243, 240, 242], [243, 242, 244], [245, 243, 244], [245, 244, 239], [246, 236, 241], [246, 241, 247], [248, 246, 247], [248, 247, 249], [250, 248, 249], [250, 249, 245], [251, 252, 236], [251, 236, 253], [254, 255, 251], [254, 251, 253], [250, 256, 255], [250, 255, 254], [257, 258, 252], [257, 252, 259], [256, 260, 261], [256, 261, 262], [262, 261, 257], [262, 257, 259], [260, 256, 191], [256, 250, 191], [250, 245, 191], [245, 239, 191], [194, 236, 258], [236, 252, 258], [204, 205, 263], [204, 263, 264], [265, 204, 264], [265, 264, 266], [267, 265, 266], [267, 266, 268], [140, 267, 268], [140, 268, 141], [269, 142, 143], [269, 143, 270], [271, 269, 270], [271, 270, 272], [273, 271, 272], [273, 272, 274], [275, 273, 274], [275, 274, 276], [277, 278, 271], [277, 271, 273], [278, 260, 269], [278, 269, 271], [260, 279, 142], [260, 142, 269], [279, 280, 139], [279, 139, 142], [280, 281, 140], [280, 140, 139], [281, 234, 267], [281, 267, 140], [234, 282, 265], [234, 265, 267], [282, 202, 204], [282, 204, 265], [188, 187, 234], [188, 234, 281], [189, 188, 281], [189, 281, 280], [190, 189, 280], [190, 280, 279], [191, 190, 279], [191, 279, 260], [235, 241, 236], [214, 209, 208], [273, 283, 277], [275, 283, 273], [258, 277, 283], [283, 275, 284], [285, 286, 287], [288, 289, 290], [291, 288, 290], [291, 290, 292], [293, 294, 295], [296, 297, 298], [299, 296, 298], [299, 298, 300], [301, 302, 303], [301, 303, 304], [305, 301, 304], [276, 274, 306], [276, 306, 307], [274, 272, 308], [274, 308, 306], [272, 270, 309], [272, 309, 308], [270, 143, 310], [270, 310, 309], [143, 136, 311], [143, 311, 310], [136, 141, 312], [136, 312, 311], [141, 268, 313], [141, 313, 312], [268, 266, 314], [268, 314, 313], [266, 264, 315], [266, 315, 314], [264, 263, 316], [264, 316, 315], [307, 306, 317], [307, 317, 318], [306, 308, 319], [306, 319, 317], [308, 309, 320], [308, 320, 319], [309, 310, 321], [309, 321, 320], [310, 311, 322], [310, 322, 321], [311, 312, 323], [311, 323, 322], [312, 313, 324], [312, 324, 323], [313, 314, 325], [313, 325, 324], [314, 315, 326], [314, 326, 325], [315, 316, 327], [315, 327, 326], [326, 327, 328], [326, 328, 329], [325, 326, 329], [325, 329, 330], [324, 325, 330], [324, 330, 331], [323, 324, 331], [323, 331, 332], [322, 323, 332], [322, 332, 333], [321, 322, 333], [321, 333, 334], [320, 321, 334], [320, 334, 335], [319, 320, 335], [319, 335, 336], [317, 319, 336], [317, 336, 337], [318, 317, 337], [318, 337, 338], [339, 340, 129], [339, 129, 133], [340, 341, 130], [340, 130, 129], [341, 342, 131], [341, 131, 130], [342, 343, 132], [342, 132, 131], [343, 302, 128], [343, 128, 132], [302, 344, 125], [302, 125, 128], [344, 345, 124], [344, 124, 125], [345, 346, 123], [345, 123, 124], [346, 347, 122], [346, 122, 123], [347, 348, 126], [347, 126, 122], [329, 328, 348], [329, 348, 347], [330, 329, 347], [330, 347, 346], [331, 330, 346], [331, 346, 345], [332, 331, 345], [332, 345, 344], [333, 332, 344], [333, 344, 302], [334, 333, 302], [334, 302, 343], [335, 334, 343], [335, 343, 342], [336, 335, 342], [336, 342, 341], [337, 336, 341], [337, 341, 340], [338, 337, 340], [338, 340, 339], [116, 126, 349], [116, 349, 120], [350, 133, 116], [115, 350, 116], [351, 352, 353], [351, 353, 354], [352, 172, 173], [352, 173, 353], [184, 355, 356], [184, 356, 185], [355, 357, 358], [355, 358, 356], [357, 359, 360], [357, 360, 358], [359, 351, 354], [359, 354, 360], [360, 354, 361], [360, 361, 362], [358, 360, 362], [358, 362, 363], [356, 358, 363], [356, 363, 364], [185, 356, 364], [185, 364, 186], [353, 173, 194], [353, 194, 365], [354, 353, 365], [354, 365, 361], [366, 367, 352], [366, 352, 351], [367, 40, 172], [367, 172, 352], [7, 368, 355], [7, 355, 184], [368, 369, 357], [368, 357, 355], [369, 370, 359], [369, 359, 357], [370, 366, 351], [370, 351, 359], [367, 366, 370], [367, 370, 369], [367, 369, 368], [371, 372, 373], [206, 373, 372], [205, 372, 371], [374, 375, 376], [374, 376, 377], [186, 364, 373], [186, 373, 206], [378, 377, 376], [378, 376, 379], [371, 378, 379], [371, 379, 380], [205, 371, 380], [205, 380, 263], [381, 275, 276], [381, 276, 382], [374, 381, 382], [374, 382, 375], [383, 384, 381], [383, 381, 374], [373, 385, 378], [373, 378, 371], [385, 386, 377], [385, 377, 378], [386, 383, 374], [386, 374, 377], [362, 361, 383], [362, 383, 386], [363, 362, 386], [363, 386, 385], [364, 363, 385], [364, 385, 373], [365, 194, 258], [365, 258, 384], [361, 365, 384], [361, 384, 383], [384, 387, 381], [381, 387, 275], [387, 384, 258], [98, 172, 23], [114, 42, 184], [375, 382, 388], [375, 388, 389], [382, 276, 307], [382, 307, 388], [263, 380, 390], [263, 390, 316], [380, 379, 391], [380, 391, 390], [379, 376, 392], [379, 392, 391], [376, 375, 389], [376, 389, 392], [389, 388, 393], [389, 393, 394], [388, 307, 318], [388, 318, 393], [316, 390, 395], [316, 395, 327], [390, 391, 396], [390, 396, 395], [391, 392, 397], [391, 397, 396], [392, 389, 394], [392, 394, 397], [397, 394, 398], [397, 398, 399], [396, 397, 399], [396, 399, 400], [395, 396, 400], [395, 400, 401], [327, 395, 401], [327, 401, 328], [393, 318, 338], [393, 338, 402], [394, 393, 402], [394, 402, 398], [403, 404, 350], [403, 350, 115], [404, 339, 133], [404, 133, 350], [348, 405, 349], [348, 349, 126], [405, 406, 120], [405, 120, 349], [406, 407, 119], [406, 119, 120], [407, 403, 115], [407, 115, 119], [399, 398, 403], [399, 403, 407], [400, 399, 407], [400, 407, 406], [401, 400, 406], [401, 406, 405], [328, 401, 405], [328, 405, 348], [402, 338, 339], [402, 339, 404], [398, 402, 404], [398, 404, 403], [127, 408, 128], [127, 409, 408], [127, 410, 409], [127, 411, 410], [127, 412, 411], [127, 413, 412], [127, 414, 413], [127, 121, 414], [128, 408, 134], [408, 409, 134], [409, 410, 134], [410, 411, 134], [411, 412, 134], [412, 413, 134], [413, 414, 134], [414, 121, 134], [415, 139, 135], [416, 415, 135], [417, 416, 135], [418, 417, 135], [419, 418, 135], [420, 419, 135], [421, 420, 135], [422, 421, 135], [423, 422, 135], [424, 423, 135], [135, 137, 424], [138, 139, 415], [138, 415, 416], [138, 416, 417], [138, 417, 418], [138, 418, 419], [138, 419, 420], [138, 420, 421], [138, 421, 422], [138, 422, 423], [138, 423, 424], [424, 137, 138], [155, 425, 144], [425, 426, 144], [426, 427, 145], [427, 428, 145], [428, 429, 152], [429, 430, 152], [430, 431, 153], [431, 432, 153], [432, 433, 149], [433, 434, 149], [434, 154, 148], [144, 426, 145], [145, 428, 152], [152, 430, 153], [153, 432, 149], [149, 434, 148], [155, 144, 148], [162, 435, 168], [162, 436, 435], [161, 437, 436], [161, 438, 437], [166, 439, 438], [166, 440, 439], [167, 441, 440], [167, 442, 441], [165, 443, 442], [165, 444, 443], [164, 169, 444], [161, 436, 162], [166, 438, 161], [167, 440, 166], [165, 442, 167], [164, 444, 165], [164, 162, 168], [160, 445, 446], [146, 445, 160], [146, 447, 445], [146, 172, 447], [160, 446, 184], [40, 367, 368], [40, 368, 7], [445, 447, 446], [40, 7, 184], [40, 184, 172], [184, 446, 447], [184, 447, 172], [233, 231, 202], [233, 202, 282], [233, 282, 234], [227, 232, 229], [226, 225, 230], [226, 230, 232], [226, 232, 227], [222, 220, 224], [222, 224, 228], [220, 208, 224], [217, 221, 218], [217, 215, 219], [217, 219, 221], [215, 214, 219], [210, 209, 213], [222, 228, 223], [211, 216, 212], [211, 210, 213], [211, 213, 216], [231, 206, 202], [278, 277, 257], [278, 257, 261], [260, 278, 261], [256, 262, 255], [259, 252, 251], [255, 262, 259], [255, 259, 251], [254, 253, 246], [254, 246, 248], [253, 236, 246], [245, 249, 243], [249, 247, 240], [249, 240, 243], [247, 241, 240], [242, 235, 237], [250, 254, 248], [239, 244, 238], [244, 242, 237], [244, 237, 238], [277, 258, 257], [448, 449, 372], [449, 206, 372], [450, 448, 372], [451, 450, 372], [452, 451, 372], [453, 452, 372], [454, 453, 372], [455, 454, 372], [456, 455, 372], [457, 456, 372], [372, 205, 207], [372, 207, 457], [457, 207, 203], [203, 456, 457], [203, 455, 456], [203, 454, 455], [203, 453, 454], [203, 452, 453], [203, 451, 452], [203, 450, 451], [203, 448, 450], [203, 449, 448], [203, 206, 449], [430, 429, 428], [430, 428, 427], [430, 427, 426], [430, 426, 425], [430, 425, 155], [430, 155, 154], [430, 154, 434], [430, 434, 433], [430, 433, 432], [430, 432, 431], [441, 442, 443], [441, 443, 444], [441, 444, 169], [441, 169, 168], [441, 168, 435], [441, 435, 436], [441, 436, 437], [441, 437, 438], [441, 438, 439], [441, 439, 440], [458, 284, 387], [284, 275, 387], [387, 459, 458], [387, 460, 459], [387, 461, 460], [387, 462, 461], [387, 463, 462], [387, 464, 463], [387, 465, 464], [387, 466, 465], [387, 467, 466], [387, 258, 467], [283, 284, 458], [458, 459, 283], [459, 460, 283], [460, 461, 283], [461, 462, 283], [462, 463, 283], [463, 464, 283], [464, 465, 283], [465, 466, 283], [466, 467, 283], [467, 258, 28]]
    point_list = [Point(each_coordinate) for each_coordinate in coordinate_list]
    my_shape = Shape(points=point_list, polygon_references=polygons, scale=100, distance=10)
    screen = Engine_3d(500, 500, fps=60, pfc='grey', frame_adjust=1)

    def activity():
        # screen.shape.rotate_x(1)
        screen.shape.rotate_y(1)


    screen.activity = activity

    screen.load_data(my_shape)
    screen.shape.rotate_z(180)
    screen.mainloop()
    print('Done...')
    print(len(polygons))


if __name__ == '__main__':
    cProfile.run('main()')
this is the cProfile output for a ~13 sec run.
Output:
Frames per second 8 Frames per second 7 Frames per second 7 Frames per second 8 Frames per second 7 Frames per second 8 Frames per second 8 Frames per second 8 Frames per second 8 Frames per second 8 Done... 734 887439 function calls (887438 primitive calls) in 12.326 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.000 0.000 <frozen importlib._bootstrap>:1017(_handle_fromlist) 1 0.000 0.000 12.325 12.325 <string>:1(<module>) 737 0.002 0.000 0.003 0.000 __init__.py:101(_cnfmerge) 83 0.112 0.001 0.220 0.003 __init__.py:111(rotate_y) 1 0.002 0.002 0.005 0.005 __init__.py:122(rotate_z) 1 0.000 0.000 0.424 0.424 __init__.py:1303(update) 1 0.000 0.000 11.634 11.634 __init__.py:1418(mainloop) 736 0.003 0.000 0.008 0.000 __init__.py:1459(_options) 468 0.002 0.000 0.002 0.000 __init__.py:150(__init__) 84 0.001 0.000 0.003 0.000 __init__.py:1504(_register) 39780 0.060 0.000 0.060 0.000 __init__.py:157(project) 1 0.000 0.000 12.325 12.325 __init__.py:163(main) 1 0.000 0.000 0.002 0.002 __init__.py:166(<listcomp>) 83 0.000 0.000 0.221 0.003 __init__.py:170(activity) 84 0.000 0.000 0.000 0.000 __init__.py:1872(__init__) 83 0.001 0.000 1.357 0.016 __init__.py:1878(__call__) 1 0.000 0.000 0.000 0.000 __init__.py:2180(wm_protocol) 1 0.000 0.000 0.000 0.000 __init__.py:2215(wm_title) 1 0.000 0.000 0.203 0.203 __init__.py:2241(__init__) 1 0.000 0.000 0.000 0.000 __init__.py:2273(_loadtk) 1 0.000 0.000 0.009 0.009 __init__.py:2299(destroy) 1 0.000 0.000 0.001 0.001 __init__.py:2309(readprofile) 1 0.000 0.000 0.000 0.000 __init__.py:2371(pack_configure) 1 0.000 0.000 0.000 0.000 __init__.py:2521(_setup) 1 0.000 0.000 0.000 0.000 __init__.py:2555(__init__) 1 0.000 0.000 0.000 0.000 __init__.py:2564(<listcomp>) 1 0.000 0.000 0.001 0.001 __init__.py:2572(destroy) 1 0.000 0.000 0.000 0.000 __init__.py:2673(__init__) 60922 0.114 0.000 0.373 0.000 __init__.py:2756(coords) 60922 0.015 0.000 0.015 0.000 __init__.py:2759(<listcomp>) 734 0.003 0.000 0.020 0.000 __init__.py:2763(_create) 734 0.001 0.000 0.021 0.000 __init__.py:2795(create_polygon) 60922 0.049 0.000 0.207 0.000 __init__.py:2934(tag_raise) 1 0.000 0.000 11.661 11.661 __init__.py:33(mainloop) 83 0.156 0.002 0.787 0.009 __init__.py:37(buffer_flush) 60922 0.011 0.000 0.011 0.000 __init__.py:38(<lambda>) 83 0.005 0.000 0.005 0.000 __init__.py:38(<listcomp>) 1 0.007 0.007 0.452 0.452 __init__.py:43(load_data) 83 0.315 0.004 1.147 0.014 __init__.py:57(update_polygons) 2 0.000 0.000 0.000 0.000 __init__.py:622(destroy) 82 0.000 0.000 0.000 0.000 __init__.py:633(deletecommand) 83 0.001 0.000 1.374 0.017 __init__.py:71(update_screen) 83 0.000 0.000 0.001 0.000 __init__.py:77(fps_measure) 83 0.000 0.000 0.005 0.000 __init__.py:790(after) 1 0.000 0.000 0.203 0.203 __init__.py:8(__init__) 82 0.000 0.000 1.348 0.016 __init__.py:802(callit) 10 0.000 0.000 0.001 0.000 __init__.py:84(frame_cycle) 1 0.000 0.000 0.001 0.001 __init__.py:89(__init__) 1 0.000 0.000 0.000 0.000 _collections_abc.py:664(__contains__) 1 0.000 0.000 0.000 0.000 genericpath.py:121(_splitext) 4 0.000 0.000 0.000 0.000 genericpath.py:27(isfile) 9 0.000 0.000 0.000 0.000 ntpath.py:124(splitdrive) 1 0.000 0.000 0.000 0.000 ntpath.py:180(split) 1 0.000 0.000 0.000 0.000 ntpath.py:203(splitext) 1 0.000 0.000 0.000 0.000 ntpath.py:214(basename) 1 0.000 0.000 0.000 0.000 ntpath.py:34(_get_bothseps) 4 0.000 0.000 0.000 0.000 ntpath.py:77(join) 1 0.000 0.000 0.000 0.000 os.py:670(__getitem__) 1 0.000 0.000 0.000 0.000 os.py:734(check_str) 1 0.000 0.000 0.000 0.000 os.py:740(encodekey) 1469 0.001 0.000 0.001 0.000 {built-in method _tkinter._flatten} 1 0.202 0.202 0.202 0.202 {built-in method _tkinter.create} 1472 0.000 0.000 0.000 0.000 {built-in method builtins.callable} 2/1 0.000 0.000 12.326 12.326 {built-in method builtins.exec} 1 0.000 0.000 0.000 0.000 {built-in method builtins.hasattr} 84 0.000 0.000 0.000 0.000 {built-in method builtins.id} 3693 0.001 0.000 0.001 0.000 {built-in method builtins.isinstance} 60933 0.010 0.000 0.010 0.000 {built-in method builtins.len} 1 0.000 0.000 0.000 0.000 {built-in method builtins.max} 12 0.001 0.000 0.001 0.000 {built-in method builtins.print} 84 0.001 0.000 0.001 0.000 {built-in method builtins.repr} 83 0.035 0.000 0.046 0.001 {built-in method builtins.sorted} 1 0.000 0.000 0.000 0.000 {built-in method math.ceil} 78624 0.028 0.000 0.028 0.000 {built-in method math.cos} 78624 0.025 0.000 0.025 0.000 {built-in method math.sin} 15 0.000 0.000 0.000 0.000 {built-in method nt.fspath} 4 0.000 0.000 0.000 0.000 {built-in method nt.stat} 94 0.000 0.000 0.000 0.000 {built-in method time.time} 2288 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} 122668 0.805 0.000 0.805 0.000 {method 'call' of '_tkinter.tkapp' objects} 86 0.000 0.000 0.000 0.000 {method 'createcommand' of '_tkinter.tkapp' objects} 86 0.000 0.000 0.000 0.000 {method 'deletecommand' of '_tkinter.tkapp' objects} 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} 184968 0.034 0.000 0.034 0.000 {method 'extend' of 'list' objects} 1 0.000 0.000 0.000 0.000 {method 'get' of 'dict' objects} 734 0.000 0.000 0.000 0.000 {method 'getint' of '_tkinter.tkapp' objects} 2 0.000 0.000 0.000 0.000 {method 'getvar' of '_tkinter.tkapp' objects} 903 0.000 0.000 0.000 0.000 {method 'items' of 'dict' objects} 1 0.000 0.000 0.000 0.000 {method 'lower' of 'str' objects} 1 10.276 10.276 11.634 11.634 {method 'mainloop' of '_tkinter.tkapp' objects} 82 0.000 0.000 0.000 0.000 {method 'remove' of 'list' objects} 5 0.000 0.000 0.000 0.000 {method 'replace' of 'str' objects} 3 0.000 0.000 0.000 0.000 {method 'rfind' of 'str' objects} 1 0.000 0.000 0.000 0.000 {method 'rstrip' of 'str' objects} 60922 0.041 0.000 0.041 0.000 {method 'splitlist' of '_tkinter.tkapp' objects} 1470 0.001 0.000 0.001 0.000 {method 'update' of 'dict' objects} 1 0.000 0.000 0.000 0.000 {method 'upper' of 'str' objects} 2 0.000 0.000 0.000 0.000 {method 'values' of 'dict' objects} Process finished with exit code 0
Any input will be highly appreciated.

Warm Regards
iMu
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020