How to convert points to radians in Objective-C?

后端 未结 3 766
深忆病人
深忆病人 2021-01-17 08:13

In my app I\'m using UIBezierPath to draw an arc into a circle. I\'m trying to correlate a number to radians. So let\'s say a user has a certain number of points, and the po

3条回答
  •  甜味超标
    2021-01-17 08:42

    Objective-C

    CGFloat fullCircle = 2 * M_PI ;             // M_PI Pi number which is half of the circle in radian
    CGFloat startPoint = 0.0      ;
    CGFloat endPoint   = fullCircle * 0.33 ;
    
    // Assuming circling clockwise
    
    // .... Draw first step UIBezierPath
    
    startPoint = endPoint        ;
    endPoint = startPoint + fullCircle * 0.33 ;
    // .... Draw second step UIBezierPath
    
    startPoint = endPoint        ;
    endPoint = fullCircle - startPoint ;       // This to make sure the whole circle will be covered
    // .... Draw the last step UIBezierPath
    

    Swift

    let fullCircle = 2 * M_PI             // M_PI Pi number which is half of the circle in radian
    var startPoint: Float = 0.0
    var endPoint: Float = fullCircle * 0.33
    
    // Assuming circling clockwise
    // .... Draw first step UIBezierPath
    
    startPoint = endPoint
    endPoint = startPoint + fullCircle * 0.33
    // .... Draw second step UIBezierPath
    
    startPoint = endPoint
    endPoint = fullCircle - startPoint       // This to make sure the whole circle will be covered
    // .... Draw the last step UIBezierPath
    

提交回复
热议问题