Find ents in a "tire" shape

For a SWEP I’m working on I need to find ents in a tire shape, meaning in a circle on one axis, and a box on another.

Forward View

|  |
|  |
|  |
|  |
|  |
|  |
|  |

Then the side view would just be a circle.

Anyone know how I would go about doing this?
I thought about doing an ents.FindInBox combined with an ents.FindInSphere and using the ents that are in both, but that seems tricky and ineffecient.

Will the shape be axis aligned?

If the tire never moved angles, that’s how I’d do it



It will be aligned to the Yaw of the players EyeAngles.


Would you be able to define your box, then use vec:Rotate() based on eyeangles to get the corrrect bounding box?


Just tried this in a SENT that i spectated (In ENT:Think())
local boxBound1 = Vector(-15, 30, 30)
local boxBound2 = Vector(15, -30, -30)
local eyeAngs = self:GetOwner():EyeAngles()
boxBound1 = boxBound1 + self:GetPos()
boxBound2 = boxBound2 + self:GetPos()
debugoverlay.Box(Vector(0,0,0), boxBound1, boxBound2, .25, Color(200,100,100,127))

Didnt work too hot, the box didnt really rotate, the dimensions just got all fucked.

local off = ent:GetPos()-tireCenter

local r = ply:EyeAngles():Right()
local d = r:Dot(off)

if d+d < tireWidth and off:Distance(r*d) < tireRadius then

--ent is inside tireshape



Is tireWidth the entire width? or does this account for an offset so the tires left side isnt at the center of the eyeview?


And also how do you reference the ents inside the tire with your code?

tireWidth is the entire width.

Just iterate ents.GetAll() and apply that check to each of them.

You mean like… uh.
FindInCylinder or something?
The only way I could think of doing it is iterating through entities found in ents.FindInBox, then removing all entries that are more than N distance from the centre of the box (to fix any that are off the edge of the “wheel”)

Yeah Cylinder - I couldn’t think of the word when I made the thread, but I did get this working with ralle’s help.
The code:

for k, v in pairs(ents.GetAll()) do
local off = v:GetPos() - cylinderOrigin
local r = self.Owner:EyeAngles():Right()
local d = r:Dot(off)
if d+d < cylinderHeight and off:Distance(r*d) < cylinderRadius then
–Ents have been found