以下代码将输出曲线图像,我希望crv1、2、3具有不同的形状或至少具有不同的控制点。
在查看最后一个图像输出时,看起来像通过更改crv3,crv 1和2一样,怎么可能呢?
from geomdl import BSpline
from geomdl import multi
from geomdl.visualization import VisMPL
crv1 = BSpline.Curve()
crv1.degree = 2
crv1.ctrlpts = [[1, 0], [1, 1], [0, 1]]
crv1.knotvector = [0, 0, 0, 1, 1, 1]
crv1.vis=VisMPL.VisCurve2D()
crv1.render()
crv2=crv1
crv2.insert_knot(0.25)
crv2.insert_knot(0.5)
crv2.insert_knot(0.75)
crv2.vis=VisMPL.VisCurve2D()
crv2.render()
crv3=crv2
crv3.remove_knot(0.5)
crv3.vis=VisMPL.VisCurve2D()
crv3.render()
crv=multi.CurveContainer([crv1, crv2, crv3])
crv.vis=VisMPL.VisCurve2D()
crv.render()
这是错误还是我的误解?请帮忙,多谢!
答案 0 :(得分:0)
我认为使用deepcopy
可以满足以下要求:
from copy import deepcopy
from geomdl import BSpline
from geomdl import multi
from geomdl.visualization import VisMPL
crv1 = BSpline.Curve()
crv1.degree = 2
crv1.ctrlpts = [[1, 0], [1, 1], [0, 1]]
crv1.knotvector = [0, 0, 0, 1, 1, 1]
crv1.vis=VisMPL.VisCurve2D()
crv1.render()
crv2=deepcopy(crv1) # changed
crv2.insert_knot(0.25)
crv2.insert_knot(0.5)
crv2.insert_knot(0.75)
crv2.vis=VisMPL.VisCurve2D()
crv2.render()
crv3=deepcopy(crv2) # changed
crv3.remove_knot(0.5)
crv3.vis=VisMPL.VisCurve2D()
crv3.render()
crv=multi.CurveContainer([crv1, crv2, crv3])
crv.vis=VisMPL.VisCurve2D()
crv.render()