Help please, I want to find out the Centroid, Area, and the Moment of Inertia of any polygon.
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Help please, I want to find out the Centroid, the Area and the Moment of Inertia of any polygon, from an axis line drawn under that shape.
Then how to make a GUI program that displays a two-dimensional area shape along with its centroid marked on the area. Does it also calculate its moment of inertia for the area and display the result? The user input is an image file containing an arbitrary closed curve shape at the top of the horizontal line indicating the axis about which the moment of inertia is measured (see image below). The length scale is defined by the user referring to the distance between the axis and the centroid determined in the first place.
Thanks in advance
0 comentarios
Respuestas (1)
Naman Kaushik
el 7 de Jun. de 2023
Hi Cristian, I understand that you are trying to find the area, centroid and the moment of inertia for any polygon by providing its vertices.
For the first part of the question, you can use the in-built functions that MATLAB provides. (assuming that you are using R2023A) Here is an example for the same:
To find the centroid of a polygon -
%Enter the x and y values corresponding your need.
x = [0, 2, 2, 0];
y = [0, 0, 1, 1];
vertices = [x', y'];
[X, Y] = centroid(polyshape(vertices));
% X and Y are the coordinates of the centroid
To find the area of a polygon -
x = [0, 2, 2, 0];
y = [0, 0, 1, 1];
vertices = [x', y'];
area = polyarea(vertices(:,1), vertices(:,2))
I guess you forgot to add the image that you are talking about for the moment of inertia part of the question.
As for the GUI, yes you can use MATLAB Appdesigner for the same.
I suggest you to use the two pane application. On one side, you may add the 'Axes' component and on the other you can add the 'Edit field' and 'Button' components which can be used to tweak the parameters according to your need. The button can invoke the call back functions which would perform the above operations.
Here are some useful links that may help -
0 comentarios
Ver también
Categorías
Más información sobre Computational Geometry en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!