bbox2points
Convert rectangle to corner points list
Description
Examples
Convert Bounding Box to List of Points and Apply Rotation
Define a bounding box.
bbox = [10,20,50,60];
Convert the bounding box to a list of four points.
points = bbox2points(bbox);
Define a rotation transformation.
theta = 10; tform = affine2d([cosd(theta) -sind(theta) 0; sind(theta) cosd(theta) 0; 0 0 1]);
Apply the rotation.
points2 = transformPointsForward(tform,points);
Close the polygon for display.
points2(end+1,:) = points2(1,:);
Plot the rotated box.
plot(points2(:,1),points2(:,2), '*-');
Input Arguments
rectangle
— Bounding box
4-element vector | 5-element vector | M-by-4 matrix | M-by-5 matrix
Bounding box, specified as a 4-element vector, 5-element vector, M-by-4 matrix, or M-by-5 matrix.
Bounding Box | Example |
---|---|
For one or more rectangles, specify one of:
| |
![]() |
Data Types: single
| double
| int16
| int32
| uint16
| uint32
Output Arguments
points
— Rectangle corner coordinates
4-by-2 matrix | 4-by-2-by-M array
Rectangle corner coordinates, returned as a 4-by-2 matrix of [x,y] coordinates, or a 4-by-2-by-M array of [x,y] coordinates. The output points for the rectangle are listed counterclockwise starting from the upper-left corner.
For a single input bounding box, the function returns the 4-by-2 matrix.
For multiple input bounding boxes, the function returns the 4-by-2-M array for M bounding boxes.
Data Types: single
| double
| int16
| int32
| uint16
| uint32
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2014b
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 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)