最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android開(kāi)發(fā)實(shí)現(xiàn)的幾何圖形工具類GeometryUtil完整實(shí)例

 更新時(shí)間:2017年11月08日 10:15:02   作者:LovooGod  
這篇文章主要介紹了Android開(kāi)發(fā)實(shí)現(xiàn)的幾何圖形工具類GeometryUtil,涉及Android坐標(biāo)圖形數(shù)值運(yùn)算相關(guān)操作技巧,需要的朋友可以參考下

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

package com.android.imooc.goo;
import android.graphics.PointF;
/**
 * 幾何圖形工具
 */
public class GeometryUtil {
  /**
   * As meaning of method name. 獲得兩點(diǎn)之間的距離
   *
   * @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. 獲得兩點(diǎn)連線的中點(diǎn)
   *
   * @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ù)百分比獲取兩點(diǎn)之間的某個(gè)點(diǎn)坐標(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ù)分度值,計(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. 獲取
   * 通過(guò)指定圓心,斜率為lineK的直線與圓的交點(diǎn)。
   *
   * @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;
  }
}

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android圖形與圖像處理技巧總結(jié)》、《Android開(kāi)發(fā)入門與進(jìn)階教程》、《Android調(diào)試技巧與常見(jiàn)問(wèn)題解決方法匯總》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)

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

相關(guān)文章

  • Android編程實(shí)現(xiàn)3D旋轉(zhuǎn)效果實(shí)例

    Android編程實(shí)現(xiàn)3D旋轉(zhuǎn)效果實(shí)例

    這篇文章主要介紹了Android編程實(shí)現(xiàn)3D旋轉(zhuǎn)效果的方法,基于Android的Camera類實(shí)現(xiàn)坐標(biāo)變換達(dá)到圖片3D旋轉(zhuǎn)效果,需要的朋友可以參考下
    2016-01-01
  • Android中imageview.ScaleType使用方法詳細(xì)介紹

    Android中imageview.ScaleType使用方法詳細(xì)介紹

    這篇文章主要介紹了Android中imageview.ScaleType使用方法詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • Android程序開(kāi)發(fā)之使用PullToRefresh實(shí)現(xiàn)下拉刷新和上拉加載

    Android程序開(kāi)發(fā)之使用PullToRefresh實(shí)現(xiàn)下拉刷新和上拉加載

    這篇文章主要介紹了Android程序開(kāi)發(fā)之使用PullToRefresh實(shí)現(xiàn)下拉刷新和上拉加載的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2016-07-07
  • Flutter中獲取屏幕及Widget的寬高示例代碼

    Flutter中獲取屏幕及Widget的寬高示例代碼

    這篇文章主要給大家介紹了關(guān)于Flutter中如何獲取屏幕及Widget的寬高的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者使用Flutter具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-03-03
  • Android開(kāi)發(fā)常用經(jīng)典代碼段集錦

    Android開(kāi)發(fā)常用經(jīng)典代碼段集錦

    這篇文章主要介紹了Android開(kāi)發(fā)常用經(jīng)典代碼段,涉及Android開(kāi)發(fā)過(guò)程中針對(duì)手機(jī)、聯(lián)系人、圖片、存儲(chǔ)卡等的相關(guān)操作技巧,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下
    2016-02-02
  • Android View源碼解讀 DecorView與ViewRootImpl淺談

    Android View源碼解讀 DecorView與ViewRootImpl淺談

    這篇文章主要解讀了Android View源碼,為大家詳細(xì)介紹DecorView與ViewRootImpl,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-02-02
  • Android選擇與上傳圖片之Matisse教程

    Android選擇與上傳圖片之Matisse教程

    這篇文章主要介紹了在Android中對(duì)于圖片的選擇與上傳方法,本文介紹了Matisse的相關(guān)使用教程,學(xué)習(xí)Android的同學(xué)進(jìn)來(lái)看看吧
    2021-08-08
  • Android中自定義ContentProvider實(shí)例

    Android中自定義ContentProvider實(shí)例

    應(yīng)用A(TestBaidu)調(diào)用另外一個(gè)應(yīng)用(TestContentProvider)即自定義ContentProvider的使用,其它應(yīng)用調(diào)用該ContentProvider,具體如下,感興趣的朋友可以參考下哈
    2013-06-06
  • Android編程常用技巧實(shí)例總結(jié)

    Android編程常用技巧實(shí)例總結(jié)

    這篇文章主要介紹了Android編程常用技巧實(shí)例總結(jié),包括Android對(duì)話框、分辨率、資源、字體等操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-11-11
  • Android?組件化神器之Arouter依賴配置使用

    Android?組件化神器之Arouter依賴配置使用

    這篇文章主要為大家介紹了Android?組件化神器之Arouter依賴配置使用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-06-06

最新評(píng)論

建宁县| 芷江| 岳阳市| 镇康县| 九龙县| 海门市| 化隆| 安丘市| 四平市| 车致| 黄骅市| 香格里拉县| 武山县| 永川市| 台北县| 云安县| 嘉禾县| 永丰县| 清流县| 越西县| 稷山县| 微博| 丹巴县| 阳曲县| 绿春县| 海宁市| 天祝| 金寨县| 江孜县| 赣州市| 吉木萨尔县| 巫溪县| 奉贤区| 万源市| 沧源| 南宁市| 达日县| 栖霞市| 龙陵县| 乌兰察布市| 甘德县|