# Inertia Calculator

{% tabs %}
{% tab title="HTML" %}
{% code fullWidth="true" %}

```html
<html>
<head>
<link rel="stylesheet" href="InertiaCalcCSS.css">
<script src="inertiaJS.JS"></script>
</head>
<body>

<div class="InertiaCalc" >
  <input type="text" class="calculator-screen" value="" disabled />
  <p>Input all your necessary data in the base scientific units about your object to get the inertia. Click on object type to output data</p>
  
    <form>
      
      <label for="Mass">Mass</label>
      <input type="text" id="Mass" name="Mass"><br><br>
      
      <label for="Radius">Radius</label>
      <input type="text" id="Radius" name="Radius"><br><br>
      
      <label for="Length">Length</label>
      <input type="text" id="Length" name="Length"><br><br>
      
      <label for="CMInertia">Center of mass inertia</label>
      <input type="text" id="CMInertia" name="CMInertia"><br><br>
      <div class="InertiaType" >
        <input type="button" class = "objectType" value="Solid Cylinder" onclick="processInputs(); calculate('Solid Cylinder'); updateDisplay()">
        <input type="button" class = "objectType" value="Hoop" onclick="processInputs(); calculate('Hoop'); updateDisplay()">
        <input type="button" class = "objectType" value="Solid Sphere" onclick="processInputs(); calculate('Solid Sphere'); updateDisplay()">
        <input type="button" class = "objectType" value="Rod about center of mass" onclick="processInputs(); calculate('Rod about center of mass'); updateDisplay()">
        <input type="button" class = "objectType" value="Solid cylinder about central diameter" onclick="processInputs(); calculate('SolidCylinderAboutCentralDia'); updateDisplay()">
        <input type="button" class = "objectType" value="Hoop about diameter" onclick="processInputs(); calculate('HoopAboutDiameter'); updateDisplay()">
        <input type="button" class = "objectType" value="Thin spherical shell" onclick="processInputs(); calculate('ThinSphericalShell'); updateDisplay()">
        <input type="button" class = "objectType" value="Rod about end" onclick="processInputs(); calculate('RodAboutEnd'); updateDisplay()">
        <input type="button" class = "objectType" value="Parallel Axis Theorom" onclick="processInputs(); calculate('ParallelAxisTheorom');updateDisplay()">
        <input type="reset" class = "objectType" value="All clear" onclick="resetCalculator(); updateDisplay() ">
      </div>
    </form>
</div>
</body>
</html>
```

{% endcode %}
{% endtab %}

{% tab title="CSS" %}

```css
html {
  box-sizing: border-box;
  color: white;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: inherit;
}

.InertiaCalc {
  border: 4px solid #ccc;
  border-color: black;
  border-radius: 5px;
  position: absolute;
  transform: translate(1%, 0%); /*this moves the interactive element down*/
  width: 960px;
  height: 570px;
}

.calculator-screen {
  width: 100%;
  font-size: 5rem;
  height: 80px;
  border: none;
  background-color: #252525;
  color: #fff;
  text-align: right;
  padding-right: 20px;
  padding-left: 10px;
}

.objectType{
  font-size: 80%;
  height: 40px;
  background-color: #22518D;
  border-radius: 3px;
  border: 3px solid #c4c4c4;
  font-size: 2rem;
  color: white;
}

.objectType:hover {
  background-color: 65A0EC;
}
.InertiaType {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-gap: 20px;
  padding: 10px;
}
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const calculator = {
  displayValue: '0',
  Mass: null,
  Radius: null,
  Length: null,
  CMInertia: null,};

function processInputs(){
  calculator.Mass = parseFloat(document.getElementById("Mass").value);
  calculator.Radius = parseFloat(document.getElementById("Radius").value);
  calculator.Length = parseFloat(document.getElementById("Length").value);
  calculator.CMInertia = parseFloat(document.getElementById("CMInertia").value);
}

function calculate(operator) {
  const mass = calculator.Mass;
  const radius = calculator.Radius;
  const Length = calculator.Length;
  const CMInertiaUse = calculator.CMInertia;
  if (operator === 'Solid Cylinder') {
    calculator.displayValue = 0.5*mass* Math.pow(radius,2);
  } else if (operator === 'Hoop') {
    calculator.displayValue = mass* Math.pow(radius,2);
  } else if (operator === 'Solid Sphere') {
    calculator.displayValue = (2/5)*mass* Math.pow(radius,2);
  }else if(operator === 'SolidCylinderAboutCentralDia'){
    calculator.displayValue = ((1/4)*mass*Math.pow(radius,2))+((1/12)*mass*Math.pow(Length,2));
  }else if(operator === 'HoopAboutDiameter'){
    calculator.displayValue = (1/2)*mass* Math.pow(radius,2);
  }else if(operator === 'Rod about center of mass'){
    calculator.displayValue = (1/2)*mass* Math.pow(radius,2);
  }else if(operator === 'ThinSphericalShell'){
    calculator.displayValue = (2/3)*mass*Math.pow(radius,2)
  }else if(operator === 'RodAboutEnd'){
    calculator.displayValue = (1/3)*mass*Math.pow(Length,2);
  }else if(operator === 'ParallelAxisTheorom'){
    calculator.displayValue = CMInertiaUse+(mass*Math.pow(Length,2));
  }else{
    calculator.displayValue=0;
  }
  updateDisplay();
}

function resetCalculator() {//clears memory
  Mass= null;
  Radius= null;
  Length= null;
  CMInertia= null;
  calculator.displayValue = '0';
  calculator.firstOperand = null;
  calculator.operator = null;
}

function updateDisplay() { //here how you can update the website based on an html element
  const display = document.querySelector('.calculator-screen');
  display.value = calculator.displayValue;
}

updateDisplay();
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://njit-robotics-club.gitbook.io/njit-robotics-club-wiki/mechanical/inertia-calculator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
