{"id":"stratiz/SpatialUtils","name":"SpatialUtils","scope":"stratiz","platform":"roblox","description":"Utilities for checking whether a position is inside various shapes and node defined regions.","version":"1.0.0","latest":"1.0.0","versions":["1.0.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"36f450a7e8e8189012b6098e7f950142bef48df80a8d2e48b7984f4098b8a3f5","likes":1,"downloads":4,"install":"forest install stratiz/SpatialUtils","url":"https://forest.dev/p/roblox/stratiz/SpatialUtils","files":"https://api.forest.dev/ai/package/roblox/stratiz/SpatialUtils/files","readme":"# SpatialUtils\n\nUtilities for checking whether a position is inside various shapes and node defined regions.\n\n## Usage\n\n```lua\nlocal SpatialUtils = require(path.to.SpatialUtils)\n\nif SpatialUtils:IsPositionInPart(character.PrimaryPart.Position, zonePart) then\n    -- position is inside the part\nend\n\nlocal inRegion = SpatialUtils:IsPositionInRegion(position, {\n    Vector3.new(0, 0, 0),\n    Vector3.new(100, 0, 0),\n    Vector3.new(100, 0, 100),\n    Vector3.new(0, 0, 100)\n})\n```\n\n## API\n\n### SpatialUtils:IsPositionInSphere(position, origin, size)\n\nChecks the position against a sphere at the origin. `size` is the diameter, matching a ball part's size.\n\n### SpatialUtils:IsPositionInBox(position, origin, size)\n\nChecks the position against a box at the origin with the given size, respecting the origin's rotation.\n\n### SpatialUtils:IsPositionInCylinder(position, origin, size)\n\nChecks the position against a cylinder at the origin. Follows Roblox's cylinder rules where the top and bottom are on the X axis, so the height is `size.X` and the radius is half the smaller of `size.Y` and `size.Z`.\n\n### SpatialUtils:IsPositionInPart(position, part)\n\nChecks the position against a part, using its actual shape for ball and cylinder parts and a box for everything else.\n\n### SpatialUtils:IsPositionInRegion(position, nodes)\n\nChecks the position against the polygon formed by the nodes on the XZ plane. Node order defines the edges and the last node connects back to the first. Height is ignored. Returns whether the position is inside, and the exact distance to the nearest edge whether inside or outside, measured to the tangent point on each edge and clamped to its endpoints.\n","readmeTruncated":false}