Moment of Inertia Project

Saba Syed, Major: Computer Science, MSU Email: syeds3@mail.montclair.edu ,12/14/2020

Theory

The moment of inertia, also known as rotational inertia, is a property of any object which can be rotated. It is a quantity that determines the torque (rotational equivalent of force) needed for a certain angular accleration on a rotational axis. The axis may be internal or external and may or may not be fixed but the moment of inertia is always specified with respect to that axis is defined as the sum of the prodycts obtained by multiplyinh the mass of each particlr of matter in a given body/object by the square if uts dustance from the axis. An object's moment of inertia depends on the axis of rotation and once that axis is determined, the moment of inertia can be calculated.

For a point mass, the moment of inertia is defined as the mass times the radiys from the axis squared:

$I=\sum_{i=0}^N m_i r_i^2$

Statement Problem:

This problem explains how to calculate the particles in the sphere and are represented in the graph below.

Finding the perpendicular distance of a point from a line in 3D

The goal is to get a data file with coordinates of points, and a specified axis and find the moment of inertia of the distribution about that point. So, we need a code that will find the perpendicular distance of a point from a line. Please remember that the axis does not need to be along the x-axis or the y-axis. It could be any straight line. One way to solve this is as follows: The equation of a straight line in 3D is written as:

$\frac{x - x_0}{l} = \frac{y - y_0}{m} = \frac{z - z_0}{n}$,

where, the quantities $(l, m, n)$ are known as direction-cosines. These are simply the cosine of the angles the line makes with the $x$, $y$, and the $z$ axis respectively. The point $(x_0, y_0, z_0)$ is one of the points on the straight line. Let us imagine there is a point in space $(X, Y, Z)$, and we want to find this point's perpendicular distance from the straight line. The distance $d$ of an arbitrary point $(x_1, y_1, z_1)$ on the straight line from this point in space is:

$(x_1 - X)^2 + (y_1 - Y)^2 + (z_1 - Z)^2 = d^2$.

Since, this arbitrary point $(x_1, y_1, z_1)$ is also on the straight line, it should satisfy the straight line equation.

$\frac{x_0 - x_1}{l} = \frac{y_0 - y_1}{m} = \frac{z_0 - z_1}{n} = p$,

where, $p$ is some quantity to which all these values must equate to. From the above equation we can therefore write, $x_1 = x_0 - lp$, $y_1 = y_0 - mp$, and $z_1 = z_0 - np$. We now plug these back in the equation of distance:

$(x_0 - lp - X)^2 + (y_0 - mp - Y)^2 + (z_0 - np - Z)^2 = d^2$.

We want to find the minimum value of this distance, since perpendicular distance of a point from a line is also the shortest distance of the line to a point. Thus, we need to differentiate the above equation w.r.t $p$ and set that to zero. The resulting equation can be solved to find the value of $p$ for which the minima is reached. That value of $p$ can then be fed back to the equations $x_1 = x_0 - lp$, $y_1 = y_0 - mp$, and $z_1 = z_0 - np$ to find the point $(x_1, y_1, z_1)$ which is the required perpendicular point.

Lets compute the minimum distance:

$\frac{d}{dp}[(x_0 - lp - X)^2 + (y_0 - mp - Y)^2 + (z_0 - np - Z)^2] = 0\\$ $2(x_0 - lp - X)(-l) + 2(y_0 - mp - Y)(-m) + 2(z_0 - np - Z)(-n) = 0$

Rearranging the terms we get:

$(l^2 + m^2 + n^2)p = (lx_0 + my_0 + nz_0) - (lX + mY + nZ)$

Note that $l^2 + m^2 + n^2 = 1$. Therefore, the above equation becomes:

$p = (lx_0 + my_0 + nz_0) - (lX + mY + nZ)$

If the line from which we are finding the the distance is the $z$-axis, Then $l=0, m=0, n=1$. Furthermore since the axis passes through the origin, therefore we can choose $x_0=0, y_0=0, z_0=0$. Then, for the $(x_1, y_1, z_1)$ to be the shortest distance from the point $(X, Y, Z)$, we must have:

$p = -Z$

Which will mean: $x_1 = 0, y_1 = 0, z_1 = 0 - (-Z) = Z$, implying $D=\sqrt{(0-X)^2 + (0-Y)^2 + (Z-Z)^2} = \sqrt{X^2 + Y^2}$.

Statment Problem:

The following problem asked us to find the perpendicular distance of a point from a line in space. The function, which is written as a code, and computes the perpendicular distance of a point in space from line. The cartesian coordinates of each point, were provided with the direction cosines of a line and one point on the line. The direction cosines were represented with the letters l, m, and n.

The parameters which were used, were the following P, dc and Q. P represented a tuple, from where the X, Y and Z coordinates were coordinates of a point, which had their perpendicular distance being calculated. dc represented the direction cosines of a line, which had their perpendicular distance being calculated. Q represented a tupe, where x0, y0, and z0 were the coordinates of each point on the line. The perpendicular distance of one point from the line, was given the following coordinates.

For Q, x0 had a value of 0. For Q, y0 had a value of 1. For Q, z0 had a value of 2.

For P, X had a value of 0. For P, Y had a value of 1. For P, Z had a value of 2. The values for x1, y1, and z1 were calculated with the following formulas. The value of x1 was calculated by the following formula: $x_{\rm 1}$ = $x_{\rm 0} - (l*p)$ .

For dc, l had a value of 0. For dc, m had a value of 1. For dc, n had a value of 2.

The value of P, which is the perpendicular distance of a point from a line in space, was calculated by the following formula: $p = (l* x_{\rm 0}$ + $m* y_{\rm 0}$ + $n* z_{\rm 0}$ - $(l*X + m*Y + n*Z)$

The values of x1, y1, and z1 were calculated with the following formulas.

The value of x1 was calculated by the following formula: $x_{\rm 1}$ = $x_{\rm 0} - (l*p)$.

The value of y1 was calculated by the following formula: $y_{\rm 1}$ = $y_{\rm 0} - (m*p)$.

The value of z1 was calculated by the following formula: $z_{\rm 1}$= $z_{\rm 0} - (n*p)$.

The perpendicular distance of a point from a line in space, was calculated with the following formula: $D$ = $(x_{\rm 1}$ - $X) ** 2 + (y_{\rm 1}$ - $Y) ** 2 + (z_{\rm 1}$ - $Z) ** 2) **0.5$.

That same formula was used to calculate the distance from the z axis. All same three values, which consisted of 3, 4 and 3 were used to calculate the distance for all three axes, x, y and z. The z axis represented the Q, and it had value of 1. P and dc had values of 0 and 0. When the distance from the z axis was calculated, the value was 5.0.

The x axis represented the P, and it had a value of 1. dc and Q had values of 0 and 0. When the distance from the x axis was calculated, the value was 5.0.

The y axis represented the dc, and it had a value of 1. P and Q had values of 0 and 0. When the distance from the y axis was calculated, it resulted in a long decimal number, as the value started with 4.24.

The last function which was used, it was computemomentofinertia(spherical_distribution_1M, dc, Q). The function used the text file which contained the data of the coordinates of the point masses, the direction of cosine of the axis for which it needed the moment of inertia to be calculated, and one point of thay axis. This function was returning the value of the moment of inertia, because it had assumed that every point from the data file had the same unity mass.

For X, P had a value of 0.

For Y, P had a value of 1.

For Z, P had a value of 2.

The direction cosines of a line (dc), which were represented with the letters l, m and n, had values of 0, 0 and 1. The square root taken from the radius, gave a value of 0. The perpendicular distance for the X, Y and Z coordinates, and the direction cosines of a line (dc), resulted in all the values for Q, which had coordinates x0, y0 and z0, to have values of 0, 0 and 0.

The squared radius was calculated with the following formula: $Dsq += (D**2)$.

The radius which was given to calculate the moment of inertia was 1, the mass was one 1000000. The moment of inertia was calculated with the following formula: $I = \frac{2}{5} * (M*(r**2))$.

Evenly distributed points on a plane:

They are not really defined and only the five platonic solids can qualify. Each node has the same number of neighbors,at the same distance and equally spaced around itself. The purpose is to prevent putting a higher number of nodes in one region than in another. This can be put in a number of ways such as packing, covering, or elctrostatic reuplusion. packing is maximizing the smallest distance between nodes, covering is minimizing the greatest distance of any point from the nearest node and electrostatic repulsion is when the nodes are seen as charged particles.

Out of the three versions electrostatic repulsion is the easiest to implement. It is also known as the electron problem or the Thomson problem. So beginning from the arbitrary distribution you can use algorithms or port repulsion where all the nose are repeal each other according to a certain force law and dynamics are simulated. The algorithm is run until a criteria is satisfied and the resulting distribution is approximate.