コード例 #1
0
ファイル: coordinate_systems.py プロジェクト: yk616/manim
 def get_parametric_curve(self, function: Callable[[float], np.ndarray],
                          **kwargs) -> ParametricCurve:
     dim = self.dimension
     graph = ParametricCurve(
         lambda t: self.coords_to_point(*function(t)[:dim]), **kwargs)
     graph.underlying_function = function
     return graph
コード例 #2
0
 def get_graph(self, function, x_range=None, **kwargs):
     t_range = np.array(self.x_range, dtype=float)
     if x_range is not None:
         t_range[:len(x_range)] = x_range
     # For axes, the third coordinate of x_range indicates
     # tick frequency.  But for functions, it indicates a
     # sample frequency
     if x_range is None or len(x_range) < 3:
         t_range[2] /= self.num_sampled_graph_points_per_tick
     t_range[0] = kwargs.pop("x_min", t_range[0])
     t_range[1] = kwargs.pop("x_max", t_range[1])
     '''    
     x_min = kwargs.pop("x_min", self.x_min)
     x_max = kwargs.pop("x_max", self.x_max)
     '''
     graph = ParametricCurve(lambda t: self.c2p(t, function(t)),
                             t_range=t_range,
                             **kwargs)
     '''
     graph = ParametricFunction(
         lambda t: self.coords_to_point(t, function(t)),
         t_min=x_min,
         t_max=x_max,
         **kwargs
     )
     '''
     graph.underlying_function = function
     return graph
コード例 #3
0
ファイル: coordinate_systems.py プロジェクト: libterty/manim
 def get_parametric_curve(self, function, **kwargs):
     dim = self.dimension
     graph = ParametricCurve(
         lambda t: self.coords_to_point(*function(t)[:dim]),
         **kwargs
     )
     graph.underlying_function = function
     return graph
コード例 #4
0
ファイル: coordinate_systems.py プロジェクト: wangxl12/manim
 def get_graph(self, function, x_range=None, **kwargs):
     if x_range is None:
         x_range = self.x_range
     graph = ParametricCurve(lambda t: self.coords_to_point(t, function(t)),
                             t_range=x_range,
                             **kwargs)
     graph.underlying_function = function
     return graph
コード例 #5
0
    def get_graph(self, function, x_range=None, **kwargs):
        t_range = np.array(self.x_range, dtype=float)
        if x_range is not None:
            t_range[:len(x_range)] = x_range
        # For axes, the third coordinate of x_range indicates
        # tick frequency.  But for functions, it indicates a
        # sample frequency
        if x_range is None or len(x_range) < 3:
            t_range[2] /= self.num_sampled_graph_points_per_tick

        graph = ParametricCurve(lambda t: self.c2p(t, function(t)),
                                t_range=t_range,
                                **kwargs)
        graph.underlying_function = function
        return graph
コード例 #6
0
ファイル: coordinate_systems.py プロジェクト: yk616/manim
 def input_to_graph_point(self, x: float,
                          graph: ParametricCurve) -> np.ndarray | None:
     if hasattr(graph, "underlying_function"):
         return self.coords_to_point(x, graph.underlying_function(x))
     else:
         alpha = binary_search(
             function=lambda a: self.point_to_coords(
                 graph.quick_point_from_proportion(a))[0],
             target=x,
             lower_bound=self.x_range[0],
             upper_bound=self.x_range[1],
         )
         if alpha is not None:
             return graph.quick_point_from_proportion(alpha)
         else:
             return None
コード例 #7
0
ファイル: graph_scene.py プロジェクト: daniel-lara-ec/manim
    def get_graph(self, func, color=None, x_min=None, x_max=None, **kwargs):
        if color is None:
            color = next(self.default_graph_colors_cycle)
        if x_min is None:
            x_min = self.x_min
        if x_max is None:
            x_max = self.x_max

        def parameterized_function(alpha):
            x = interpolate(x_min, x_max, alpha)
            y = func(x)
            if not np.isfinite(y):
                y = self.y_max
            return self.coords_to_point(x, y)

        graph = ParametricCurve(parameterized_function, color=color, **kwargs)
        graph.underlying_function = func
        return graph