How would I be able to create a circle that is a certain distance away and each point is at a 5 degree angle from the center? I know there is some geometry stuff for this.
local function calculateCirclePoint(centerPosition, radius, angleDegrees)
local angleRadians = math.rad(angleDegrees)
local x = centerPosition.x + radius * math.cos(angleRadians)
local y = centerPosition.y + radius * math.sin(angleRadians)
return Vector2.new(x, y)
end
-- Parameters
local centerPosition = Vector2.new(0, 0) -- Replace with your center position
local radius = 10 -- Replace with your radius
-- Create points around the circle at 5-degree intervals
for angle = 0, 360, 5 do
local pointPosition = calculateCirclePoint(centerPosition, radius, angle)
-- Now you can use 'pointPosition' to create objects, such as parts or GUI elements, at each point
local part = Instance.new("Part")
part.Position = Vector3.new(pointPosition.x, 0, pointPosition.y)
part.Size = Vector3.new(1, 1, 1)
part.Anchored = true
part.Parent = workspace
end
I am trying to get the radius from a angle and the distance of the center.
I already have premade assets
function getPointOnCircle(centerPosition, radius, angle)
local x = centerPosition.X + radius * math.cos(angle)
local y = centerPosition.Y + radius * math.sin(angle)
return Vector2.new(x, y)
end
local center = Vector2.new(0, 0)
local radius = 10
local angleInRadians = math.rad(45) -- Angle in radians
local pointOnCircle = getPointOnCircle(center, radius, angleInRadians)
print("Point on Circle:", pointOnCircle)
This should work, it returns a Vector2 representing the coordinates of the point on the circle
but what exactly does the radius do in this function?
it represents the distance from the center of the circle to the point you want to calculate, it defines the size of the circle