我想将点旋转 -90 度
最初的

最终的

让我们来看看 Initial 的左上角和右上角点。他们的坐标是:
let topLeft = CGPoint(x: 2, y: 1)
let topRight = CGPoint(x: 3, y: 1)
Run Code Online (Sandbox Code Playgroud)
并且在它们的旋转坐标之后应该变成:
topLeft 1:0
topRight 2:0
Run Code Online (Sandbox Code Playgroud)
我该怎么做 ?
我尝试了几个答案,但没有一个给出我的最终结果。
不起作用: 围绕另一个 CGPoint 旋转 CGPoint
这是我的操场上的一些代码:
let topLeft = CGPoint(x: 2, y: 1)
let topRight = CGPoint(x: 3, y: 1)
func rotatePoint1(_ point: CGPoint, _ degrees: CGFloat) -> CGPoint {
let s = CGFloat(sinf(Float(degrees)))
let c = CGFloat(cosf(Float(degrees)));
return CGPoint(x: c * point.x - s * point.y, …Run Code Online (Sandbox Code Playgroud)