小编Kol*_*kos的帖子

Swift:在 2D 中旋转点

我想将点旋转 -90 度

最初的

https://ibb.co/HHCCSyp

最终的

https://ibb.co/3vyV7PG

让我们来看看 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

在网格上旋转 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)

math rotation cgpoint ios swift

4
推荐指数
1
解决办法
609
查看次数

标签 统计

cgpoint ×1

ios ×1

math ×1

rotation ×1

swift ×1