Skip to content

Main content

Ponderal Index Calculator Source Code

Browse the implementation files for Ponderal Index Calculator.
@tool.io/tools/ponderal-index source ↗
tool.ts typescript
import { parseFiniteNumber } from '../parse/number/tool';
import { calculatePonderalIndex as calculatePortablePonderalIndex } from '@tool.io/tools/ponderal-index';

export type PonderalIndexGroup = 'adult' | 'newborn';
export type PonderalIndexUnits = 'metric' | 'us';

export const calculatePonderalIndex = (
	groupInput: unknown,
	unitsInput: unknown,
	weightInput: unknown,
	heightInput: unknown
): number | null => {
	if (
		(groupInput !== 'adult' && groupInput !== 'newborn') ||
		(unitsInput !== 'metric' && unitsInput !== 'us')
	) {
		return null;
	}

	const weight = parseFiniteNumber(weightInput);
	const height = parseFiniteNumber(heightInput);
	if (
		weight === null ||
		height === null ||
		weight <= 0 ||
		height <= 0
	) {
		return null;
	}

	return calculatePortablePonderalIndex(
		groupInput,
		unitsInput,
		weight,
		height
	);
};

export const ponderalIndex = (
	groupInput: unknown,
	unitsInput: unknown,
	weightInput: unknown,
	heightInput: unknown
): string => {
	const result = calculatePonderalIndex(
		groupInput,
		unitsInput,
		weightInput,
		heightInput
	);
	return result === null ? '' : result.toFixed(3);
};

export const Tool: TypeTool = {
	name: 'Ponderal Index Calculator',
	slug: 'ponderal-index',
	intro:
		"Calculate the Ponderal Index, also called the Corpulence Index or Rohrer's Index, from weight and height using adult or newborn conventions.",
	description:
		'The Ponderal Index relates body weight to the cube of height. Adult results use kilograms per cubic meter. Newborn results use the conventional birth-weight formula of 100 times weight in grams divided by length in cubic centimeters. This calculator converts metric or US customary measurements before applying the selected convention. It is informational and is not a medical diagnosis.',
	tool: ponderalIndex,
	i: [
		{
			example: 'adult',
			label: 'Calculation',
			options: [
				{
					selected: true,
					text: 'Adult or older child',
					value: 'adult'
				},
				{
					text: 'Newborn',
					value: 'newborn'
				}
			],
			placeholder: 'Select a calculation',
			type: 'select'
		},
		{
			example: 'us',
			label: 'Measurement System',
			options: [
				{
					selected: true,
					text: 'US customary — lb and in',
					value: 'us'
				},
				{
					text: 'Metric — kg and cm',
					value: 'metric'
				}
			],
			placeholder: 'Select measurement units',
			type: 'select'
		},
		{
			example: '176.4',
			help: 'Enter pounds for US customary or kilograms for metric.',
			label: 'Weight',
			placeholder: 'Enter body weight',
			type: 'number'
		},
		{
			example: '70.9',
			help: 'Enter inches for US customary or centimeters for metric.',
			label: 'Height or Length',
			placeholder: 'Enter height or crown-to-heel length',
			type: 'number'
		}
	],
	o: [
		{
			example: '13.717',
			help: 'Adult results are kg/m³. Newborn results use 100 × g/cm³.',
			label: 'Ponderal Index',
			placeholder: 'Ponderal Index will appear here...',
			render: 'textarea',
			type: 'number'
		}
	],
	equation:
		'$$ PI_{adult} = \\frac{weight_{kg}}{height_m^3}, \\qquad PI_{newborn} = 100 \\times \\frac{weight_g}{length_{cm}^3} $$',
	alternative: [
		{
			title: 'Body Mass Index Calculator',
			url: '/body-mass-index'
		},
		{
			title: 'Body Roundness Index Calculator',
			url: '/body-roundness-index'
		},
		{
			title: 'Waist-to-Hip Ratio Calculator',
			url: '/waist-to-hip'
		}
	],
	cite: [
		{
			title: 'Corpulence index - Wikipedia',
			url: 'https://en.wikipedia.org/wiki/Corpulence_index'
		},
		{
			title:
				'Physical status: the use and interpretation of anthropometry - World Health Organization',
			url: 'https://iris.who.int/handle/10665/37003'
		}
	]
};

export default Tool;

Description

Browse the implementation files for Ponderal Index Calculator.

References

  1. Tool.io on GitHub
  2. Tool.io TypeScript tools library

Similar or alternative tools