v0.14.0
sdf.py
Go to the documentation of this file.
1 import math
2
3 # SDF Indenter
4
5 # Negative level set represents interior of the indenter.
6 # This normal points outside of the indenter.
7
8 r = 1
9
10
11 def sdf(t, x, y, z, tx, ty, tz):
12  return 1;
13
14
15 def grad_sdf(t, x, y, z, tx, ty, tz):
16  return [0, 0, 0]
17
18
19 def hess_sdf(t, x, y, z, tx, ty, tz):
20  return [0, 0, 0, 0, 0, 0]
21
22 # Indenters
23
24 class yPlane:
25  def sDF(shift, y):
26  return y - shift
27
29  # nx, ny, nz
30  return [0, 1, 0]
31
32  def hessSdf():
33  # xx, yx, zx, yy, zy, zz
34  return [0, 0, 0, 0, 0, 0]
35
36
37 class CylinderZ:
38
39  def sDF(r, xc, yc, x, y):
40  a = pow(x-xc, 2)+pow(y-yc, 2)
41  c_val = math.sqrt(a)-r
42  return c_val
43
44  def gradSdf(xc, yc, x, y):
45  a = pow(x-xc, 2)+pow(y-yc, 2)
46  c_val = math.sqrt(a)
47  c_val_A = 1/c_val
48  c_val_dx = c_val_A * (x-xc)
49  c_val_dy = c_val_A * (y-yc)
50  # x, y, z
51  return [c_val_dx, c_val_dy, 0]
52
53  def hessSdf(xc, yc, x, y):
54  a = pow(x-xc, 2)+pow(y-yc, 2)
55  c_val = math.sqrt(a)
56  c_val_A = 1./c_val
57  c_val_B = 1./pow(a, 3./2.)
58  c_val_dx_dx = c_val_A - c_val_B * pow(x-xc, 2)
59  c_val_dx_dy = -c_val_B * (x-xc)*(y-yc)
60  c_val_dy_dy = c_val_A - c_val_B * pow(y-yc, 2)
61  # xx, yx, zx, yy, zy, zz
62  return [c_val_dx_dx, c_val_dx_dy, 0, c_val_dy_dy, 0, 0]
sdf.hess_sdf
def hess_sdf(t, x, y, z, tx, ty, tz)
Definition: sdf.py:19
sdf.yPlane.sDF
def sDF(shift, y)
Definition: sdf.py:25
Definition: sdf.py:28
Definition: sdf.py:44
sdf.CylinderZ.sDF
def sDF(r, xc, yc, x, y)
Definition: sdf.py:39
sdf.yPlane.hessSdf
def hessSdf()
Definition: sdf.py:32
sdf.CylinderZ
Definition: sdf.py:37
sdf.yPlane
Definition: sdf.py:24
sdf.sdf
def sdf(t, x, y, z, tx, ty, tz)
Definition: sdf.py:11