bbox2points
Convert rectangle to corner points list
Description
Examples
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
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
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 Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)