Bookmark this: tool.io/lighting/room-lighting-calculator/source-code
Room Lighting Calculator Source Code
Browse the implementation files for Room Lighting 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 calculateRoomLumens = (
lengthInput: unknown,
widthInput: unknown,
targetIlluminanceInput: unknown
) => {
const length = parseFinite(lengthInput);
const width = parseFinite(widthInput);
const targetIlluminance = parseFinite(targetIlluminanceInput);
if (
length === null ||
length <= 0 ||
width === null ||
width <= 0 ||
targetIlluminance === null ||
targetIlluminance < 0
)
return '';
return length * width * targetIlluminance;
};
export const Tool: TypeTool = {
name: 'Room Lighting Calculator',
slug: 'lighting/room-lighting-calculator',
tool: calculateRoomLumens,
intro:
'Calculate the luminous flux required to reach a target average illuminance across a rectangular room.',
i: [
{
example: '5',
label: 'Room length',
placeholder: 'Meters (m)',
type: 'number'
},
{
example: '4',
label: 'Room width',
placeholder: 'Meters (m)',
type: 'number'
},
{
example: '300',
label: 'Target illuminance',
placeholder: 'Lux (lx)',
type: 'number'
}
],
o: [
{
example: '6000',
label: 'Required luminous flux',
placeholder: 'Lumens (lm)',
render: 'textarea',
type: 'number'
}
],
equation: 'Φᵥ = length × width × Eᵥ',
alternative: [
{
title: 'Lighting Layout Calculator',
url: '/lighting/lighting-layout-calculator'
},
{
title: 'Lumens to Lux Calculator',
url: '/lighting/lumens-to-lux-calculator'
},
{ title: 'Convert area', url: '/convert/area' },
{
title: 'Convert luminous flux',
url: '/convert/luminous-flux'
}
],
cite: [
{
title: 'Lux — Wikipedia',
url: 'https://en.wikipedia.org/wiki/Lux'
},
{
title: 'Lumen — Wikipedia',
url: 'https://en.wikipedia.org/wiki/Lumen_(unit)'
}
]
};
export default Tool;
Description
Browse the implementation files for Room Lighting Calculator.