Bookmark this: tool.io/geometry/chebyshev-distance/source-code
Chebyshev Distance Calculator Source Code
Browse the implementation files for Chebyshev Distance Calculator.tool.ts typescript
import { calculateChebyshevDistance } from '@tool.io/tools/geometry/chebyshev-distance';
import { parseFiniteNumberList } from '@tool.io/tools/parse/numeric-dataset';
export const chebyshevDistance = (
firstInput: unknown,
secondInput: unknown
): string => {
const first = parseFiniteNumberList(firstInput);
const second = parseFiniteNumberList(secondInput);
if (!first || !second || first.length !== second.length)
return '';
const result = calculateChebyshevDistance(first, second);
return result === null ? '' : String(result);
};
export const Tool: TypeTool = {
name: 'Chebyshev Distance Calculator',
slug: 'geometry/chebyshev-distance',
intro:
'Find the greatest coordinate difference between two equal-length points or vectors.',
tool: chebyshevDistance,
i: [
{
example: '1, 2, 3',
label: 'First Vector',
placeholder: 'First vector',
render: 'textarea',
type: 'text'
},
{
example: '4, 2, -1',
label: 'Second Vector',
placeholder: 'Second vector',
render: 'textarea',
type: 'text'
}
],
o: [
{
example: '4',
label: 'Chebyshev Distance',
placeholder: 'Distance will appear here...',
type: 'number'
}
],
equation: '$$d_\\infty(x,y)=\\max_i|x_i-y_i|$$'
};
export default Tool;
Description
Browse the implementation files for Chebyshev Distance Calculator.