Bookmark this: tool.io/lighting/beam-angle-calculator/source-code
Beam Angle Calculator Source Code
Browse the implementation files for Beam Angle Calculator.tool.ts typescript
const parseFinite = (value: unknown): number | null => {
if (value === '' || value === null || value === undefined)
return null;
const parsed = Number(value);
return Number.isFinite(parsed) ? parsed : null;
};
export const calculateBeamAngle = (
distanceInput: unknown,
beamDiameterInput: unknown
) => {
const distance = parseFinite(distanceInput);
const beamDiameter = parseFinite(beamDiameterInput);
if (
distance === null ||
distance <= 0 ||
beamDiameter === null ||
beamDiameter < 0
)
return '';
return (
(2 * Math.atan(beamDiameter / (2 * distance)) * 180) /
Math.PI
);
};
export const Tool: TypeTool = {
name: 'Beam Angle Calculator',
slug: 'lighting/beam-angle-calculator',
tool: calculateBeamAngle,
intro:
'Calculate the full beam angle from the beam diameter measured at a known distance from the light source.',
i: [
{
example: '5',
label: 'Distance from light',
placeholder: 'Meters (m)',
type: 'number'
},
{
example: '2',
label: 'Beam diameter',
placeholder: 'Meters (m)',
type: 'number'
}
],
o: [
{
example: '22.619864948040426',
label: 'Full beam angle',
placeholder: 'Degrees (°)',
render: 'textarea',
type: 'number'
}
],
equation: 'θ = 2 × atan(d / (2r))',
alternative: [
{
title: 'Throw Distance Calculator',
url: '/lighting/throw-distance-calculator'
},
{
title: 'Candela to Lumens Calculator',
url: '/lighting/candela-to-lumens-calculator'
},
{
title: 'Candela to Lux Calculator',
url: '/lighting/candela-to-lux-calculator'
},
{ title: 'Convert length', url: '/convert/length' }
],
cite: [
{
title: 'Angular diameter — Wikipedia',
url: 'https://en.wikipedia.org/wiki/Angular_diameter'
}
]
};
export default Tool;
Description
Browse the implementation files for Beam Angle Calculator.