### Subdivisions of a Quadrant

Basically, the problem that I am facing here is that there is something going wrong in my calculation of calculating a quadrant, though the issue only occurs when attempting to section an already sectioned quadrant into 4. This is how the sectioning should ideally look like (Image 1), though when I proceed to attempt to section those quadrants into 4, I get a very weird looking result (Image 2);

This is what I am working from:

## Script

```
local ScreenSize = workspace.CurrentCamera.ViewportSize
function Quadrants.new(Point1: Vector2, Point2: Vector2, Width: number, Height: number, CentreVector: Vector2)
local Quadrant = setmetatable({}, Quadrants)
Quadrant.Bounds = {
Min = Point1,
Max = Point2,
Width = Width,
Height = Height,
CentreVector = CentreVector
}
Quadrant.Divided = false
return Quadrant
end
function Quadrants:SubDivide()
if (self.Divided) and true then return end
local CentreVector = self.Bounds.CentreVector
local northeastMax = Vector2.new(math.clamp(CentreVector.X + CentreVector.X, 0, ScreenSize.X), math.clamp(CentreVector.Y - CentreVector.Y, 0, ScreenSize.Y))
local northwestMax = Vector2.new(math.clamp(CentreVector.X - CentreVector.X, 0, ScreenSize.X), math.clamp(CentreVector.Y - CentreVector.Y, 0, ScreenSize.Y))
local southeastMax = Vector2.new(math.clamp(CentreVector.X + CentreVector.X, 0, ScreenSize.X), math.clamp(CentreVector.Y + CentreVector.Y, 0, ScreenSize.Y))
local southwestMax = Vector2.new(math.clamp(CentreVector.X - CentreVector.X, 0, ScreenSize.X), math.clamp(CentreVector.Y + CentreVector.Y, 0, ScreenSize.Y))
local northeastHeight = CentreVector.Y
local northwestHeight = CentreVector.Y
local southwestHeight = CentreVector.Y
local southeastHeight = CentreVector.Y
local northwestWidth = CentreVector.X
local southeastWidth = CentreVector.X
local southwestWidth = CentreVector.X
local northeastWidth = CentreVector.X
local CentreNorthWest = Vector2.new(CentreVector.X - (northwestWidth / 2), CentreVector.Y - (northwestHeight / 2))
local CentreNorthEast = Vector2.new(CentreVector.X + (northeastWidth / 2), CentreVector.Y - (northeastHeight / 2))
local CentreSouthWest = Vector2.new(CentreVector.X - (southwestWidth / 2), CentreVector.Y + (southwestHeight / 2))
local CentreSouthEast = Vector2.new(CentreVector.X + (southeastWidth / 2), CentreVector.Y + (southeastHeight / 2))
self.northeast = Quadrants.new(CentreVector, northeastMax, northeastWidth, northeastHeight, CentreNorthEast)
self.northwest = Quadrants.new(CentreVector, northwestMax, northwestWidth, northwestHeight, CentreNorthWest)
self.southeast = Quadrants.new(CentreVector, southeastMax, southeastWidth, southeastHeight, CentreSouthEast)
self.southwest = Quadrants.new(CentreVector, southwestMax, southwestWidth, southwestHeight, CentreSouthWest)
end
```

I based my calculations on these ones I had made a sketch off, though I am unsure if they are even right!