Main Content

rigid2d

(不推荐)使用后乘约定的二维刚性几何变换

自 R2020b 起

不建议使用 rigid2d。请改用 rigidtform2d 对象。有关详细信息,请参阅兼容性注意事项

说明

rigid2d 对象存储有关二维刚性几何变换的信息,并支持正向变换和逆变换。

创建对象

描述

tform = rigid2d 创建对应于恒等变换的默认 rigid2d 对象。

tform = rigid2d(t)T 属性设置为指定的二维刚性变换矩阵 t

示例

tform = rigid2d(rot,trans)RotationTranslation 属性分别设置为指定的旋转矩阵 rot 和平移向量 trans

属性

全部展开

正向刚性变换,指定为 3×3 数值矩阵。矩阵 T 满足由下式给出的后乘约定:

[x y 1] = [u v 1] * Rotation + Translation

数据类型: single | double

变换的旋转分量,指定为 2×2 数值矩阵。

数据类型: single | double

变换的平移分量,指定为一个包含 2 个元素的数值行向量。

数据类型: single | double

此 属性 为只读。

几何变换的维度,指定为数字 2

对象函数

invertInvert geometric transformation
isTranslationDetermine if geometric transformation is pure translation
outputLimitsFind output spatial limits given input spatial limits
transformPointsForwardApply forward geometric transformation
transformPointsInverseApply inverse geometric transformation

示例

全部折叠

以度为单位指定旋转角度,并创建一个 2×2 旋转矩阵。

theta = 30;
rot = [ cosd(theta) sind(theta); ...
       -sind(theta) cosd(theta)];

分别指定水平和垂直平移量。

trans = [2 3];

创建一个执行旋转和平移的 rigid2d 对象。

tform = rigid2d(rot,trans)
tform = 
  rigid2d with properties:

       Rotation: [2x2 double]
    Translation: [2 3]

扩展功能

版本历史记录

在 R2020b 中推出

全部折叠

R2022b: 不推荐

从 R2022b 开始,大多数 Image Processing Toolbox™ 函数都使用前乘约定来创建和执行几何变换。因此,不推荐使用 rigid2d 对象,因为它使用后乘约定。虽然当前没有删除 rigid2d 对象的计划,但您可以通过切换到支持前乘约定的 rigidtform2d 对象来简化几何变换工作流。有关详细信息,请参阅Migrate Geometric Transformations to Premultiply Convention

要更新您的代码,请执行以下操作:

  • 将函数名称 rigid2d 的实例更改为 rigidtform2d

  • 将变换矩阵指定为 TRotation 的转置。Trigid2d 对象的 T 属性的值,或用于创建 rigid2d 对象的变换矩阵。Rotationrigid2d 对象的 Rotation 属性的值,或用于创建 rigid2d 对象的旋转矩阵。

不推荐使用推荐的替代项

此示例基于后乘约定中的变换矩阵 T 创建一个 rigid2d 对象。

T = [1 0 0; 0 1 0; 5 10 1];
tformPost = rigid2d(T);

此示例基于变换矩阵 T 的转置创建一个 rigidtform2d 对象。

T = [1 0 0; 0 1 0; 5 10 1];
tform = rigidtform2d(T');

此示例从一个名为 tformPostrigid2d 对象开始,并基于 tformPostT 属性的转置创建一个 rigidtform2d 对象。

T = tformPost.T;
tform = rigidtform2d(T');

此示例基于后乘约定中的旋转矩阵 rot 和平移 trans 创建一个 rigid2d 对象。

theta = 45;
rot = [cosd(theta) sind(theta); -sind(theta) cosd(theta)];
trans = [5 10];
tformPost = rigid2d(rot,trans);

此示例基于旋转矩阵 rot 的转置和平移 trans 创建一个 rigidtform2d 对象。

theta = 45;
rot = [cosd(theta) sind(theta); -sind(theta) cosd(theta)];
trans = [5 10];
tform = rigidtform2d(rot',trans);

您可以通过直接指定旋转角度来简化代码。

tform = rigidtform2d(theta,trans);