Sie sind auf Seite 1von 7

A MATLAB polygonal integrator

January 2006

Adrian B. Biran, Technion Faculty of Mechanical Engineering, Companion software for the book Ship Hydrostatics and Stability, revised reprint, Oxford, UK, Elsevier Butterworth-Heinemann. Copyright c 2006, A.B. Biran.

Introduction and instructions for use

Many engineering problems require the knowledge of the geometrical properties of a plane gure. This task can be performed by numerical integration using, for example, the trapezoidal or Simpsons rule. Since the invention of the planimeter by Amsler, around 1854, Naval Architects used mechanical analog computers, specically planimeters, integrators and integraphs to calculate the geometrical properties by following a closed contour on the lines drawing or on intermediate, specially-prepared graphs. In this document we describe a MATLAB function that accepts as input the array of coordinates 1

of the vertices of a polygonal gure. Let the coordinates of the i-th point be xi , yi . Then, the function can be called as [ PROPERTIES ] = pintegrator(X);} where

X=

x1

x2 . . . x n x1

y1 y2 . . . yn y1

The output consists of a MATLAB array named PROPERTIES within the programme. This array contains the following geometrical properties of the polygonal gure 1. polygonal area; 2. x-coordinate of centroid; 3. y-coordinate of centroid 4. second moment about barycentric y-axis 5. second moment about barycentric y-axis 6. product of inertia about barycentric axes 7. radius of gyration about barycentric y-axis 8. radius of gyration about barycentric x-axis 9. maximum principal moment of inertia 2

10. minimum principal moment of inertia 11. maximum radius of gyration about principal axes 12. minimum radius of gyration about principal axes These, and additional data are also printed on a le called pintegrator.out. The output stored in the array PROPERTIES can be further processed by any of the available MATLAB tools. A plot of the digitized polygon and its principal axes is also produced. To calculate the area of the polygonal gure, the programme calls the MATLAB built-in function POLYAREA. The calculation of the perimeter is based on repeated invocations of the MATLAB function NORM. The rst and second moments of the polygonal area are calculated by means of Greens theorem. A statement of this theorem is M dx + N dy = M N x y dxdy

where L is the boundary of the area S (see, for example, Finney, 1988, pp. 102739, or ONeil, 2003, p. 5659). Functions M and N suitable for the calculation of the geometrical properties can be found, for example, in a paper by Ken Turkowksi available on the web. The boundary L must be followed in the counterclockwise sense, that is so as to have the area A always on the left of the cursor. If a gure has an axis of symmetry, that axis is also a principal axis. Small errors of digitization can yield wrong principal axes. The error can 3

be important if the two moments of inertia about the barycentric axes are nearly equal. If the coordinates of polygonal vertices must be measured in a given drawing, scan that drawing to obtain a graphic le (for example a JPEG le) and use the function digitizer. For waterlines or other symmetrical gures use the function wldigitizer, for curves of statical stability use the function scdigitizer, and for body plans the function bpdigitizer. The function digitizer calls the function point. Therefore, the le of the latter function must be included in the same directory as the function digitizer.

An example

The le Zfigure.m (stored on the same site with this document) contains the coordinates of the vertices of a Z-shaped gure as exemplied in Beer and Johnston (1998). See Figure 1. Assuming that the dimensions are given in m, the properties of the above gure are

Z test 4

3.5

2.5

1.5

0.5

0 2 1.5 1 0.5 0 0.5 1 1.5 2 2.5 3

Figure 1: A Z-shaped gure area x-coordinate of centroid y-coordinate of centroid moment of inertia about given y-axis moment of inertia about given x-axis product of inertia about given axes moment of inertia about barycentric y-axis moment of inertia about barycentric x-axis product of inertia about barycentric axes angle of principal axes maximum moment of inertia about principal axes 5 minimum moment of inertia about principal axes 4.500 0.250 2.000 7.250 28.375 -4.313 6.969 10.375 -6.563 37.726 15.452 1.892 m2 m m m4 m4 m4 m4 m4 m4 degrees m4 m4

Above we call barycentric axes the axes with the origin of coordinates in the centroid of the gure. Beer and Johnston (1998) call these axes centroidal. To exercise, the reader can call the function with the commands Zfigure [ PROPERTIES ] = pintegrator(Z);

Figure 2: Figure produced by the function pintegrator The function plots the digitized gure and its principal axes as shown in Figure 2.

Bibliography

Beer, F.P., and Johnston, E.R. Jr (1998), Vector mechanics for engineers, 3d SI metric edition, Toronto, McGraw-Hill Ryerson. Finney, R.L. (1988), Calculus and analytic geometry, 7th ed., ReadingMassachusetts, Addison Wesley publishing Company. ONeil, P.V. (2003), Advanced engineering mathematics, 5th ed., Pacic Grove - CA, Thomson Brooks/Cole. Turkowski, K. (1997), Computing 2D polygon moments using Greens Theorem, http://www.worldserver.com/turk/computergraphics/Moments.pdf.

Das könnte Ihnen auch gefallen