[英]Cartesian to Polar coordinate transformation in manim
How can I write a code that would show me this transformation, in the same format as the equation not like carrying it to the complex plain etc. because I want to play with it for other functions as well.我如何编写一个代码来向我展示这种转换,其格式与方程式相同,而不是将其带到复杂的平原等,因为我也想将它用于其他功能。
I tried myself a little bit and came up with this code that might be useful howeever I couldn't work it out to give me polar coordinates.我尝试了一下自己并想出了这段代码,它可能很有用,但是我无法给出极坐标。
class Transformation(LinearTransformationScene):
def construct(self):
line = Line(start=np.array([0,0,0]),
end=np.array([2,1,0]))
function = lambda pos: np.dot(np.array(pos[0]*np.cos(pos[1]), pos[0]*np.sin(pos[1])), pos)
self.add_transformable_mobject(line)
self.apply_nonlinear_transformation(function, run_time=5)
self.wait(3)
To transform cartesian coordinates to polar ones, you need this formula:要将笛卡尔坐标转换为极坐标,您需要以下公式:
fi = numpy.arctan2(y, x)
r = numpy.hypot(y, x)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.