coordinate_systems¶
- class janim.items.coordinate.coordinate_systems.CoordinateSystem(*args, num_sampled_graph_points_per_tick, **kwargs)¶
基类:
object坐标系统抽象类
具体实现请参考
AxesThreeDAxes以及NumberPlane- static create_axis(range: RangeSpecifier, axis_config: dict, length: float | None) NumberLine¶
- abstractmethod get_axes() list[NumberLine]¶
得到由各方向
NumberLine所组成的列表
- get_origin() ndarray¶
- coords_to_point(*coords: float) ndarray¶
传入坐标得到对应的位置
例如
c2p(1, 3)得到 (1,3) 的位置
- coords_array_to_points(coords_array: VectArray) ndarray¶
传入一组坐标得到对应的一组位置
例如
c2p([[1, 3], [2, 1], [-1, -1]])得到对应的三个位置
- c2p(*coords: float) ndarray¶
- point_to_coords3d(point: Vect | Iterable[Vect]) ndarray¶
传入位置得到对应的坐标(但是会扩张为三维坐标;对于二维坐标系来说,第三个分量则表示距离二维平面的距离)
也可以传入一组位置得到一组对应的坐标
- p2c3d(point: Vect | Iterable[Vect]) ndarray¶
- point_to_coords(point: Vect | Iterable[Vect]) ndarray¶
传入位置得到对应坐标
也可以传入一组位置得到一组对应的坐标
- p2c(point: Vect | Iterable[Vect]) ndarray¶
- number_to_point(number: complex | float) ndarray¶
传入复数得到对应位置
- n2p(number: complex | float) ndarray¶
- point_to_number(point: Vect) complex¶
传入位置得到对应复数
- p2n(point: Vect) complex¶
- class janim.items.coordinate.coordinate_systems.Axes(x_range: RangeSpecifier = (-8.0, 8.0, 1), y_range: RangeSpecifier = (-4.0, 4.0, 1), *, num_sampled_graph_points_per_tick: int = 5, axis_config: dict = {}, x_axis_config: dict = {}, y_axis_config: dict = {}, x_length: float | None = None, y_length: float | None = None, height: float | None = None, width: float | None = None, unit_size: float = 1.0, **kwargs)¶
基类:
CoordinateSystem,MarkedItem,NamedGroupMixin二维坐标轴
num_sampled_graph_points_per_tick:表示
get_graph()方法在采样步长缺省时,在每段刻度中采样点的数量axis_config:横坐标轴和纵坐标轴共用的配置项,可用参数请参考
NumberLinex_axis_config:横坐标轴的配置项,可用参数请参考
NumberLiney_axis_config:纵坐标轴的配置项,可用参数请参考
NumberLinex_length:当该值指定时,会将横坐标轴的长度拉伸以匹配该值
y_length:当该值指定时,会将纵坐标轴的长度拉伸以匹配该值
unit_size:指定横坐标与纵坐标的单位长度,如果指定了对应的
*_length则会被忽略注:如果需要给某个坐标轴单独指定
unit_size,请传入对应的*_axis_config
- default_axis_config = {'numbers_to_exclude': [0]}¶
- default_x_axis_config = {}¶
- default_y_axis_config = {'line_to_number_direction': array([0., 1., 0.])}¶
- axis_config_d = {'numbers_to_exclude': [0]}¶
- x_axis_config_d = {}¶
- y_axis_config_d = {'line_to_number_direction': array([0., 1., 0.])}¶
- property x_axis: NumberLine¶
- property y_axis: NumberLine¶
- get_axes() list[NumberLine]¶
得到由各方向
NumberLine所组成的列表
- get_graph(function: Callable[[float], float], x_range: RangeSpecifier | None = None, *, bind: bool = True, **kwargs) ParametricCurve¶
基于坐标轴的坐标构造函数曲线,使用
ParametricCurvefunction: 用于构造曲线的函数x_range: 图像定义域如果没有指定则使用横坐标的定义域
指定时,可以使用
[x_min, x_max, x_step]或者省略采样步长[x_min, x_max]如果没有指定采样步长,则将坐标轴的刻度步长除以物件的
num_sampled_graph_points_per_tick作为采样步长bind: 在默认情况下为True,会使得函数曲线自动同步应用于坐标系上的变换,也可同步动画,详见 API 演示 中的NumberPlaneExample
- get_parametric_curve(function: Callable[[float], Vect], t_range: tuple[float, float, float] = (0, 1, 0.1), *, bind: bool = True, **kwargs)¶
基于坐标轴的坐标构造参数曲线,即
ParametricCurvefunction: 将值映射为坐标系上的一个点的参数函数bind: 在默认情况下为True,会使得参数曲线自动同步应用于坐标系上的变换,也可同步动画,详见 API 演示 中的NumberPlaneExample
- get_area(graph: ParametricCurve, x_range: tuple[float, float] | None = None, color: JAnimColor = '#58C4DD', alpha: float = 0.3, stroke_alpha: float | None = None, fill_alpha: float | None = None, bounded_graph: ParametricCurve = None, **kwargs) Polygon¶
构造
x_range区间内,graph与坐标轴所围成的区域,使用Polygon表示graph: 函数曲线,另见get_graph()x_range:x区间的最小值与最大值,x_range = [x_min, x_max]bounded_graph: 如果指定该参数,那么将会构造graph与bounded_graph所围成的区域,而非与坐标轴
- get_axis_labels(x_label: str | Points = 'x', y_label: str | Points = 'y', x_kwargs: dict = {}, y_kwargs: dict = {}, **kwargs) Group[TypstMath | Points]¶
-
如果设置
ensure_on_screen=True,坐标轴标签会自动调整位置移动到默认屏幕区域内
- get_x_axis_label(label: str | Points = 'x', **kwargs) TypstMath | Points¶
-
如果设置
ensure_on_screen=True,坐标轴标签会自动调整位置移动到默认屏幕区域内
- class janim.items.coordinate.coordinate_systems.ThreeDAxes(x_range: RangeSpecifier = (-6, 6, 1), y_range: RangeSpecifier = (-5, 5, 1), z_range: RangeSpecifier = (-4, 4, 1), *, axis_config: dict = {}, z_length: float | None = None, z_axis_config: dict = {}, z_normal: Vect = array([0., 1., 0.]), **kwargs)¶
基类:
Axes三维坐标轴
z_normal表示 z 坐标轴上刻度和箭头标记的面向,默认面向UP方向
其它可用参数请参考并类比
Axes的使用- default_z_axis_config = {}¶
- z_axis_config_d = {}¶
- property z_axis: NumberLine¶
- get_axes() list[NumberLine]¶
得到由各方向
NumberLine所组成的列表
- get_axis_labels(x_label: str | Points = 'x', y_label: str | Points = 'y', z_label: str | Points = 'z', x_kwargs: dict = {}, y_kwargs: dict = {}, z_kwargs: dict = {}, rotate_xy: bool = True, z_point_up: bool = True, **kwargs) Group[TypstMath | Points]¶
-
另外,在默认情况下
rotate_xy=True会将 x、y 轴的标签原地旋转半圈,以匹配从 x、y、z 三个轴的正方向看向原点的视角以及,直接生成的 z 坐标轴标签会和 2D 平面平行,默认情况下
point_up=True会将其立起来和 z 轴方向一致,传入point_up=False可禁用该行为
- class janim.items.coordinate.coordinate_systems.CmptVPoints_NumberPlaneImpl(*args, **kwargs)¶
基类:
Cmpt_VPoints- prepare_for_nonlinear_transform(num_inserted_curves: int = 50, *, root_only=False) Self¶
- class janim.items.coordinate.coordinate_systems.NumberPlane(x_range: RangeSpecifier = (-8.0, 8.0, 1), y_range: RangeSpecifier = (-4.0, 4.0, 1), background_line_style: dict = {}, faded_line_style: dict = {}, faded_line_ratio: int = 4, **kwargs)¶
基类:
Axes坐标网格
一般来说包含:
坐标轴:
默认是白色的坐标轴,不带箭头标志和刻度线
主要网格线:
颜色默认是 BLUE_D,可传入
background_line_style调整次要网格线:
可使用
faded_line_style调整当
faded_line_style没有设置时,会将采用与background_line_style相同的配置,并将其颜色透明化 50% 来使用使用
faded_line_ratio调整每个网格中次要网格线的数量例如默认的
4表示每两个主要网格线之间等距排布了 4 个次要网格线可调整成
1,减少次要网格线的密集程度,或是直接设置成0来禁用次要网格线
更多参数与方法另请参考
Axes- points¶
- default_background_line_style = {'stroke_color': '#29ABCA', 'stroke_radius': 0.01}¶
- default_axis_config = {'include_ticks': False, 'include_tip': False, 'line_to_number_buff': 0.1, 'line_to_number_direction': array([-1., -1., 0.]), 'stroke_color': '#FFFFFF', 'stroke_radius': 0.01}¶
- default_y_axis_config = {'line_to_number_direction': array([-1., -1., 0.]), 'numbers_to_exclude': [0]}¶
- background_line_style_d = {'stroke_color': '#29ABCA', 'stroke_radius': 0.01}¶
- axis_config_d = {'include_ticks': False, 'include_tip': False, 'line_to_number_buff': 0.1, 'line_to_number_direction': array([-1., -1., 0.]), 'stroke_color': '#FFFFFF', 'stroke_radius': 0.01}¶
- y_axis_config_d = {'line_to_number_direction': array([-1., -1., 0.]), 'numbers_to_exclude': [0]}¶
- get_lines_parallel_to_axis(axis1: NumberLine, axis2: NumberLine) tuple[Group[Line], Group[Line]]¶