We started this lab with explaining how in case of discrete masses, the centre Robeys: Στο m; (r-R) = 0. If the mass dis

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

We started this lab with explaining how in case of discrete masses, the centre Robeys: Στο m; (r-R) = 0. If the mass dis

Post by answerhappygod »

 1
1 (192.69 KiB) Viewed 41 times
QUESTION ONE:
 2
2 (127.99 KiB) Viewed 41 times
We started this lab with explaining how in case of discrete masses, the centre Robeys: Στο m; (r-R) = 0. If the mass distribution is continuous with the density p(r) within a solid Q, we need to replace the discrete sum above by a volume (triple) integral, which transforms the equation above into (r)(r – R)AV = 0. Note that p dV represents infinitesimal elements of mass (density x volume = mass). Solving for the coordinates R, we get 1 R= p(r)rdV, M * 0 where M = ( pdV is the total mass in the volume. If the density p is constant, then R= V + rdV, where V is the total volume. That is for 3-dimensional objects, but our shapes are only 2-dimensional. In that case, we can re-interpet the above result for a plane object S of uniform density by replacing volumes V by areas A. Expressing this independently for the two coordinates of R = (XCM, Ycm), we get Is xda Is yda XCM = and YCM = Isda Isda We can calculate each of these integrals in the usual way, i.e. by (a) dividing the set S into small elements, (b) evaluating the quantity to the right of the sign on each of the elements, and (c) adding these up. Note how, in the denominators, the integral of dA just yields the total area of the object. We are now ready to implement this numerically in Python.
Write a Python function [ ] def area (img, dpi): # some code here to calculate the area of shape area = return area which returns the area in square millimetres of an image, when img is in the form of an array of zeros and ones, and dpi is the resolution of that image in dots per inch. Hint: You may find the np.sum function useful. If M = np.array([[1,2,3],[4,5,6]]) is a 2D array, then np.sum (M, 0) is a 1D array formed by adding all the rows together, yielding array([5,7,9]), while np.sum (M, 1) is a 1D array formed by adding all the columns together, yielding array([6,15]); np.sum(M) adds both ways to give 21. Since your img array only contains 0 and 1's, np.sum(img) is the number of pixels forming your piece. Given the resolution, you can also figure out the surface area corresponding to each pixel. Put it all together to calculate the total surface area of your piece. To figure out the resolution, compare the number of pixels across your shape versus the actual size that you can measure with a ruler on your piece. Note that this may differ between the images of your three pieces. 1 inch = 25.4 mm. Once your function is ready, calculate the surface area of your three pieces with a call like area (F, dpi=100) where Fis the array previously obtained from loading your image files (adjust the dpi value accordingly). List the surface areas you obtain for your three pieces in your report. Make sure to compare them with the surface areas estimated directly from your pieces dimensions (a rough estimate is sufficient if your pieces have complex shapes) and make sure it all makes sense. (If your piece is about 100 by 100 mm, and if your area function returns a values in, say, the billions, there is most likely something wrong.)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply