日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Android >内容正文

Android

android图形开发工具,Android开发实现的几何图形工具类GeometryUtil完整实例

發(fā)布時間:2024/8/1 Android 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android图形开发工具,Android开发实现的几何图形工具类GeometryUtil完整实例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

本文實例講述了Android開發(fā)實現(xiàn)的幾何圖形工具類GeometryUtil。分享給大家供大家參考,具體如下:

package com.android.imooc.goo;

import android.graphics.PointF;

/**

* 幾何圖形工具

*/

public class GeometryUtil {

/**

* As meaning of method name. 獲得兩點之間的距離

*

* @param p0

* @param p1

* @return

*/

public static float getDistanceBetween2Points(PointF p0, PointF p1) {

float distance = (float) Math.sqrt(Math.pow(p0.y - p1.y, 2) + Math.pow(p0.x - p1.x, 2));

return distance;

}

/**

* Get middle point between p1 and p2. 獲得兩點連線的中點

*

* @param p1

* @param p2

* @return

*/

public static PointF getMiddlePoint(PointF p1, PointF p2) {

return new PointF((p1.x + p2.x) / 2.0f, (p1.y + p2.y) / 2.0f);

}

/**

* Get point between p1 and p2 by percent. 根據(jù)百分比獲取兩點之間的某個點坐標(biāo)

*

* @param p1

* @param p2

* @param percent

* @return

*/

public static PointF getPointByPercent(PointF p1, PointF p2, float percent) {

return new PointF(evaluateValue(percent, p1.x, p2.x), evaluateValue(percent, p1.y, p2.y));

}

/**

* 根據(jù)分度值,計算從start到end中,fraction位置的值。fraction范圍為0 -> 1

*

* @param fraction

* @param start

* @param end

* @return

*/

public static float evaluateValue(float fraction, Number start, Number end) {

return start.floatValue() + (end.floatValue() - start.floatValue()) * fraction;

}

/**

* Get the point of intersection between circle and line. 獲取

* 通過指定圓心,斜率為lineK的直線與圓的交點。

*

* @param pMiddle

* The circle center point.

* @param radius

* The circle radius.

* @param lineK

* The slope of line which cross the pMiddle.

* @return

*/

public static PointF[] getIntersectionPoints(PointF pMiddle, float radius, Double lineK) {

PointF[] points = new PointF[2];

float radian, xOffset = 0, yOffset = 0;

if (lineK != null) {

radian = (float) Math.atan(lineK);

xOffset = (float) (Math.sin(radian) * radius);

yOffset = (float) (Math.cos(radian) * radius);

} else {

xOffset = radius;

yOffset = 0;

}

points[0] = new PointF(pMiddle.x + xOffset, pMiddle.y - yOffset);

points[1] = new PointF(pMiddle.x - xOffset, pMiddle.y + yOffset);

return points;

}

}

希望本文所述對大家Android程序設(shè)計有所幫助。

總結(jié)

以上是生活随笔為你收集整理的android图形开发工具,Android开发实现的几何图形工具类GeometryUtil完整实例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。