python 点超出曲线

nbysray5  于 2023-02-02  发布在  Python
关注(0)|答案(1)|浏览(109)

我有secp256k1椭圆曲线,我想在那条曲线上打印一个点。但是,这个点在曲线之外,我看不出为什么。

  • Python 3.10.7语言
  • 马尼姆0.17.2

谢谢你的帮助。

from manim import *

class eliptic_curves(MovingCameraScene):
    def secp256k1(self, x):
        return x ** 3 + 7

    def construct(self):
        ax = Axes(
            x_range=[-10, 10]
        )

        # plot the x^3 + 7 = y^2 curve
        graph = ax.plot_implicit_curve(lambda x, y : x ** 3 + 7 - y ** 2, color = BLUE)
        self.add(ax, graph)

        y = np.sqrt(self.secp256k1(1))
        dA = Dot([1, y, 0], color = RED)
        self.add(dA)

with tempconfig({"quality": "medium_quality", "preview": True}):
    scene = eliptic_curves()
    scene.render()

xtupzzrd

xtupzzrd1#

好了,我终于找到了一个解决办法,坐标轴的坐标系和场景的坐标系是不一样的(当然),所以我需要用ax.coords_to_point的方法把一个Dot放到ax坐标系的正确位置。

y = np.sqrt(self.secp256k1(1))
dA = Dot(ax.coords_to_point(1, y), color = RED)

相关问题