fuzzyometry 0.0.3__tar.gz → 0.0.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: fuzzyometry
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: The fuzzyometry library provides smooth objects, object connections and automatic chamfer generation for xyzcad.
5
5
  Author: Stefan Helmert
6
6
  Author-email: stefan@entroserv.de
@@ -0,0 +1 @@
1
+ __version__ = "0.0.5"
@@ -1,5 +1,5 @@
1
- from numba import njit
2
1
  import numpy as np
2
+ from numba import njit
3
3
 
4
4
 
5
5
  @njit
@@ -48,9 +48,9 @@ def _fz_cuboid_ir(p, s):
48
48
 
49
49
 
50
50
  @njit
51
- def fz_cuboid(pnt, dimensions, r=0.):
52
- #s = [e / 2 - r for e in dimensions]
53
- s = np.array(dimensions) /2. - r
51
+ def fz_cuboid(pnt, dimensions, r=0.0):
52
+ # s = [e / 2 - r for e in dimensions]
53
+ s = np.array(dimensions) / 2.0 - r
54
54
  x, y, z = pnt
55
55
  w, l, h = s
56
56
  xd = min(w - x, w + x)
@@ -1,3 +1,4 @@
1
+ import numpy as np
1
2
  from numba import njit
2
3
 
3
4
 
@@ -15,3 +16,13 @@ def fz_or_chamfer(r, *args):
15
16
  for a in args:
16
17
  s += max(r - a, 0) ** 2
17
18
  return r - s**0.5
19
+
20
+
21
+ @njit
22
+ def grad(f, p, h=0.001):
23
+ x, y, z, par = p
24
+ f0 = f(p)
25
+ return (
26
+ np.array([f((x + h, y, z, par)), f((x, y + h, z, par)), f((x, y, z + h, par))])
27
+ - f0
28
+ ) / h
@@ -5,12 +5,14 @@ from numba import njit
5
5
  @njit
6
6
  def fz_thread_profile(pnt, a=1.0):
7
7
  y = pnt[1]
8
- if abs(y) > 2*a:
9
- return y / 2 / a
8
+ if abs(y) > 2 * a:
9
+ return y / a
10
10
  x = pnt[0] * 2 * np.pi
11
- p = a / (-0.5 * np.sin(x) + 2**-20 - 2**-19 * np.sign(np.sin(x)))
12
- q = y / (np.sin(x) + 2**-20 + 2**-19 * np.sign(np.sin(x))) - 1
13
- return -p / 2 - np.sign(np.sin(x)) * (max(0, (p / 2) ** 2 - q)) ** 0.5
11
+ sg = np.sign(np.sin(x))
12
+ snglr = 2**-20 - 2**-19 * sg
13
+ p = a / (-np.sin(x) / 2 + snglr)
14
+ q = y / (np.sin(x) + snglr) - 1.0
15
+ return -p - sg * np.sqrt(max(0, p**2 - 4 * q))
14
16
 
15
17
 
16
18
  @njit
@@ -18,7 +20,6 @@ def fz_thread(pnt, radius, n=1, profile_depth=1.0, a=1.0):
18
20
  x, y, z = pnt
19
21
  ang = -np.atan2(y, x)
20
22
  r = (x**2 + y**2) ** 0.5
21
- r_arg = (r - radius)/profile_depth
23
+ r_arg = (r - radius) / profile_depth
22
24
  z_arg = z + n * ang / 2 / np.pi
23
25
  return profile_depth * fz_thread_profile((z_arg, r_arg), a)
24
-
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "fuzzyometry"
3
- version = "0.0.3"
3
+ version = "0.0.5"
4
4
  description = "The fuzzyometry library provides smooth objects, object connections and automatic chamfer generation for xyzcad."
5
5
  authors = ["Stefan Helmert <stefan@entroserv.de>"]
6
6
  readme = "README.md"
@@ -1 +0,0 @@
1
- __version__ = "0.0.3"
File without changes