transformPointsForward
Apply forward geometric transformation
Syntax
Description
Examples
Apply Forward Transformation of 2-D Geometric Transformation
Create an affine2d
object that defines the
transformation.
theta = 10; tform = affine2d([cosd(theta) -sind(theta) 0; sind(theta) cosd(theta) 0; 0 0 1])
tform = affine2d with properties: T: [3x3 double] Dimensionality: 2
Apply forward geometric transformation to an input
(u
,v
) point.
[X,Y] = transformPointsForward(tform,5,10)
X = 6.6605 Y = 8.9798
Transform Coordinate Arrays Using Custom 2-D Transformation
Specify the x- and y-coordinates vectors of five points to transform.
x = [10 11 15 2 2]; y = [15 32 34 7 10];
Define the inverse and forward mapping functions. Both functions accept and return points in packed (x,y) format.
inversefn = @(c) [c(:,1).^2,sqrt(c(:,2))]; forwardfn = @(c) [sqrt(c(:,1)),c(:,2).^2];
Create a 2-D geometric transform object, tform
, that stores the inverse mapping function and the optional forward mapping function.
tform = geometricTransform2d(inversefn,forwardfn)
tform = geometricTransform2d with properties: InverseFcn: @(c)[c(:,1).^2,sqrt(c(:,2))] ForwardFcn: @(c)[sqrt(c(:,1)),c(:,2).^2] Dimensionality: 2
Apply the inverse geometric transform to the input points.
[u,v] = transformPointsInverse(tform,x,y)
u = 1×5
100 121 225 4 4
v = 1×5
3.8730 5.6569 5.8310 2.6458 3.1623
Apply the forward geometric transform to the transformed points u
and v
.
[x,y] = transformPointsForward(tform,u,v)
x = 1×5
10 11 15 2 2
y = 1×5
15.0000 32.0000 34.0000 7.0000 10.0000
Apply Forward Transformation of 3-D Geometric Transformation
Create an affine3d
object that defines the
transformation.
tform = affine3d([3 1 2 0;4 5 8 0;6 2 1 0;0 0 0 1])
tform = affine3d with properties: T: [4×4 double] Dimensionality: 3
Apply forward transformation of 3-D geometric transformation to an input
(u
,v
,w
)
point.
[X,Y,Z] = transformPointsForward(tform,2,3,5)
X = 48 Y = 27 Z = 33
Transform Coordinate Arrays Using Custom 3-D Transformation
Specify the x-, y- and the z-coordinate vectors of five points to transform.
x = [3 5 7 9 11]; y = [2 4 6 8 10]; z = [5 9 13 17 21];
Define the inverse and forward mapping functions that accept and return points in packed (x,y,z) format.
inverseFcn = @(c)[c(:,1).^2,c(:,2).^2,c(:,3).^2]; forwardFcn = @(c)[sqrt(c(:,1)),sqrt(c(:,2)),sqrt(c(:,3))];
Create a 3-D geometric transformation object, tform
, that stores these inverse and forward mapping functions.
tform = geometricTransform3d(inverseFcn,forwardFcn)
tform = geometricTransform3d with properties: InverseFcn: @(c)[c(:,1).^2,c(:,2).^2,c(:,3).^2] ForwardFcn: @(c)[sqrt(c(:,1)),sqrt(c(:,2)),sqrt(c(:,3))] Dimensionality: 3
Apply the inverse transformation of this 3-D geometric transformation to the input points.
[u,v,w] = transformPointsInverse(tform,x,y,z)
u = 1×5
9 25 49 81 121
v = 1×5
4 16 36 64 100
w = 1×5
25 81 169 289 441
Apply the forward geometric transform to the transformed points u
, v
, and w
.
[x,y,z] = transformPointsForward(tform,u,v,w)
x = 1×5
3 5 7 9 11
y = 1×5
2 4 6 8 10
z = 1×5
5 9 13 17 21
Input Arguments
tform
— Geometric transformation
geometric transformation object
Geometric transformation, specified as a geometric transformation object.
For 2-D geometric transformations, tform
can be a
rigid2d
, affine2d
, projective2d
, or geometricTransform2d
geometric transformation object.
For 3-D geometric transformations, tform
can be an
affine3d
, rigid3d
, or geometricTransform3d
geometric transformation object.
u
— x-coordinates of points to be transformed
m-by-n or
m-by-n-by-p
numeric array
x-coordinates of points to be transformed, specified as
an m-by-n or
m-by-n-by-p
numeric array. The number of dimensions of u
matches
the dimensionality of tform
.
Data Types: single
| double
v
— y-coordinates of points to be transformed
m-by-n or
m-by-n-by-p
numeric array
y-coordinates of points to be transformed, specified as
an m-by-n or
m-by-n-by-p
numeric array. The size of v
must match the size of
u
.
Data Types: single
| double
U
— Coordinates of points to be transformed
l-by-2 or
l-by-3 numeric array
Coordinates of points to be transformed, specified as an
l-by-2 or
l-by-3 numeric array. The number
of columns of U
matches the dimensionality of
tform
.
The first column lists the x-coordinate of each point
to transform, and the second column lists the
y-coordinate. If tform
represents a
3-D geometric transformation, U
has size
l-by-3 and the third column lists
the z-coordinate of the points to transform.
Data Types: single
| double
Output Arguments
x
— x-coordinates of points after transformation
m-by-n or
m-by-n-by-p
numeric array
x-coordinates of points after transformation, returned
as an m-by-n or
m-by-n-by-p
numeric array. The number of dimensions of x
matches
the dimensionality of tform
.
Data Types: single
| double
y
— y-coordinates of points after transformation
m-by-n or
m-by-n-by-p
numeric array
y-coordinates of points after transformation, returned
as an m-by-n or
m-by-n-by-p
numeric array. The size of y
matches the size of
x
.
Data Types: single
| double
z
— z-coordinates of points after transformation
m-by-n-by-p
numeric array
z-coordinates of points after transformation, returned
as an m-by-n-by-p
numeric array. The size of z
matches the size of
x
.
Data Types: single
| double
X
— Coordinates of points after transformation
numeric array
Coordinates of points after transformation, returned as a numeric array.
The size of X
matches the size of
U
.
The first column lists the x-coordinate of each point
after transformation, and the second column lists the
y-coordinate. If tform
represents a
3-D geometric transformation, the third column lists the
z-coordinate of the points after
transformation.
Data Types: single
| double
Version History
See Also
Apri esempio
Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)