--- jupyter: description: 'Areas, centroids and second moments in planex2d: Measure() as a dict, an IPE 200, a T-slot nut and an equal angle with its principal axes, checked against closed forms.' --- # Areas, centroids and second moments The section properties of a profile, its area, centroid and second moments of area, are what a beam calculation needs. `center` is the centroid in 3D, and `Measure()` adds the second moments about it in the plane of the object: - `Ih`, the integral of v², about the h axis; - `Iv`, the integral of h², about the v axis; - `Ihv`, the product moment, the integral of h v; - `I1 ≥ I2`, the principal second moments, and `principal_angle`, the angle of the first principal axis in degrees. ```python import math import planex as px ``` ```python nbsphinx="hidden" from docs_figures import Row, Vertices ``` ## Everything at once `Measure()` returns every measurement of an object as a dict. The example is an IPE 200 beam section without its root radii: 200 high and 100 wide, with flanges 8.5 thick and a web 5.6 thick (Figure 1, with the centroid marked). ```python flange = px.QuickSketch().RectangleC(100, 8.5).Face() web = px.QuickSketch().RectangleC(5.6, 200 - 2 * 8.5).Face() beam = px.Unify([flange.Translated((0, 95.75)), web, flange.Translated((0, -95.75))]) ``` ```python nbsphinx="hide-input" Row((beam, "An IPE 200 and its center", {"marks": [beam.center[:2]]}), caption="An IPE 200 section") ``` ```python m = beam.Measure() for key in ["type", "area", "center", "Ih", "Iv", "I1", "I2", "principal_angle", "bounding_box"]: print(key, m[key]) ``` ## Two sections The first example is a T-slot nut, a flange of 18 × 4 below a neck of 10 × 6, with its centroid marked (Figure 2a). Its half is drawn and mirrored. The centroid of two rectangles lies at v = (A1 v1 + A2 v2) / (A1 + A2). ```python half = px.QuickSketch().Line(9).Line(0, 4).Line(-4, 0).Line(0, 6).Line((0, 10)).Close().Face() nut = half + half.Mirrored((0, 0), (0, 1)) A1, A2 = 18 * 4, 10 * 6 print("nut centroid", nut.center, "exact v", (A1 * 2 + A2 * (4 + 3)) / (A1 + A2)) ``` The second example is a sharp-cornered equal angle of 40 × 40 × 5, with its centroid and its principal axes dashed (Figure 2b). The principal axes lie at 45° to the legs. Its second moments follow from the two rectangles about the outer corner, moved to the centroid. With L = 40 and t = 5: ```python L, t = 40, 5 angle = px.QuickSketch().Line(L).Line(0, t).Line(t - L, 0).Line(0, L - t).Line(-t, 0).Close().Face() m = angle.Measure() A = t * (2 * L - t) c = (L**2 + L * t - t**2) / (2 * (2 * L - t)) I = (t * L**3 + (L - t) * t**3) / 3 - A * c**2 Ihv = t**2 * (2 * L**2 - t**2) / 4 - A * c**2 for key, exact in {"area": A, "Ih": I, "Iv": I, "I1": I + abs(Ihv), "I2": I - abs(Ihv)}.items(): print(key, m[key], "exact", exact) print("principal angle", m["principal_angle"]) ``` ```python nbsphinx="hide-input" cu, cv = angle.center[:2] k = math.radians(m["principal_angle"]) axes = [px.Line((cu - 30 * math.cos(q), cv - 30 * math.sin(q)), (cu + 30 * math.cos(q), cv + 30 * math.sin(q))) for q in (k, k + math.pi / 2)] Row((nut, "A T-slot nut and its centroid", {"marks": [nut.center[:2]]}), (angle, "An equal angle and its principal axes", {"marks": [(cu, cv)], "dashed": axes, "view": ((-8, 48), (-8, 48))}), caption="Centroids and principal axes") ```