I’m trying to make a circle of parts but I don’t know how to resize the length of the parts in order to close out all the gaps on the outside of the circle. The inner side of the parts may overlap.
Currently I’m using the formula to find the length of the sides of an N sided polygon by only knowing the radius, but it still leaves a gap.
local center = script.Parent
local PART_COUNT = 24
local RADIUS = 8
local TEMPLATE = Instance.new("Part")
TEMPLATE.Anchored = true
TEMPLATE.CanCollide = false
local double_pi = 2 * math.pi
local length = (2 * (RADIUS + TEMPLATE.Size.Z / 2)) * math.sin(math.rad(180) / PART_COUNT)
for i = 1, PART_COUNT, 1 do
local part = TEMPLATE:Clone()
part.Size = Vector3.new(length, TEMPLATE.Size.Y, TEMPLATE.Size.Z)
part.Parent = workspace
local angle = i * (double_pi / PART_COUNT)
local x = math.cos(angle) * RADIUS
local z = math.sin(angle) * RADIUS
local position = (center.CFrame * CFrame.new(x, 0, z)).Position
part.CFrame = CFrame.new(position, center.Position)
end
Try this formula.
You just need to know the radius (which is your radius + half the width of hte Part you use, and the angle between the parts (in this case 360/24) for t.
You’re calculating the length of the parts as the distance between 2 points on a circle (green) and then placing it tangent to the circle (red), as a result the length falls short.