-3
다른 방사형으로 12 포인트를 그려야합니다. 점 1에서 점 2로, 점 2에서 점 3으로 등 선을 그리십시오. 선은 문제가되지 않습니다.신속한 극좌표
12 * (x, y)를 찾을 수있는 공식을 찾을 수 없지만 극좌표/원이있는 것으로 생각하십니까?
누구와도 작업하고 있고 나와 공유하고 싶습니까?
다른 방사형으로 12 포인트를 그려야합니다. 점 1에서 점 2로, 점 2에서 점 3으로 등 선을 그리십시오. 선은 문제가되지 않습니다.신속한 극좌표
12 * (x, y)를 찾을 수있는 공식을 찾을 수 없지만 극좌표/원이있는 것으로 생각하십니까?
누구와도 작업하고 있고 나와 공유하고 싶습니까?
이것은 내가 가진 결과 :
은 내가 할 수있는 것보다 더 잘 설명 할 수있는 그림을 참조하십시오을 그리고 이것은 나의 놀이터입니다 :
//: Playground - noun: a place where people can play
import Foundation
import UIKit
class DemoView: UIView {
override func draw(_ rect: CGRect) {
let origin = CGPoint(x: frame.size.width/2, y: frame.size.height/2)
let radius = frame.size.width/2
self.createCircle(origin: origin, radius: radius)
self.addLinesInCircle(origin: origin, radius: radius)
}
func createCircle(origin: CGPoint, radius: CGFloat) {
let path = UIBezierPath()
path.addArc(withCenter: origin, radius: radius, startAngle: 0, endAngle: CGFloat(2 * Double.pi), clockwise: true)
path.close()
UIColor.orange.setFill()
path.fill()
}
func addLinesInCircle(origin: CGPoint, radius: CGFloat) {
let path = UIBezierPath()
let incrementAngle: CGFloat = CGFloat.pi/6
let ratios: [CGFloat] = [3/6, 5/6, 3/6, 1/6, 5/6, 2/6, 4/6, 2/6, 4/6, 4/6, 4/6, 4/6, 3/6]
for (index, ratio) in ratios.enumerated() {
let point = CGPoint(x: origin.x + cos(CGFloat(index) * incrementAngle) * radius * ratio,
y: origin.y + sin(CGFloat(index) * incrementAngle) * radius * ratio)
if index == 0 {
path.move(to: point)
} else {
path.addLine(to: point)
}
}
path.close()
UIColor.black.set()
path.stroke()
}
}
let demoView = DemoView(frame: CGRect(x: 0, y: 0, width: 320, height: 320))
고맙습니다, 그게 내가 필요합니다 :-) –
안녕하세요 allan 님이 그림을 추가 할 수 있습니까? ure. :) –
감사합니다. 지금 사진을 볼 수 있습니까? –
Polar System을 사용하여 점을 (x, y) 한 개 더 고전적으로 배치하려면 수학에 관한 내용을 읽어야합니다. 일단 두 점을 얻으면 선을 그리는 것은 쉽습니다. – Larme