public class Circle {private PointF centerPoint;private float radius;public PointF getCenterPoint() {return centerPoint;}public void setCenterPoint(PointF centerPoint) {this.centerPoint = centerPoint;}public float getRadius() {return radius;}public void setRadius(float radius) {this.radius = radius;}}



public class CircleUtils {/** * 根据圆上的三个点求圆心坐标、半径 * @param pA * @param pB * @param pC * @return */public static Circle getCircle(PointF pA,PointF pB,PointF pC){ float mat1,mat2,mat3 ;   mat1 = ((pB.x*pB.x +pB.y*pB.y)-(pA.x*pA.x +pA.y*pA.y))*(2*(pC.y-pA.y))-   ((pC.x*pC.x +pC.y*pC.y)-(pA.x*pA.x +pA.y*pA.y))*(2*(pB.y-pA.y));   mat2 = (2*(pB.x-pA.x))*((pC.x*pC.x+pC.y*pC.y)-(pA.x*pA.x +pA.y*pA.y))-   (2*(pC.x-pA.x))*((pB.x*pB.x+pB.y*pB.y)-(pA.x*pA.x +pA.y*pA.y));   mat3 = 4*((pB.x-pA.x)*(pC.y-pA.y) - (pC.x-pA.x)*(pB.y-pA.y));    Circle circle=new Circle(); PointF centerPoint=new PointF(); float radius; centerPoint.x = mat1/mat3;   centerPoint.y = mat2/mat3;  radius=(float) Math.sqrt(((pA.x-centerPoint.x)*(pA.x-centerPoint.x) + (pA.y-centerPoint.y)*(pA.y-centerPoint.y)));    circle.setCenterPoint(centerPoint); circle.setRadius(radius);  return circle;}/** * 求一段圆弧两端另一点的坐标 * @param circle * @param startP 圆弧一端的点 * @param angle 圆弧对应的角度 * @return */public PointF getEndPointOfArc(Circle circle,PointF startP,float angle) {PointF centerP=circle.getCenterPoint();PointF endPointF=new PointF();endPointF.x=(float) (centerP.x+(startP.x-centerP.x)*Math.cos(angle*Math.PI/180)-(startP.y-centerP.y)*Math.sin(angle*Math.PI/180));endPointF.y=(float) (centerP.y+(startP.x-centerP.x)*Math.sin(angle*Math.PI/180)+(startP.y-centerP.y)*Math.cos(angle*Math.PI/180));return endPointF;}}






更多相关文章

  1. android画了一个笑脸
  2. Solution of issue: Android(安卓)soft keyboard overlap with i
  3. Android(安卓)Scroll分析
  4. Android(安卓)Canvas类介绍和Android(安卓)Draw Rect 坐标图示
  5. Android(安卓)Canvas类介绍和Android(安卓)Draw Rect 坐标图示
  6. (1)集成
  7. Android之自定义View实现随手势滑动的小圆球
  8. Android(安卓)自定义视图
  9. Android中贪吃蛇游戏的学习(三)

随机推荐

  1. Django代理模型返回父模型
  2. sqlalchemy的基础使用,sqlalchemy调用外部
  3. 转换器4:手写PHP转Python编译器,语法解析部
  4. Tensorflow:恢复图形和模型,然后在单个图像
  5. 机器学习Python数据特征选定
  6. 在混合的Bash-Python代码片段中,变量的双
  7. python基础(7)--深浅拷贝、函数
  8. Python学习之四sys.argv
  9. python中merge、concat用法
  10. 使用nagios+python监控nginx进程数