Rectangle
Parameterizing the Curve
The rectangle is made up of $4$ distinct lines.
So we actually don’t have to parameterize the curve, we can derive the mass and moment of inertia using results from the post on lines.
Mass
The mass is obviously just the perimeter times the mass density, but let’s do it rigorously. To get the total mass, we sum the mass of each line segment ($\ell_1$, $\ell_2$, $\ell_3$, and $\ell_4$), which we derived in the post on lines.
\[\begin{align} M &= M_1 + M_2 + M_3 + M_4 \\[10pt] &= \lambda L_1 + \lambda L_2 + \lambda L_3 + \lambda L_4 \\[10pt] &= \lambda b + \lambda a + \lambda b + \lambda a \\[10pt] &= \lambda \cdot 2(a + b) \end{align}\]Moment of Inertia About Central Axis
Just like in calculating the mass, we can calculate the total moment of inertia by summing the contribution of each line segment ($\ell_1$, $\ell_2$, $\ell_3$, and $\ell_4$). We use the special case formula for the moment of inertia of a line derived in the previous post.
\[\begin{align} I &= I_1 + I_2 + I_3 + I_4 \\[10pt] &= (\tfrac{1}{12} M_1 L_1^2 + M_1 D_1^2) + (\tfrac{1}{12} M_2 L_2^2 + M_2 D_2^2) + (\tfrac{1}{12} M_3 L_3^2 + M_3 D_3^2) + (\tfrac{1}{12} M_4 L_4^2 + M_4 D_4^2) \\[10pt] &= (\tfrac{1}{12} (\lambda b)(b)^2 + (\lambda b)(a/2)^2) + (\tfrac{1}{12} (\lambda a)(a)^2 + (\lambda a)(b/2)^2) + (\tfrac{1}{12} (\lambda b)(b)^2 + (\lambda b)(a/2)^2) + (\tfrac{1}{12} (\lambda a)(a)^2 + (\lambda a)(b/2)^2) \\[10pt] &= (\tfrac{1}{12} \lambda b^3 + \tfrac{1}{4} \lambda a^2b) + (\tfrac{1}{12} \lambda a^3 + \tfrac{1}{4} \lambda ab^2) + (\tfrac{1}{12} \lambda b^3 + \tfrac{1}{4} \lambda a^2b) + (\tfrac{1}{12} \lambda a^3 + \tfrac{1}{4} \lambda ab^2) \\[10pt] &= \tfrac{1}{6} \lambda (a^3 + b^3) + \tfrac{1}{2} \lambda (a^2b + ab^2) \\[10pt] &= \tfrac{1}{6} \lambda (a + b) (a^2 - ab + b^2) + \tfrac{1}{2} \lambda (a + b)ab \\[10pt] &= \lambda \cdot 2(a + b) \cdot \tfrac{1}{12} \left ( (a^2 - ab + b^2) + 3ab \right ) \\[10pt] &= \tfrac{1}{12} M \left ( a^2 + 2ab + b^2 \right ) \\[10pt] &= \tfrac{1}{12} M \left ( a + b \right )^2 \end{align}\]Moment of Inertia About Central Diameter
We do likewise here.
\[\begin{align} I &= I_1 + I_2 + I_3 + I_4 \\[10pt] &= (\tfrac{1}{12} M_1 L_1^2 + M_1 D_1^2) + (M_2 D_2^2) + (\tfrac{1}{12} M_3 L_3^2 + M_3 D_1^3) + (M_4 D_4^2) \\[10pt] &= (\tfrac{1}{12} (\lambda b)(b)^2 + (\lambda b)(0)^2) + ((\lambda a)(b/2)^2) + (\tfrac{1}{12} (\lambda b)(b)^2 + (\lambda b)(0)^2) + ((\lambda a)(b/2)^2) \\[10pt] &= (\tfrac{1}{12} \lambda b^3) + (\tfrac{1}{4} \lambda ab^2) + (\tfrac{1}{12} \lambda b^3) + (\tfrac{1}{4} \lambda ab^2) \\[10pt] &= \tfrac{1}{6} \lambda b^3 + \tfrac{1}{2} \lambda ab^2 \\[10pt] &= \tfrac{1}{6} \lambda b^2 (b + 3a) \\[10pt] &= \tfrac{1}{6} \lambda (a + b) \cdot \frac{b^2 (b + 3a)}{a + b} \\[10pt] &= \tfrac{1}{12} M b^2 \; \frac{3a + b}{a + b} \\[10pt] \end{align}\]Unfortunately, I have not found a way to simplify this any further. If you have any ideas, please let me know.
Inertia Tensor
\[\m{I} = \tfrac{1}{12} M \begin{bmatrix} b^2 \frac{3a+b}{a+b} & 0 & 0 \\ 0 & a^2 \frac{a+3b}{a+b} & 0 \\ 0 & 0 & (a+b)^2 \end{bmatrix}\]Special Case: Square
This is a special case where all sides are equal in length. Therefore, $a = b = S$.