v0.13.2
Searching...
No Matches
sdf.py
Go to the documentation of this file.
1import math
2
3# SDF Indenter
4
5r = 1
6
7#xc = (-58.9 + 12.5)/2
8#zc = (-70.5 + 0.9)/2
9#yc = -58.9 - r
10
11
12def sdf(t, x, y, z, tx, ty, tz):
13 #return Sphere.sDF(r, xc, yc, zc, x, y, z)
14 return CylinderZ.sDF(r, 0, -0.5-r, x, y)
15
16
17def grad_sdf(t, x, y, z, tx, ty, tz):
18 #return Sphere.gradSdf(xc, yc, zc, x, y, z)
19 return CylinderZ.gradSdf(0, -0.5-r, x, y)
20
21
22def hess_sdf(t, x, y, z, tx, ty, tz):
23 #return Sphere.hessSdf(xc, yc, zc, x, y, z)
24 return CylinderZ.hessSdf(0, -0.5-r, x, y)
25
26# Indenters
27
28class yPlane:
29 def sDF(shift, xc, yc, x, y):
30 return y-shiftl
31
32 def gradSdf(xc, yc, x, y):
33 # x, y, z
34 return [0, 0, 0]
35
36 def hessSdf(xc, yc, x, y):
37 # xx, yx, zx, yy, zy, zz
38 return [0, 0, 0, 0, 0]
39
40
42
43 def sDF(r, xc, yc, x, y):
44 a = pow(x-xc, 2)+pow(y-yc, 2)
45 c_val = math.sqrt(a)-r
46 return c_val
47
48 def gradSdf(xc, yc, x, y):
49 a = pow(x-xc, 2)+pow(y-yc, 2)
50 c_val = math.sqrt(a)
51 c_val_A = 1/c_val
52 c_val_dx = c_val_A * (x-xc)
53 c_val_dy = c_val_A * (y-yc)
54 # x, y, z
55 return [c_val_dx, c_val_dy, 0]
56
57 def hessSdf(xc, yc, x, y):
58 a = pow(x-xc, 2)+pow(y-yc, 2)
59 c_val = math.sqrt(a)
60 c_val_A = 1./c_val
61 c_val_B = 1./pow(a, 3./2.)
62 c_val_dx_dx = c_val_A - c_val_B * pow(x-xc, 2)
63 c_val_dx_dy = -c_val_B * (x-xc)*(y-yc)
64 c_val_dy_dy = c_val_A - c_val_B * pow(y-yc, 2)
65 # xx, yx, zx, yy, zy, zz
66 return [c_val_dx_dx, c_val_dx_dy, 0, c_val_dy_dy, 0, 0]
67
68class Sphere:
69
70 def sDF(r, xc, yc, zc, x, y, z):
71 a = pow(x-xc, 2)+pow(y-yc, 2)+pow(z-zc, 2)
72 c_val = math.sqrt(a)-r
73 return c_val
74
75 def gradSdf(xc, yc, zc, x, y, z):
76 a = pow(x-xc, 2)+pow(y-yc, 2)+pow(z-zc, 2)
77 c_val = math.sqrt(a)
78 c_val_A = 1/c_val
79 c_val_dx = c_val_A * (x-xc)
80 c_val_dy = c_val_A * (y-yc)
81 c_val_dz = c_val_A * (z-zc)
82 # x, y, z
83 return [c_val_dx, c_val_dy, c_val_dz]
84
85 def hessSdf(xc, yc, zc, x, y, z):
86 a = pow(x-xc, 2)+pow(y-yc, 2)+pow(z-zc, 2)
87 c_val = math.sqrt(a)
88 c_val_A = 1./c_val
89 c_val_B = 1./pow(a, 3./2.)
90 c_val_dx_dx = c_val_A - c_val_B * pow(x-xc, 2)
91 c_val_dx_dy = -c_val_B * (x-xc)*(y-yc)
92 c_val_dy_dy = c_val_A - c_val_B * pow(y-yc, 2)
93 # xx, yx, zx, yy, zy, zz
94 return [c_val_dx_dx, c_val_dx_dy, 0, c_val_dy_dy, 0, 0]
95
96
def hessSdf(xc, yc, x, y)
Definition: sdf.py:57
Definition: sdf.py:48
def sDF(r, xc, yc, x, y)
Definition: sdf.py:43
def hessSdf(xc, yc, zc, x, y, z)
Definition: sdf.py:85
def gradSdf(xc, yc, zc, x, y, z)
Definition: sdf.py:75
def sDF(r, xc, yc, zc, x, y, z)
Definition: sdf.py:70
def sDF(shift, xc, yc, x, y)
Definition: sdf.py:29
def hessSdf(xc, yc, x, y)
Definition: sdf.py:36