简体   繁体   English

尽管具有相同的锚点/句柄(manim),为什么这会生成两条不同的贝塞尔曲线?

[英]Why does this generate two different Bezier curves despite having the same anchors/handles (manim)?

I am trying to have two identical Bezier curves in the same scene, one with an end tip and the other with a start tip, but the Bezier curves come out differently despite having the same anchors and handles.我试图在同一场景中有两条相同的贝塞尔曲线,一条有末端,另一个有起始末端,但尽管具有相同的锚点和手柄,但贝塞尔曲线的表现却有所不同。 I know I can add both tips to the same Bezier curve but to integrate the graphics into my existing code (to animate it) I need to have them separate.我知道我可以将两个提示添加到同一个 Bezier 曲线,但要将图形集成到我现有的代码中(使其动画化),我需要将它们分开。 Sample code to demonstrate the problem is as follows:演示问题的示例代码如下:

from manimlib.imports import *
class Testing3(Scene):
    def construct(self):
        coords_list=[0.818*UP+.9*UP, -2*RIGHT+((1/6-19/36)*np.sqrt(3))*UP+.9*UP]
        node_list=[]
        for i in range(2):
            mobject = VMobject()
            number = TexMobject(str(i+1))
            circle = Circle(radius=0.4,color=WHITE)
            mobject.add(number)
            mobject.add(circle)
            mobject.move_to(coords_list[i])
            node_list.append(mobject)
        
        arc1=TipableVMobject()
        arc1.add_cubic_bezier_curve(
            node_list[1].get_center(),
            node_list[1].get_center()-3*RIGHT+2*UP,
            node_list[1].get_center()-2*RIGHT+5.2*UP,
            node_list[0].get_center()
        )
        arc1.pointwise_become_partial(
            arc1,
            0.4/arc1.get_arc_length(n_sample_points=20),
            1-0.2/arc1.get_arc_length(n_sample_points=100)
        )
        arc1.add_tip(tip_length=0.2)
        
        arc2=TipableVMobject()
        arc2.add_cubic_bezier_curve(
            node_list[1].get_center(),
            node_list[1].get_center()-3*RIGHT+2*UP,
            node_list[1].get_center()-2*RIGHT+5.2*UP,
            node_list[0].get_center()
        )
        arc2.pointwise_become_partial(
            arc2,
            0.4/arc2.get_arc_length(n_sample_points=20),
            1-0.2/arc2.get_arc_length(n_sample_points=100)
        )
        arc2.add_tip(tip_length=0.2,at_start=True)
        self.add(*node_list,arc1,arc2)
        self.wait()

I have tried making a copy of the Bezier curve but it produces the same result.我曾尝试制作贝塞尔曲线的副本,但它产生了相同的结果。

For the moment this is only can I do:目前我只能这样做:

class Testing3(Scene):
    def construct(self):
        coords_list=[0.818*UP+.9*UP, -2*RIGHT+((1/6-19/36)*np.sqrt(3))*UP+.9*UP]
        node_list=[]
        for i in range(2):
            mobject = VMobject()
            number = TexMobject(str(i+1))
            circle = Circle(radius=0.4,color=WHITE)
            mobject.add(number)
            mobject.add(circle)
            mobject.move_to(coords_list[i])
            node_list.append(mobject)

        arc1=TipableVMobject()
        arc1.add_cubic_bezier_curve(
        node_list[1].get_center(),
        node_list[1].get_center()-3*RIGHT+2*UP,
        node_list[1].get_center()-2*RIGHT+5.2*UP,
        node_list[0].get_center()
        )
        arc1.pointwise_become_partial(
        arc1,
        0.4/arc1.get_arc_length(n_sample_points=20),
        1-0.2/arc1.get_arc_length(n_sample_points=100)
        )
        arc1.add_tip(tip_length=0.2,
        #at_start=True
        )
        arc1.add_tip(tip_length=0.2,
        at_start=True
        )
        arc1.set_color(RED)

        arc2=TipableVMobject()
        arc2.add_cubic_bezier_curve(
        node_list[1].get_center(),
        node_list[1].get_center()-3*RIGHT+2*UP,
        node_list[1].get_center()-2*RIGHT+5.2*UP,
        node_list[0].get_center()
        )
        arc2.pointwise_become_partial(
        arc2,
        0.4/arc2.get_arc_length(n_sample_points=20),
        1-0.2/arc2.get_arc_length(n_sample_points=100)
        )
        arc2.add_tip(tip_length=0.2,
        #at_start=True
        )
        arc2.add_tip(tip_length=0.2,
        at_start=True
        )
        arc2.set_color(BLUE)

        arc1.remove(arc1[-2])
        arc2.remove(arc2[-1])

        self.add(*node_list,arc1)

        self.wait()
        self.add(arc2)
        self.wait()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 connectionstyle arc3(FancyArrowPatch)和路径CURVE3-两个二次贝塞尔曲线,结果不同吗? - connectionstyle arc3 (FancyArrowPatch) and path CURVE3 - two quadratic Bezier curves, different outcomes? 尽管代码不同,但两个不同的文件仍提供相同的输出-PyQT5和Python - Two different files giving same output despite having different codes - PyQT5 and Python 如何绘制不同颜色的蓝色贝塞尔曲线的每一段? - How to draw each section of the blue Bezier curves with different color? 为什么结果不同,尽管代码完全相同? - Why is the result different ,despite the code is exactly the same? 尽管 Big-O 相同,为什么这两个函数的性能差异如此之大? - Why is the performance of these two functions so drastically different despite the same Big-O? 为什么Manim会遇到乳胶的问题 - Why does Manim meet problems with latex 为什么同一语句打印两个不同的值? - Why does the same statement print two different values? 在Manim中绘制高阶贝塞尔曲线 - Draw Higher-Order Bezier Curve in Manim VTK,两个磁盘的大小相同,尽管半径不同? - VTK, two disks are same size despite different radius? 尽管我使用相同的代码,为什么LSTM给出不同的输出? - Why LSTM give different output despite I use the same code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM