# 请教关于PCISPH中的系数

B. Solenthaler and R. Pajarola. 2009. Predictive-corrective incompressible SPH. ACM Trans. Graph. 28, 3, Article 40 (August 2009), 6 pages. DOI:https://doi.org/10.1145/1531326.1531346

1 Like

perfect sampling:

3 Likes

(画出来结果和mzhang 助教 所说一致)

``````import numpy as np
import math
import matplotlib.pyplot as plt

def circle(x,y,r,color='k',count=1000):
xarr=[]
yarr=[]
for i in range(count):
j = float(i)/count * 2 * np.pi
xarr.append(x+r*np.cos(j))
yarr.append(y+r*np.sin(j))
plt.plot(xarr,yarr,c=color)

hp = 0.025
h = 4* hp
diam =2*hp
xi = [0, 0]
xj =[-h,-h]

print("h=",h,"diam=",diam)
i,j=0,0

fig1 = plt.figure(num='fig1',figsize=(6,6),dpi=100,facecolor='#FFFFFF',edgecolor='#FF0000')
plt.grid()

plt.arrow(-0.15,0,0.3,0)
plt.arrow(0,-0.15,0,0.3)

circle(0,0,h)

while(xj[0]<=h):
print("")
print("")
print("loop0 ")
while(xj[1]<=h):
j=j+1
print("loop1")
print("xi=",xi,"xj=",xj)

dist2=(xi[0]-xj[0])**2 + (xi[1]-xj[1])**2
print("dist=",math.sqrt(dist2))

#画蓝色圈
circle(xj[0],xj[1],hp,'#00BFFF')
plt.scatter(xj[0],xj[1],c='k')
plt.text(xj[0],xj[1],color='r',s=f'{j}',size=8)
plt.text(xj[0]+0.005,xj[1]+0.005,color='k',s=f'{xj[0],xj[1]}',size=5)

if  dist2<= h**2:
print("yes")
xj[1] += diam
xj[0] += diam
xj[1] = -h
print("end")

#画橙色圈
circle(0,0,hp,'#FF8C00')
plt.show()
``````
3 Likes

2 Likes