Calculate pixels-per-meter ratio from arena bounds.
This is the fundamental conversion factor between screen space (pixels) and physics space (meters). It varies by device resolution and arena size.
Korean: 픽셀당미터비율 (Pixels Per Meter Ratio)
Arena bounds with pixel and meter dimensions
Conversion ratio (pixels per meter)
Error if worldWidthMeters is not positive
// Desktop: 960px arena, 10m worldconst desktopPxPerM = getPixelsPerMeter({ width: 960, worldWidthMeters: 10, ... });// Result: 96 px/m// Mobile: 300px arena, 6m world const mobilePxPerM = getPixelsPerMeter({ width: 300, worldWidthMeters: 6, ... });// Result: 50 px/m Copy
// Desktop: 960px arena, 10m worldconst desktopPxPerM = getPixelsPerMeter({ width: 960, worldWidthMeters: 10, ... });// Result: 96 px/m// Mobile: 300px arena, 6m world const mobilePxPerM = getPixelsPerMeter({ width: 300, worldWidthMeters: 6, ... });// Result: 50 px/m
Calculate pixels-per-meter ratio from arena bounds.
This is the fundamental conversion factor between screen space (pixels) and physics space (meters). It varies by device resolution and arena size.
Korean: 픽셀당미터비율 (Pixels Per Meter Ratio)