diff --git a/NEWS.md b/NEWS.md index 03bd438..b58082f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ * Benchmark results cleaned up (#54). +* Inertia tensor and uncertainty equations layout improved (#57). + # massProps 0.3.2 * Invocation instructions in vignette cleaned up (#41). diff --git a/vignettes/massProps.Rmd b/vignettes/massProps.Rmd index b143408..1e5b860 100644 --- a/vignettes/massProps.Rmd +++ b/vignettes/massProps.Rmd @@ -25,18 +25,15 @@ knitr::opts_chunk$set( \newcommand{\Ixy}{I_{XY}} \newcommand{\Ixz}{I_{XZ}} \newcommand{\Iyz}{I_{YZ}} - \newcommand{\kx}{k_X} \newcommand{\ky}{k_Y} \newcommand{\kz}{k_Z} - \newcommand{\moia}[3]{ \sum_{i=1}^{n} \left[ {I_{#1}}_i + w_i \left( {#2}_i^2 + {#3}_i^2 \right) - w_i \left( \bar{#2}^2 + \bar{#3}^2 \right) \right] } - \newcommand{\moib}[3]{ \sum_{i=1}^{n} \left\{ {I_{#1}}_i + w_i \left[ \left( {#2}_i - \bar{#2} \right)^2 + \left( {#3}_i - \bar{#3} \right)^2 \right] @@ -57,6 +54,9 @@ knitr::opts_chunk$set( \newcommand{\sigmapoi}[3]{\sqrt{ \sum_{i=1}^n \left\{ \sigma_{{I_{#1}}_i}^2 + \left[ \di{#2} w_i \sigma_{{#3}_i}\right]^2 + \left[ \di{#2}\di{#3}\sigma_{w_i} \right]^2 + \left[ \di{#3} w_i \sigma_{{#2}_i} \right]^2 \right\} } } +\newcommand{\phantomeq}{\phantom{=}} +\newcommand{\phantomii}{\phantom{\boldsymbol{I}_i}} +\newcommand{\phantomsigii}{\phantom{{\boldsymbol{\sigma_I}}_i^2}} # Overview @@ -96,7 +96,7 @@ The Mass Property Table must contain the following columns. Other columns may ex - `Iyz` product of inertia relative to the $y$ and $z$ axes (numeric) - - `POIconv` either '+' or '-', indicating the sign convention for products of inertia. In the negative convention, for example, $I_{XY} \equiv -\int{xy \rho \, dV}$. In the positive convention, $I_{XY} \equiv \int{xy \rho \, dV}$. +- `POIconv` either '+' or '-', indicating the sign convention for products of inertia. In the negative convention, for example, $I_{XY} \equiv -\int{xy \rho \, dV}$. In the positive convention, $I_{XY} \equiv \int{xy \rho \, dV}$. - `Ipoint` logical indicator that this item is considered a point mass. The same algebraic result can be achieved by setting all moments and products of inertia to zero, but `rollup_mass_props()` by default ensures that all leaf items in the tree have mass properties that correspond to physically-realizable objects. A zero inertia tensor will fail this check. Rather than relax the check (which is essential for trustworthy results), a `TRUE` value for `Ipoint` indicates that the inertia tensor should be excluded from computations. @@ -155,6 +155,7 @@ Suppose we also have this tree: ```{r echo = FALSE} suppressPackageStartupMessages({library(igraph)}) ``` + ```{r} library(igraph) test_tree @@ -226,7 +227,7 @@ The author has intentionally made no effort to micro-optimize for performance. I In this section, we state the reference equations [@zimmerman:05:sawe] and show, where applicable, how those equations can be rewritten in more concise form. The form of the equations actually implemented is displayed within a box, e.g. $\boxed{F = ma}$. -The reference uses the word *weight* and the symbol $w$ in equations. We interpret weight as mass. The reference refers to center of mass by its $x$, $y$, and $z$ components. Symbols for moments ($\Ixx$) and products ($\Ixy$) of inertia are conventional. Variables with $i$ subscripts designate properties of parts; those without designate properties of aggregates. The letter $\sigma$ denotes uncertainty. $\sigma_w$, for example, is the mass uncertainty. +The reference uses the word *weight* and the symbol $w$ in equations. We interpret weight as mass. The reference refers to center of mass by its $x$, $y$, and $z$ components. Symbols for moments ($I_{XX}$) and products ($I_{XY}$) of inertia are conventional. Variables with $i$ subscripts designate properties of parts; those without designate properties of aggregates. The letter $\sigma$ denotes uncertainty. $\sigma_w$, for example, is the mass uncertainty. ## Mass Properties @@ -289,9 +290,36 @@ The corresponding `R` code is $$ \begin{align} -\Ixx & = \moia{XX}{y}{z} & = \moib{XX}{y}{z} \\ -\Iyy & = \moia{YY}{x}{z} & = \moib{YY}{x}{z} \\ -\Izz & = \moia{ZZ}{x}{y} & = \moib{ZZ}{x}{y} \\ +I_{XX}& = + \sum_{i=1}^{n} \left[ {I_{XX}}_i + + w_i \left( {y}_i^2 + {z}_i^2 \right) + - w_i \left( \bar{y}^2 + \bar{z}^2 \right) + \right] + & = +\sum_{i=1}^{n} \left\{ {I_{XX}}_i + + w_i \left[ \left( {y}_i - \bar{y} \right)^2 + \left( {z}_i - \bar{z} \right)^2 \right] + \right\} + \\ +I_{YY}& = + \sum_{i=1}^{n} \left[ {I_{YY}}_i + + w_i \left( {x}_i^2 + {z}_i^2 \right) + - w_i \left( \bar{x}^2 + \bar{z}^2 \right) + \right] + & = +\sum_{i=1}^{n} \left\{ {I_{YY}}_i + + w_i \left[ \left( {x}_i - \bar{x} \right)^2 + \left( {z}_i - \bar{z} \right)^2 \right] + \right\} + \\ +I_{ZZ}& = + \sum_{i=1}^{n} \left[ {I_{ZZ}}_i + + w_i \left( {x}_i^2 + {y}_i^2 \right) + - w_i \left( \bar{x}^2 + \bar{y}^2 \right) + \right] + & = +\sum_{i=1}^{n} \left\{ {I_{ZZ}}_i + + w_i \left[ \left( {x}_i - \bar{x} \right)^2 + \left( {y}_i - \bar{y} \right)^2 \right] + \right\} + \\ \end{align} $$ @@ -299,9 +327,9 @@ $$ $$ \begin{align} -\Ixy & = \poia{XY}{x}{y} & = \poib{XY}{x}{y} \\ -\Ixz & = \poia{XZ}{x}{z} & = \poib{XZ}{x}{z} \\ -\Iyz & = \poia{YZ}{y}{z} & = \poib{YZ}{y}{z} \\ +I_{XY}& = \sum_{i=1}^{n} \left[ {I_{XY}}_i + w_i {{x}_i}{{y}_i} -w_i (\bar{x}\bar{y})\right] & = \sum_{i=1}^{n} \left[ {I_{XY}}_i + w_i ({x}_i - \bar{x})({y}_i - \bar{y})\right] \\ +I_{XZ}& = \sum_{i=1}^{n} \left[ {I_{XZ}}_i + w_i {{x}_i}{{z}_i} -w_i (\bar{x}\bar{z})\right] & = \sum_{i=1}^{n} \left[ {I_{XZ}}_i + w_i ({x}_i - \bar{x})({z}_i - \bar{z})\right] \\ +I_{YZ}& = \sum_{i=1}^{n} \left[ {I_{YZ}}_i + w_i {{y}_i}{{z}_i} -w_i (\bar{y}\bar{z})\right] & = \sum_{i=1}^{n} \left[ {I_{YZ}}_i + w_i ({y}_i - \bar{y})({z}_i - \bar{z})\right] \\ \end{align} $$ @@ -312,20 +340,20 @@ Let $\boldsymbol{I}$ be the inertia tensor of the aggregate and $\boldsymbol{I}_ $$ \boldsymbol{I} = \left[ \begin{array}{rrr} -\Ixx & -\Ixy & -\Ixz \\ - -\Ixy & \Iyy & -\Iyz \\ - -\Ixz & -\Iyz & \Izz \\ +I_{XX}& -I_{XY}& -I_{XZ}\\ + -I_{XY}& I_{YY}& -I_{YZ}\\ + -I_{XZ}& -I_{YZ}& I_{ZZ}\\ \end{array} \right] $$ and similarly for $\boldsymbol{I}_i$. -Noting the repeated appearance of terms of the form $\di{x}\di{y}$, we form the outer product +Noting the repeated appearance of terms of the form $({x}_i - \bar{x})({y}_i - \bar{y})$, we form the outer product $$ \boxed{ \begin{align} -\boldsymbol{d}_i & = (\di{x} \quad \di{y} \quad \di{z})^T \\ +\boldsymbol{d}_i & = (({x}_i - \bar{x}) \quad ({y}_i - \bar{y}) \quad ({z}_i - \bar{z}))^T \\ \boldsymbol{Q}_i & = \boldsymbol{d}_i {\boldsymbol{d}_i}^T \end{align} } @@ -335,9 +363,9 @@ $$ \begin{align} \boldsymbol{Q}_i & = \begin{bmatrix} -\di{x}^2 & \di{x}\di{y} & \di{x}\di{z} \\ -\di{y}\di{x} & \di{y}^2 & \di{y}\di{z} \\ -\di{z}\di{x} & \di{z}\di{y} & \di{z}^2 \\ +({x}_i - \bar{x})^2 & ({x}_i - \bar{x})({y}_i - \bar{y}) & ({x}_i - \bar{x})({z}_i - \bar{z}) \\ +({y}_i - \bar{y})({x}_i - \bar{x}) & ({y}_i - \bar{y})^2 & ({y}_i - \bar{y})({z}_i - \bar{z}) \\ +({z}_i - \bar{z})({x}_i - \bar{x}) & ({z}_i - \bar{z})({y}_i - \bar{y}) & ({z}_i - \bar{z})^2 \\ \end{bmatrix} \end{align} $$ @@ -348,34 +376,23 @@ $$ \boldsymbol{I} = \sum_{i=1}^{n} \boldsymbol{s}_i $$ -where $$ -\begin{align} -\boldsymbol{s}_i & = \boldsymbol{I}_i \\ -& - -w_i \begin{bmatrix} --\di{y}^2 - \di{z}^2 & \di{x}\di{y} & \di{x}\di{z} \\ -\di{x}\di{y} & -\di{x}^2 - \di{z}^2 & \di{y}\di{z} \\ -\di{x}\di{z} & \di{y}\di{z} & -\di{x}^2 - \di{y}^2 \\ -\end{bmatrix} \\ -& = -\boldsymbol{I}_i \\ -& - -w_i \begin{bmatrix} -\di{x}^2 & \di{x}\di{y} & \di{x}\di{z} \\ -\di{x}\di{y} & \di{y}^2 & \di{y}\di{z} \\ -\di{x}\di{z} & \di{y}\di{z} & \di{z}^2 \\ -\end{bmatrix} \\ -& - -w_i \begin{bmatrix} --\di{x}^2 - \di{y}^2 - \di{z}^2 & 0 & 0 \\ -0 & -\di{x}^2 - \di{y}^2 - \di{z}^2 & 0 \\ -0 & 0 &-\di{x}^2 - \di{y}^2 - \di{z}^2 \\ -\end{bmatrix} \\ -& = -\boldsymbol{I}_i -- -w_i \left( \boldsymbol{Q}_i - \mathrm{tr}(\boldsymbol{Q}_i) \boldsymbol{1}_3 \right) -\end{align} +where + +$$ +\begin{aligned} +\boldsymbol{s}_i & = \boldsymbol{I}_i - w_i \begin{bmatrix} + -({y}_i - \bar{y})^2 - ({z}_i - \bar{z})^2 & ({x}_i - \bar{x})({y}_i - \bar{y}) & ({x}_i - \bar{x})({z}_i - \bar{z}) \\ + ({x}_i - \bar{x})({y}_i - \bar{y}) & -({x}_i - \bar{x})^2 - ({z}_i - \bar{z})^2 & ({y}_i - \bar{y})({z}_i - \bar{z}) \\ + ({x}_i - \bar{x})({z}_i - \bar{z}) & ({y}_i - \bar{y})({z}_i - \bar{z}) & -({x}_i - \bar{x})^2 - ({y}_i - \bar{y})^2 \\ + \end{bmatrix} \\ + & = \boldsymbol{I}_i - w_i \left( \begin{bmatrix} + ({x}_i - \bar{x})^2 & ({x}_i - \bar{x})({y}_i - \bar{y}) & ({x}_i - \bar{x})({z}_i - \bar{z}) \\ + ({x}_i - \bar{x})({y}_i - \bar{y}) & ({y}_i - \bar{y})^2 & ({y}_i - \bar{y})({z}_i - \bar{z}) \\ + ({x}_i - \bar{x})({z}_i - \bar{z}) & ({y}_i - \bar{y})({z}_i - \bar{z}) & ({z}_i - \bar{z})^2 \\ + \end{bmatrix} + - \left(({x}_i - \bar{x})^2 + ({y}_i - \bar{y})^2 + ({z}_i - \bar{z})^2 \right) \boldsymbol{1}_3 \right) \\ + & = \boldsymbol{I}_i - w_i \left( \boldsymbol{Q}_i - \mathrm{tr}(\boldsymbol{Q}_i) \boldsymbol{1}_3 \right) +\end{aligned} $$ where $\mathrm{tr}(\boldsymbol{Q}_i)$ is the *trace* of $\boldsymbol{Q}_i$, i.e., the sum of its diagonal elements, and $\boldsymbol{1}_3$ is the 3⨉3 identity matrix. Therefore @@ -430,9 +447,18 @@ The corresponding `R` code is $$ \begin{align} -\sigma_\bar{x} & = \sigmacm{x} \\ -\sigma_\bar{y} & = \sigmacm{y} \\ -\sigma_\bar{z} & = \sigmacm{z} \\ +\sigma_\bar{x} & = + \sqrt{ \sum_{i=1}^n \left\{ (w_i {{\sigma_\bar{x}}}_i)^2 + [{\sigma_w}_i ({x}_i - \bar{x})]^2 \right\} } + \bigg/ \sum_{i=1}^{n}w_i \\ + \\ +\sigma_\bar{y} & = + \sqrt{ \sum_{i=1}^n \left\{ (w_i {{\sigma_\bar{y}}}_i)^2 + [{\sigma_w}_i ({y}_i - \bar{y})]^2 \right\} } + \bigg/ \sum_{i=1}^{n}w_i \\ + \\ +\sigma_\bar{z} & = + \sqrt{ \sum_{i=1}^n \left\{ (w_i {{\sigma_\bar{z}}}_i)^2 + [{\sigma_w}_i ({z}_i - \bar{z})]^2 \right\} } + \bigg/ \sum_{i=1}^{n}w_i \\ + \\ \end{align} $$ @@ -474,9 +500,15 @@ The corresponding `R` code is $$ \begin{align} -\sigma_{\Ixx} & = \sigmamoi{XX}{y}{z} \\ -\sigma_{\Iyy} & = \sigmamoi{YY}{x}{z} \\ -\sigma_{\Izz} & = \sigmamoi{ZZ}{x}{y} \\ +\sigma_{I_{XX}} & = \sqrt{ \sum_{i=1}^n \left\{ + \sigma_{{I_{XX}}_i}^2 + \left[ 2 w_i ({y}_i - \bar{y}) \sigma_{{y}_i} \right]^2 + \left[ 2 w_i ({z}_i - \bar{z}) \sigma_{{z}_i} \right]^2 + \left[ \left(({y}_i - \bar{y})^2 + ({z}_i - \bar{z})^2 \right)\sigma_{w_i}\right]^2 \right\} } + \\ +\sigma_{I_{YY}} & = \sqrt{ \sum_{i=1}^n \left\{ + \sigma_{{I_{YY}}_i}^2 + \left[ 2 w_i ({x}_i - \bar{x}) \sigma_{{x}_i} \right]^2 + \left[ 2 w_i ({z}_i - \bar{z}) \sigma_{{z}_i} \right]^2 + \left[ \left(({x}_i - \bar{x})^2 + ({z}_i - \bar{z})^2 \right)\sigma_{w_i}\right]^2 \right\} } + \\ +\sigma_{I_{ZZ}} & = \sqrt{ \sum_{i=1}^n \left\{ + \sigma_{{I_{ZZ}}_i}^2 + \left[ 2 w_i ({x}_i - \bar{x}) \sigma_{{x}_i} \right]^2 + \left[ 2 w_i ({y}_i - \bar{y}) \sigma_{{y}_i} \right]^2 + \left[ \left(({x}_i - \bar{x})^2 + ({y}_i - \bar{y})^2 \right)\sigma_{w_i}\right]^2 \right\} } + \\ \end{align} $$ @@ -484,9 +516,15 @@ $$ $$ \begin{align} -\sigma_{\Ixy} & = \sigmapoi{XY}{x}{y} \\ -\sigma_{\Ixz} & = \sigmapoi{XZ}{x}{z} \\ -\sigma_{\Iyz} & = \sigmapoi{YZ}{y}{z} \\ +\sigma_{I_{XY}} & = \sqrt{ \sum_{i=1}^n \left\{ + \sigma_{{I_{XY}}_i}^2 + \left[ ({x}_i - \bar{x}) w_i \sigma_{{y}_i}\right]^2 + \left[ ({x}_i - \bar{x})({y}_i - \bar{y})\sigma_{w_i} \right]^2 + \left[ ({y}_i - \bar{y}) w_i \sigma_{{x}_i} \right]^2 \right\} } + \\ +\sigma_{I_{XZ}} & = \sqrt{ \sum_{i=1}^n \left\{ + \sigma_{{I_{XZ}}_i}^2 + \left[ ({x}_i - \bar{x}) w_i \sigma_{{z}_i}\right]^2 + \left[ ({x}_i - \bar{x})({z}_i - \bar{z})\sigma_{w_i} \right]^2 + \left[ ({z}_i - \bar{z}) w_i \sigma_{{x}_i} \right]^2 \right\} } + \\ +\sigma_{I_{YZ}} & = \sqrt{ \sum_{i=1}^n \left\{ + \sigma_{{I_{YZ}}_i}^2 + \left[ ({y}_i - \bar{y}) w_i \sigma_{{z}_i}\right]^2 + \left[ ({y}_i - \bar{y})({z}_i - \bar{z})\sigma_{w_i} \right]^2 + \left[ ({z}_i - \bar{z}) w_i \sigma_{{y}_i} \right]^2 \right\} } + \\ \end{align} $$ @@ -497,7 +535,7 @@ Let $$ \boxed{ \begin{align} -\boldsymbol{d}_i & = (\di{x} \quad \di{y} \quad \di{z})^T \\ +\boldsymbol{d}_i & = (({x}_i - \bar{x}) \quad ({y}_i - \bar{y}) \quad ({z}_i - \bar{z}))^T \\ {\boldsymbol{\sigma_c}}_i & = ({\sigma_\bar{x}}_i \quad {\sigma_\bar{y}}_i \quad {\sigma_\bar{z}}_i)^T \\ \boldsymbol{P}_i & = \boldsymbol{d}_i {\boldsymbol{\sigma_c}}_i^T \\ \boldsymbol{Q}_i & = \boldsymbol{d}_i {\boldsymbol{d}_i}^T @@ -511,17 +549,17 @@ $$ \begin{align} \boldsymbol{P}_i & = \begin{bmatrix} -\di{x}\sigma_{x_i} &\di{x}\sigma_{y_i} &\di{x}\sigma_{z_i} \\ -\di{y}\sigma_{x_i} & \di{y}\sigma_{y_i} & \di{y}\sigma_{z_i} \\ -\di{z}\sigma_{x_i} & \di{z}\sigma_{y_i} & \di{z}\sigma_{z_i} \\ +({x}_i - \bar{x})\sigma_{x_i} &({x}_i - \bar{x})\sigma_{y_i} &({x}_i - \bar{x})\sigma_{z_i} \\ +({y}_i - \bar{y})\sigma_{x_i} & ({y}_i - \bar{y})\sigma_{y_i} & ({y}_i - \bar{y})\sigma_{z_i} \\ +({z}_i - \bar{z})\sigma_{x_i} & ({z}_i - \bar{z})\sigma_{y_i} & ({z}_i - \bar{z})\sigma_{z_i} \\ \end{bmatrix} \\ \\ \boldsymbol{Q}_i & = \begin{bmatrix} -\di{x}^2 &\di{x}\di{y} &\di{x}\di{z} \\ -\di{y}\di{x} & \di{y}^2 & \di{y}\di{z} \\ -\di{z}\di{x} & \di{z}\di{y} & \di{z}^2 \\ +({x}_i - \bar{x})^2 &({x}_i - \bar{x})({y}_i - \bar{y}) &({x}_i - \bar{x})({z}_i - \bar{z}) \\ +({y}_i - \bar{y})({x}_i - \bar{x}) & ({y}_i - \bar{y})^2 & ({y}_i - \bar{y})({z}_i - \bar{z}) \\ +({z}_i - \bar{z})({x}_i - \bar{x}) & ({z}_i - \bar{z})({y}_i - \bar{y}) & ({z}_i - \bar{z})^2 \\ \end{bmatrix} \end{align} $$ @@ -532,49 +570,51 @@ $$ \boldsymbol{\sigma_I}^2 = \sum_{i=1}^{n} \boldsymbol{s}_i^2 $$ -Let ${p_X}_i$, ${p_Y}_i$, and ${p_Z}_i$ be the respective diagonal elements of $P_i$. Let $\boldsymbol{1}_3$ be the 3 ⨉ 3 identity matrix. If we interpret squaring a matrix as the Hadamard (element-wise) product with itself, then $$ +Let ${p_X}_i$, ${p_Y}_i$, and ${p_Z}_i$ be the respective diagonal elements of $P_i$. Let $\boldsymbol{1}_3$ be the 3 ⨉ 3 identity matrix. If we interpret squaring a matrix as the Hadamard (element-wise) product with itself, then + +$$ \begin{align} -\boldsymbol{s}_i^2 & = {\boldsymbol{\sigma_I}}_i^2 \\ -& + +\boldsymbol{s}_i^2 & = {\boldsymbol{\sigma_I}}_i^2 ++ \begin{bmatrix} -2 w_i \di{y} \sigma_{y_i} & w_i\di{x} \sigma_{y_i} & w_i\di{x} \sigma_{z_i} \\ - w_i\di{x} \sigma_{y_i} & 2 w_i\di{x} \sigma_{x_i} & w_i \di{y} \sigma_{z_i} \\ - w_i\di{x} \sigma_{z_i} & w_i \di{y} \sigma_{z_i} & 2 w_i\di{x} \sigma_{x_i} +2 w_i ({y}_i - \bar{y}) \sigma_{y_i} & w_i({x}_i - \bar{x}) \sigma_{y_i} & w_i({x}_i - \bar{x}) \sigma_{z_i} \\ + w_i({x}_i - \bar{x}) \sigma_{y_i} & 2 w_i({x}_i - \bar{x}) \sigma_{x_i} & w_i ({y}_i - \bar{y}) \sigma_{z_i} \\ + w_i({x}_i - \bar{x}) \sigma_{z_i} & w_i ({y}_i - \bar{y}) \sigma_{z_i} & 2 w_i({x}_i - \bar{x}) \sigma_{x_i} \end{bmatrix}^2 \\ -& + +& \mathrel{\phantomeq} \phantomsigii + \begin{bmatrix} -2 w_i \di{z} \sigma_{z_i} & w_i \di{y} \sigma_{x_i} & w_i \di{z} \sigma_{x_i} \\ - w_i \di{y} \sigma_{x_i} & 2 w_i \di{z} \sigma_{z_i} & w_i \di{z} \sigma_{y_i} \\ - w_i \di{z} \sigma_{x_i} & w_i \di{z} \sigma_{y_i} & 2 w_i \di{y} \sigma_{y_i} +2 w_i ({z}_i - \bar{z}) \sigma_{z_i} & w_i ({y}_i - \bar{y}) \sigma_{x_i} & w_i ({z}_i - \bar{z}) \sigma_{x_i} \\ + w_i ({y}_i - \bar{y}) \sigma_{x_i} & 2 w_i ({z}_i - \bar{z}) \sigma_{z_i} & w_i ({z}_i - \bar{z}) \sigma_{y_i} \\ + w_i ({z}_i - \bar{z}) \sigma_{x_i} & w_i ({z}_i - \bar{z}) \sigma_{y_i} & 2 w_i ({y}_i - \bar{y}) \sigma_{y_i} \end{bmatrix}^2 \\ -& + +& \mathrel{\phantomeq} \phantomsigii + \begin{bmatrix} -(\di{y}^2 + \di{z}^2)\sigma_{w_i} &\di{x}\di{y}\sigma_{w_i} &\di{x}\di{z}\sigma_{w_i} \\ -\di{y}\di{x}\sigma_{w_i} & (\di{x}^2 + \di{z}^2)\sigma_{w_i} & \di{y}\di{z}\sigma_{w_i} \\ -\di{z}\di{x}\sigma_{w_i} & \di{z}\di{y}\sigma_{w_i} & (\di{x}^2 + \di{y}^2)\sigma_{w_i} \\ +(({y}_i - \bar{y})^2 + ({z}_i - \bar{z})^2)\sigma_{w_i} &({x}_i - \bar{x})({y}_i - \bar{y})\sigma_{w_i} &({x}_i - \bar{x})({z}_i - \bar{z})\sigma_{w_i} \\ +({y}_i - \bar{y})({x}_i - \bar{x})\sigma_{w_i} & (({x}_i - \bar{x})^2 + ({z}_i - \bar{z})^2)\sigma_{w_i} & ({y}_i - \bar{y})({z}_i - \bar{z})\sigma_{w_i} \\ +({z}_i - \bar{z})({x}_i - \bar{x})\sigma_{w_i} & ({z}_i - \bar{z})({y}_i - \bar{y})\sigma_{w_i} & (({x}_i - \bar{x})^2 + ({y}_i - \bar{y})^2)\sigma_{w_i} \\ \end{bmatrix}^2 \\ \\ -& = {\boldsymbol{\sigma_I}}_i^2 \\ -& + w_i^2 \left( +& = {\boldsymbol{\sigma_I}}_i^2 ++ w_i^2 \left( \boldsymbol{P}_i - \begin{bmatrix} -\di{x}\sigma_{x_i} - 2 \di{y}\sigma_{y_i} & 0 & 0 \\ -0 & \di{y}\sigma_{y_i} - 2\di{x}\sigma_{x_i} & 0 \\ -0 & 0 & \di{z}\sigma_{y_i} - 2\di{x}\sigma_{x_i} \\ +({x}_i - \bar{x})\sigma_{x_i} - 2 ({y}_i - \bar{y})\sigma_{y_i} & 0 & 0 \\ +0 & ({y}_i - \bar{y})\sigma_{y_i} - 2({x}_i - \bar{x})\sigma_{x_i} & 0 \\ +0 & 0 & ({z}_i - \bar{z})\sigma_{y_i} - 2({x}_i - \bar{x})\sigma_{x_i} \\ \end{bmatrix} \right) ^2 \\ -& + w_i^2 \left( +& \mathrel{\phantomeq} \phantomsigii + w_i^2 \left( \boldsymbol{P}_i^T - \begin{bmatrix} -\di{x}\sigma_{x_i} - 2 \di{z}\sigma_{y_i} & 0 & 0 \\ -0 & \di{y}\sigma_{y_i} - 2 \di{z}\sigma_{z_i} & 0 \\ -0 & 0 & \di{z}\sigma_{y_i} - 2 \di{y}\sigma_{y_i} \\ +({x}_i - \bar{x})\sigma_{x_i} - 2 ({z}_i - \bar{z})\sigma_{y_i} & 0 & 0 \\ +0 & ({y}_i - \bar{y})\sigma_{y_i} - 2 ({z}_i - \bar{z})\sigma_{z_i} & 0 \\ +0 & 0 & ({z}_i - \bar{z})\sigma_{y_i} - 2 ({y}_i - \bar{y})\sigma_{y_i} \\ \end{bmatrix} \right) ^2 \\ -& + \sigma_{w_i}^2 \left( +& \mathrel{\phantomeq} \phantomsigii + \sigma_{w_i}^2 \left( \boldsymbol{Q}_i - \mathrm{tr}(\boldsymbol{Q}_i)\boldsymbol{1}_3 \right)^2 \\ \\ -& = {\boldsymbol{\sigma_I}}_i^2 \\ -& + w_i^2 \left( +& = {\boldsymbol{\sigma_I}}_i^2 ++ w_i^2 \left( \boldsymbol{P}_i - \begin{bmatrix} {p_X}_i - 2 {p_Y}_i & 0 & 0 \\ @@ -582,7 +622,7 @@ Let ${p_X}_i$, ${p_Y}_i$, and ${p_Z}_i$ be the respective diagonal elements of $ 0 & 0 & {p_Z}_i - 2 {p_X}_i \\ \end{bmatrix} \right) ^2 \\ -& + w_i^2 \left( +& \mathrel{\phantomeq} \phantomsigii + w_i^2 \left( \boldsymbol{P}_i^T - \begin{bmatrix} {p_X}_i - 2{p_Z}_i & 0 & 0 \\ @@ -590,7 +630,7 @@ Let ${p_X}_i$, ${p_Y}_i$, and ${p_Z}_i$ be the respective diagonal elements of $ 0 & 0 & {p_Z}_i - 2 {p_Y}_i \\ \end{bmatrix} \right) ^2 \\ -& + \sigma_{w_i}^2 \left( +& \mathrel{\phantomeq} \phantomsigii + \sigma_{w_i}^2 \left( \boldsymbol{Q}_i - \mathrm{tr}(\boldsymbol{Q}_i)\boldsymbol{1}_3 \right)^2 \end{align} @@ -666,17 +706,17 @@ By definition: $$ \begin{align} -\kx & = \sqrt{\Ixx / w} \\ -\ky & = \sqrt{\Iyy / w} \\ -\kz & = \sqrt{\Izz / w} \\ +k_X& = \sqrt{I_{XX}/ w} \\ +k_Y& = \sqrt{I_{YY}/ w} \\ +k_Z& = \sqrt{I_{ZZ}/ w} \\ \end{align} $$ Let $$ \boxed{ \begin{align} -\boldsymbol{k} & = (\kx \quad \ky \quad \kz)^T \\ -\boldsymbol{I} & = (\Ixx \quad \Iyy \quad \Izz)^T +\boldsymbol{k} & = (k_X\quad k_Y\quad k_Z)^T \\ +\boldsymbol{I} & = (I_{XX}\quad I_{YY}\quad I_{ZZ})^T \end{align} } $$ Then @@ -701,12 +741,11 @@ Let $$ \boxed{ \begin{align} -\sigma_\boldsymbol{k} & = (\sigma_{\kx} \quad \sigma_{\ky} \quad \sigma_{\kz})^T \\ -\sigma_\boldsymbol{I} & = (\sigma_{\Ixx} \quad \sigma_{\Iyy} \quad \sigma_{\Izz})^T +\sigma_\boldsymbol{k} & = (\sigma_{k_X} \quad \sigma_{k_Y} \quad \sigma_{k_Z})^T \\ +\sigma_\boldsymbol{I} & = (\sigma_{I_{XX}} \quad \sigma_{I_{YY}} \quad \sigma_{I_{ZZ}})^T \end{align} } -$$ -Then +$$ Then $$ \begin{align} @@ -714,47 +753,40 @@ $$ & \approx \left( \frac{1}{2 \sqrt{w \boldsymbol{I}}} \right)^2 {\sigma_\boldsymbol{I}}^2 + \left(\frac{- \sqrt{\boldsymbol{I}}}{2 w^{3/2}}\right)^2 {\sigma_w}^2 + 2 \left( \frac{1}{2 \sqrt{w \boldsymbol{I}}} \right) \left(\frac{- \sqrt{\boldsymbol{I}}}{2 w^{3/2}}\right) \sigma_{\boldsymbol{I}w} \\ & \approx \frac{1}{4 w \boldsymbol{I}} {\sigma_\boldsymbol{I}}^2 + \frac{\boldsymbol{I}}{4 w^3} {\sigma_w}^2 - \frac{1}{2 w^2} \sigma_{\boldsymbol{I}w} \\ \end{align} -$$ -where $\sigma_{\boldsymbol{I}w}$ is the covariance between $\boldsymbol{I}$ and $w$. +$$ where $\sigma_{\boldsymbol{I}w}$ is the covariance between $\boldsymbol{I}$ and $w$. Let $W$ and $X$ be random variables such that $$ \begin{align} W & = \sum_{i=1}^{n} (w_i + {\epsilon_w}_i) \\ -X & = \sum_{i=1}^{n} \left\{ {\Ixx}_i + {\epsilon_\Ixx}_i +X & = \sum_{i=1}^{n} \left\{ {I_{XX}}_i + {\epsilon_I_{XX}}_i + (w_i + {\epsilon_w}_i) \left[ \left( {y}_i - \bar{y} \right)^2 + \left( {z}_i - \bar{z} \right)^2 \right] \right\} \\ \end{align} -$$ -where $E[{\epsilon_w}_i] = 0$ and $E[{\epsilon_\Ixx}_i] = 0$ for all $i$, -$E[{\epsilon_w}_i {\epsilon_w}_j] = 0$ and $E[{\epsilon_\Ixx}_i {\epsilon_\Ixx}_j] = 0$ for all $i \neq j$, and -$E[{\epsilon_w}_i {\epsilon_\Ixx}_j] = 0$ for all $i$ and $j$. It is clear from the linearity of $W$ and $X$ in $w_i$ and $\Ixx_i$ that +$$ where $E[{\epsilon_w}_i] = 0$ and $E[{\epsilon_I_{XX}}_i] = 0$ for all $i$, $E[{\epsilon_w}_i {\epsilon_w}_j] = 0$ and $E[{\epsilon_I_{XX}}_i {\epsilon_I_{XX}}_j] = 0$ for all $i \neq j$, and $E[{\epsilon_w}_i {\epsilon_I_{XX}}_j] = 0$ for all $i$ and $j$. It is clear from the linearity of $W$ and $X$ in $w_i$ and $I_{XX}_i$ that $$ E[W] = E \left[\sum_{i=1}^{n} (w_i + {\epsilon_w}_i) \right] = w + \sum_{i=1}^{n} {\epsilon_w}_i = w -$$ -and -$$ +$$ and $$ \begin{align} -E[X] & = E \left[ \sum_{i=1}^{n} \left\{ {\Ixx}_i + {\epsilon_{\Ixx}}_i +E[X] & = E \left[ \sum_{i=1}^{n} \left\{ {I_{XX}}_i + {\epsilon_{I_{XX}}}_i + (w_i + {\epsilon_w}_i) \left[ \left( {y}_i - \bar{y} \right)^2 + \left( {z}_i - \bar{z} \right)^2 \right] \right\} \right] \\ -& = \Ixx + E \left[ \sum_{i=1}^{n} \left\{ {\epsilon_{\Ixx}}_i +& = I_{XX}+ E \left[ \sum_{i=1}^{n} \left\{ {\epsilon_{I_{XX}}}_i + {\epsilon_w}_i \left[ \left( {y}_i - \bar{y} \right)^2 + \left( {z}_i - \bar{z} \right)^2 \right] \right\} \right] \\ -& = \Ixx +& = I_{XX} \end{align} -$$ -Therefore, +$$ Therefore, $$ \begin{align} -\sigma_{\Ixx w} & = E \left[ \left( W - E[W] \right) \left( X - E[X] \right)\right] \\ +\sigma_{I_{XX}w} & = E \left[ \left( W - E[W] \right) \left( X - E[X] \right)\right] \\ & = E \left[ \sum_{i=1}^{n} {\epsilon_w}_i - \sum_{j=1}^{n} \left\{ {\epsilon_{\Ixx}}_j + \sum_{j=1}^{n} \left\{ {\epsilon_{I_{XX}}}_j + {\epsilon_w}_j \left[ \left( {y}_j - \bar{y} \right)^2 + \left( {z}_j - \bar{z} \right)^2 \right] \right\} \right] \\ & = \sum_{i=1}^{n} - \sum_{j=1}^{n} E \left[ {\epsilon_w}_i \left\{ {\epsilon_{\Ixx}}_j + \sum_{j=1}^{n} E \left[ {\epsilon_w}_i \left\{ {\epsilon_{I_{XX}}}_j + {\epsilon_w}_j \left[ \left( {y}_j - \bar{y} \right)^2 + \left( {z}_j - \bar{z} \right)^2 \right] \right\} \right] \\ & = \sum_{i=1}^{n} E \left[ {\epsilon_w}^2_i \right] \left[ \left( {y}_i - \bar{y} \right)^2 + \left( {z}_i - \bar{z} \right)^2 \right] \\ & = \sum_{i=1}^{n} {\sigma_w}^2_i \left[ \left( {y}_i - \bar{y} \right)^2 + \left( {z}_i - \bar{z} \right)^2 \right] \\ @@ -777,8 +809,7 @@ $$ {\sigma_\boldsymbol{k}}^2 & \approx \frac{1}{4 w \boldsymbol{I}} {\sigma_\boldsymbol{I}}^2 + \frac{\boldsymbol{I}}{4 w^3} {\sigma_w}^2 - \frac{1}{2 w^2} \sum_{i=1}^{n} {\sigma_w}^2_i (\boldsymbol{s}_i - \boldsymbol{d}_i^2 ) \\ \end{align} -$$ -Therefore, we define +$$ Therefore, we define $$ \boxed{ @@ -790,7 +821,7 @@ $$ } $$ -The corresponding R code is +The corresponding R code is ``` r amp <- get_mass_props_and_unc(ds, target) @@ -811,7 +842,7 @@ The corresponding R code is init = c(0, 0, 0) ) ) / 2 - ``` +``` # Testing and Validation @@ -1114,7 +1145,7 @@ no <- (nv - nl) * 20 Benchmarks were taken on a platform with these CPU characteristics: -``` +``` Python Version: 3.12.7.final.0 (64 bit) Cpuinfo Version: 9.0.0 Vendor ID Raw: @@ -1157,7 +1188,7 @@ benchmark('mp + unc ' = rollup_mass_props_and_unc_fast(mp_tree, mp_t Times reported are in seconds. -``` +``` test elapsed user.self sys.self 3 mp 0.6754 0.6632 0.0123 4 mp + validation 0.9793 0.9651 0.0143