Philipp Rosengart
Philipp Rosengart

Reputation: 733

Calculate x/y Coordinates from Angle for every Point

I want to order 28 Items in a Circle. I have a given angle and a radius, with this I need to calculate my coordinates. Can anybody help me please?

Upvotes: 1

Views: 1029

Answers (1)

Grimxn
Grimxn

Reputation: 22517

This is a simple maths question, not a Swift question.

let circle = 2.0 * Double.pi
for angle in stride(from: 0.0, to: circle, by: circle / 28.0) {
    let x = radius * cos(angle)        
    let y = radius * sin(angle)
    // Add x & y to the coordinates of your centre.
}

Upvotes: 5

Related Questions