Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can I get CFrames in a circle around a certain point with equal distance between them?

Asked by 6 years ago

As the title says I need to find points circled around a point on a certain distance between the main point. So for example if you want to position your parts around the main part you would want to take the parts CFrame and then multiply it by CFrame.new(5,0,0),CFrame.new(-5,0,0),CFrame.new(0,0,5),CFrame.new(0,0,-5). If I want to add another point In between two other points I set the parts CFrame to the x/2 one of the first and z/2 of the second. But this way I will have to script everything manually because while some points have changed X's while others have changed Z's and I cant do it as many times as I want. Any help wil be appreciated.

1 answer

Log in to vote
0
Answered by
fredfishy 833 Moderation Voter
6 years ago

Look up parametric circle equations, but the jist of it is basically

1x = sin(t) * radius
2y = cos(t) * radius

or

1x = cos(t) * radius
2y = sin(t) * radius

So, you could do something like

01function getPoints(pointsAroundCircle)
02    divisor = pointsAroundCircle / 2
03    points = {}
04    for i = 1, math.pi * 2, math.pi/divisor do
05        x = cos(i) * radius
06        y = sin(i) * radius
07        table.insert(points, {x, y})
08    end
09    return points
10end
Ad

Answer this question