How to create a bounding box with a right angled triangle.

5 visualizaciones (últimos 30 días)
Sai Kiran Maryada
Sai Kiran Maryada el 16 de Sept. de 2019
Respondida: Ajay Pattassery el 19 de Sept. de 2019
Hello,
I'm new to matlab. Could any one help me how to create a bounding box with right angled triangle say the coordinates are (0, 0) (100, 0), (0, 150).
Thank you.

Respuestas (1)

Ajay Pattassery
Ajay Pattassery el 19 de Sept. de 2019
I assume that a bounding box is needed to be drawn over a right-angled triangle.
x1 = [0 1 0];
y1 = [0 0 1];
polyin = polyshape(x1,y1);
[xlim,ylim] = boundingbox(polyin);
plot(polyin)
hold on
rectangle('position',[xlim(1),ylim(1),xlim(2),ylim(2)])
The polyshape function create a 2-D polygon, here a right-angled triangle with the given vertices values.
The boundingbox function returns the x,y bounds of the smallest rectangle enclosing the triangle.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by