gpt4 book ai didi

ios - UIBezierPath - 什么是单位半径

转载 作者:搜寻专家 更新时间:2023-11-01 07:31:20 25 4
gpt4 key购买 nike

我正在编写 Swift 应用程序,我使用 SDK Skobbler 来操作 map 。应用程序显示圆圈:

func displayCircle(x: Int, y: Int, radius: Int){...} //display circle in the map

此外,我检查用户是否在这个区域:

for area in self.areas {

var c = UIBezierPath()

let lat = area.getLatitude()
let long = area.getLongitude()
let radius = area.getRadius()/1000
let center = CGPoint(x: lat, y: long)

c.addArcWithCenter(center, radius: CGFloat(radius), startAngle: CGFloat(0), endAngle: CGFloat(360), clockwise: true)
if c.containsPoint(CGPoint(x: currentLocation.latitude, y: currentLocation.longitude)) {
//I AM IN THE AREA
}else {
//I AM NOT IN THE AREA
}
c.closePath()
}

当我在圈子里时,它有效,但当我在圈子外时,它也有效...

我认为问题与单位半径有关

  • skobbler -> 单位米
  • UIBezierPath - 单位 ???

谢谢你的帮助

是的

最佳答案

iOS单位是点。
在非视网膜设备中,1 个点等于 1 个像素。在视网膜设备 (@2x) 中,1 点等于两个像素。在@3x 设备(Iphone 6 plus)中,1 点等于 3 个像素。

注意角度。单位是弧度不是度。所以你需要将你的度数转换为弧度,你的和角度应该是 2 * M_PI 对应于 360 度。您可以定义一个扩展来进行转换:

extension Int {
var degreesToRadians : CGFloat {
return CGFloat(self) * CGFloat(M_PI) / 180.0
}
}
45.degreesToRadians // 0.785398163397448

关于ios - UIBezierPath - 什么是单位半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32399822/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com