Write a MATLAB-function which determines the center of mass of a domain enclosed by an interpolated curve.
This function has no input or output variables. It opens a figure with a big rectangle on the screen (use for example the property 'position' of a figure). The function then asks the user to put his hand on the rectangle and outline the circumference of his hand with a few dozen mouse clicks. This information can be retrieved with the function ginput. Next, the function interpolates these points with splines to obtain a nice (hand) shape and calculates (approximately) the center of mass. Finally, the function produces a picture of the input points, the interpolated curve, and the area inside the curve, with a clear mark at the center of mass.
1. Give the user instructions on the screen.
2. The function should ignore subsequent clicks on the same point (i.e. a double click of the mouse).
3. Interpolation should be done using pseudo arc-length parametrization.
4. The center of mass of a set Ω ⊂ Rn is given by the vector (∫Ωx→)/(∫Ω 1).
5. A nice way to calculate, for example, the area of an enclosed domain is via Green's theorem: ∫δΩ[f1 dx + f2 dy] + ∫Ω[(δf2/δx) - (δf1/δy)] dxdy.