-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_diff.py
More file actions
77 lines (59 loc) · 1.3 KB
/
demo_diff.py
File metadata and controls
77 lines (59 loc) · 1.3 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#######################################################################
#
# xyzCad - functional cad software for 3d printing
# Copyright (c) 2021 Stefan Helmert <stefan.helmert@t-online.de>
#
#######################################################################
import math
import time
from numba import jit, njit
from xyzcad import render
@njit
def old_shape(p):
x, y, z = p[:3]
if x > 2:
return False
if x < -2:
return False
if y > 2:
return False
if y < -2:
return False
if z > 10:
return False
if z < 0:
return False
return True
@njit
def new_shape(p):
x, y, z = p[:3]
if x > 1:
return False
if x < -2:
return False
if y > 2:
return False
if y < -2:
return False
if z > 12:
return False
if z < 0:
return False
return True
@njit
def full_shape(p):
return old_shape(p) or new_shape(p)
@njit
def shape_diff(p):
if old_shape(p) and new_shape(p):
return 1
if old_shape(p) and not new_shape(p):
return 2
if not old_shape(p) and new_shape(p):
return 3
return 0
t0 = time.time()
render.renderAndSave(shape_diff, "build/demo_diff", 0.1)
print(time.time() - t0)