如何在Manim中创建椭圆曲线的动画?
我正在与Manim一起玩,我想创建一个具有椭圆曲线的动画。这是我的代码,在file functions.py中:
from manim import *
class EllipticCurve(Scene):
def construct(self):
basic_ec = FunctionGraph(
lambda x: x**1.5 - x**0.5 + 19**0.5
)
self.play(Create(basic_ec))
执行此命令 manim -pql functions.py ellipticcurve
,我得到以下错误:
value eRROR:value eRror:array不得包含infs或nans
我相信方法 functiongraph
期望功能,而不是曲线,但是我如何对椭圆曲线进行动画和绘制呢?还有其他方法吗?我想念什么吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正正确地将函数传递到
functiongraph
,问题是,如果您没有明确指定图的x_range
,则Manim将选择范围[ - config.frame_x_radius,config.frame_x_radius]
(也就是说,它跨越整个宽度框架;默认情况下为-7.11至+7.11)。
插入功能中的负值是有问题的,因此Manim抱怨。通过
对于使用椭圆曲线更有用)。
x_range = [0,7]
tofunctiongraph
,或者查看还有一个最后的提示:获得
functiongraph
的理智缩放可能有点棘手.plot 或axes.plot_implitic
方法。You are passing the function to
FunctionGraph
correctly, the problem is that if you don't explicitly specify ax_range
for the plot, Manim will choose the range[-config.frame_x_radius, config.frame_x_radius]
(that is, it spans over the entire widthof the frame; by default from -7.11 to +7.11).
Plugging in negative values in your function is problematic, and so Manim complains. Either pass
x_range=[0, 7]
toFunctionGraph
, or check outImplicitFunction
(which to me seems more useful for working with elliptic curves).And one final hint: It can be a bit tricky to get sane scaling for
FunctionGraph
, you might want to consider creating anAxes
mobject and then use the correspondingAxes.plot
orAxes.plot_implicit
methods.以下对我有用:
它使用隐式图,轴对象的方法
plot_implitic_curve
axe> ax ,并且正在产生:注意:从评论中提取了通缉的椭圆曲线。它是曲线y²=x³-x + 19 。 (当然,我们无法通过从RHS中提取平方根“术语”来隔离y-无论术语的符号是什么...)曲线(在理由上看到)没有扭转点,其等级是一个,是一个,并且发电机为(2,5)。
The following worked for me:
It uses an implicit plot, the method
plot_implicit_curve
of the axes objectax
, and is producing:Note: The wanted elliptic curve was extracted from the comments. It is the curve y² = x³ - x + 19 . (Of course, we cannot isolate y by extracting the square root "termwise" from the R.H.S. - whatever the signs of the terms may be...) The curve (seen over the rationals) has no torsion points, its rank is one, and a generator is (2, 5).