Clamp a 2D position to stay within arena boundaries in meters.
Works in projected 2D arena space where:
position.x
position.y
2D projected position in meters (may exceed arena bounds)
Arena bounds with meter dimensions
Position clamped to arena boundaries
const bounds = { worldWidthMeters: 10, worldDepthMeters: 7.5, ... };const position = { x: 6, y: 4 }; // Outside arenaconst clamped = clampToArenaBounds(position, bounds);// Result: { x: 5, y: 3.75 } Copy
const bounds = { worldWidthMeters: 10, worldDepthMeters: 7.5, ... };const position = { x: 6, y: 4 }; // Outside arenaconst clamped = clampToArenaBounds(position, bounds);// Result: { x: 5, y: 3.75 }
Clamp a 2D position to stay within arena boundaries in meters.
Works in projected 2D arena space where:
position.x→ world X (horizontal)position.y→ world Z (depth)