fix lab2 add pt
This commit is contained in:
@@ -76,8 +76,8 @@ def ibspline(inputA, inputB=None):
|
||||
elif i >= h + 1:
|
||||
new_points.append(points[i - 1])
|
||||
else:
|
||||
denom = knot_vector[i+n] - knot_vector[i]
|
||||
alpha = (t_hat - knot_vector[i]) / denom if denom > 1e-8 else 0.0
|
||||
denom = knot_vector[i+n-1] - knot_vector[i-1]
|
||||
alpha = (t_hat - knot_vector[i-1]) / denom if denom > 1e-8 else 0.0
|
||||
px = (1 - alpha) * points[i-1][0] + alpha * points[i][0]
|
||||
py = (1 - alpha) * points[i-1][1] + alpha * points[i][1]
|
||||
new_points.append((px, py))
|
||||
@@ -87,7 +87,7 @@ def ibspline(inputA, inputB=None):
|
||||
vY = [p[1] for p in new_points]
|
||||
|
||||
# Update knot vector: insert t_hat
|
||||
knot_vector.insert(h + 1, t_hat)
|
||||
knot_vector.insert(h, t_hat)
|
||||
|
||||
outputPlotMessage(f"Added Control Point. (m={len(vX)})")
|
||||
redrawPlot(vX, vY)
|
||||
@@ -337,18 +337,6 @@ def ibspline(inputA, inputB=None):
|
||||
enableButtons()
|
||||
return
|
||||
|
||||
# Pick and move a vertex
|
||||
def pickPointCallback(event):
|
||||
global iv_selected, cid_moveCallback
|
||||
|
||||
if (len(event.ind) < 1): return
|
||||
|
||||
if (event.ind[0] >= 0) and (event.ind[0] < len(vX)):
|
||||
iv_selected = event.ind[0]
|
||||
cid_moveCallback = \
|
||||
fig.canvas.mpl_connect('button_release_event', moveVertexCallback)
|
||||
|
||||
return
|
||||
|
||||
# Move selected vertex to location (event.xdata, event.ydata)
|
||||
def moveVertexCallback(event):
|
||||
|
||||
Reference in New Issue
Block a user