Point#

Point 表示平面中的一个点,由其 x 和 y 坐标定义。

属性 / 方法

描述

Point.distance_to()

计算到点或矩形的距离

Point.norm()

欧几里得范数

Point.transform()

使用矩阵转换点

Point.abs_unit

与单位相同,但坐标为正

Point.unit

点的坐标除以 abs(point)

Point.x

x 坐标

Point.y

y 坐标

类 API

class Point#
__init__(self)#
__init__(self, x, y)#
__init__(self, point)#
__init__(self, sequence)#

重载构造函数。

如果没有参数,则创建 Point(0, 0)

如果指定了另一个点,则会创建 新副本,”sequence” 是包含 2 个数字的 Python 序列(参见 在 PyMuPDF 中使用 Python 序列作为参数)。

参数:
  • x (float) – 点的 x 坐标

  • y (float) – 点的 y 坐标

distance_to(x[, unit])#

计算到 x 的距离,x 可以是 point_likerect_like。距离以像素(默认)、英寸、厘米或毫米为单位。

参数:
  • x (point_like,rect_like) – 计算距离的目标。

  • unit (str) – 测量的单位。可以是 “px”、”in”、”cm”、”mm” 之一。

返回类型:

float

返回:

x 的距离。如果 xrect_like,则距离

  • 是连接矩形任意一边的最短线段的长度

  • 计算的是 有限版本 的距离

  • 如果矩形 包含 该点,则距离为零

norm()#
  • 新版本 1.16.0 引入

返回点的欧几里得范数(长度)作为一个向量。等同于函数 abs() 的结果。

transform(m)#

将矩阵应用于点,并用结果替代原点。

参数:

m (matrix_like) – 要应用的矩阵。

返回类型:

Point

unit#

将每个坐标除以 norm(point) (点到 (0,0) 的距离)后的结果。该向量的长度为 1,方向与点相同。其 x 和 y 值分别等于该向量与 x 轴夹角的余弦和正弦值。

_images/img-point-unit.jpg
Type:

Point

abs_unit#

unit 相同,但坐标的值替换为其绝对值。

Type:

Point

x#

x 坐标

Type:

float

y#

y 坐标

Type:

float

备注

Point represents a point in the plane, defined by its x and y coordinates.

Attribute / Method

Description

Point.distance_to()

calculate distance to point or rect

Point.norm()

the Euclidean norm

Point.transform()

transform point with a matrix

Point.abs_unit

same as unit, but positive coordinates

Point.unit

point coordinates divided by abs(point)

Point.x

the X-coordinate

Point.y

the Y-coordinate

Class API

备注


本软件按原样提供,不作任何明示或暗示担保。本软件根据许可分发,除非根据该许可条款明确授权,否则不得复制、修改或分发。请参阅 artifex.com 上的许可信息,或联系 Artifex Software Inc., 39 Mesa Street, Suite 108A, San Francisco CA 94129, United States 了解更多信息。