gpt4 book ai didi

Make Triangle with Points(使用点生成三角形)

转载 作者:bug小助手 更新时间:2023-10-26 21:29:25 28 4
gpt4 key购买 nike



I'm trying to use Manim to make a visual proof of the Squeeze Theorem from calculus. This involves comparing areas. I have made three dots labeled point0, point1, point2, and three lines labeled line1, line2, line3. The figure looks like a triangle, except I have no idea how to treat it like one. Namely, I need (a) to fill the shape with a color like green, and (b) to make a copy of the shape and move it elsewhere.

我试图用曼尼姆对微积分中的挤压定理做一个直观的证明。这涉及到对地区进行比较。我已经制作了三个标记为Point0、Point1、Point2的点,以及三条标记为直线1、直线2、直线3的直线。这个人物看起来像一个三角形,除了我不知道如何把它当作一个三角形。也就是说,我需要(A)用绿色之类的颜色填充该形状,以及(B)复制该形状并将其移动到其他地方。


from manim import *
import math

class One(Scene):
def construct(self):

#Number Plane
plane = NumberPlane(x_range=[-1,1], x_length=6,
y_range=[0,1], y_length=3, color=BLUE).move_to(ORIGIN+UP)
plane_graph = plane.plot(lambda x: math.sqrt(1-x**2), x_range=[-1,1,0.01], color=GREEN)

self.add(plane)
self.play(Create(plane_graph))
self.wait()

#Creating the Triangles
q = ValueTracker(0.7)
point0 = Dot().move_to(plane.c2p(0,0))
point1 = always_redraw(lambda: Dot().move_to(plane.c2p(q.get_value(),
plane_graph.

underlying_function(q.get_value()))))
point2 = always_redraw(lambda: Dot().move_to(plane.c2p(q.get_value(), 0)))
label1 = Tex("$(\cos(x), \sin(x))$", font_size=30).next_to(point1)

self.play(Create(point0))
v1 = VGroup(point1, label1)
self.play(Create(v1))


line1 = Line(point0, point1)
self.play(Create(line1))
self.play(Create(point2))

line2 = Line(point1, point2)
line3 = Line(point2, point0)
self.play(Create(line2))
self.play(Create(line3))
self.wait()

v2 = VGroup(point0, point1, point2, line1, line2, line3)
triangle1 = v2.copy()
self.play(Create(triangle1.move_to(ORIGIN+DOWN)))
self.wait()



The code above works to copy my "triangle", but I cannot manipulate it like one. I can't set the fill_color because there is nothing to fill. At best, I suppose I could find the area under the hypotenuse and force the color to be what I want, but that seems problematic.

上面的代码可以复制我的“三角形”,但我不能像处理三角形那样操作它。我无法设置FILL_COLOR,因为没有要填充的内容。充其量,我想我可以找到斜边下面的区域,并迫使颜色成为我想要的,但这似乎是有问题的。


Update: I used Polygon() with the points I described in my code. I think this is better. The triangle I made is of the same size and shape, but I think it's not using the coordinates/lengths of my plane and is instead getting the numbers from my plane_graph and using default coordinates/lengths of the screen.

更新:我使用Polygon()和我在代码中描述的点。我觉得这样更好。我做的三角形是相同的大小和形状,但我认为它没有使用我的平面的坐标/长度,而是从我的plane_graph中获取数字,并使用屏幕的默认坐标/长度。


更多回答
优秀答案推荐
更多回答

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com