moments: Second moment tensor

View source: R/moments.R

momentsR Documentation

Second moment tensor

Description

Compute the tensor of second moments of a set of point masses

Usage

moments(x, m = 1)

Arguments

x

n-by-3 matrix (x[1:n,1:3]) specifying the 3D Cartesian coordinates of n points

m

n-vector with point masses, or single scalar giving a uniform mass for all points (default is unity)

Value

Returns a 3-by-3 symmetric matrix

Author(s)

Danail Obreschkow

See Also

inertia, quadrupole

Examples

# Make a randomly oriented ellipsoid of semi-axes a=2.1, b=1.73, c=0.8
x = t(t(fibonaccisphere(1e4))*c(2.1,1.73,0.8))
x = x%*%rotation3(c(0.3,1.64,2.31))

# Recover lengths of semi-axes from eigenvalues of second moment tensor
M = moments(x,m=1/dim(x)[1])
v = sqrt(3*eigen(M)$values)
print(v)


obreschkow/cooltools documentation built on Nov. 16, 2024, 2:46 a.m.