nilupeng
2022-01-13 e3bd13f6f12aae8a01a61d3368373fa9636549eb
三角算法更新
2 files modified
59 ■■■■■ changed files
.idea/gradle.xml 3 ●●●● patch | view | raw | blame | history
app/src/main/java/com/demo/navtogether/utils/TriangleUtils.java 56 ●●●●● patch | view | raw | blame | history
.idea/gradle.xml
@@ -4,7 +4,7 @@
  <component name="GradleSettings">
    <option name="linkedExternalProjectsSettings">
      <GradleProjectSettings>
        <option name="testRunner" value="PLATFORM" />
        <option name="testRunner" value="GRADLE" />
        <option name="distributionType" value="DEFAULT_WRAPPED" />
        <option name="externalProjectPath" value="$PROJECT_DIR$" />
        <option name="gradleHome" value="D:/gradle-4.4" />
@@ -16,7 +16,6 @@
          </set>
        </option>
        <option name="resolveModulePerSourceSet" value="false" />
        <option name="useQualifiedModuleNames" value="true" />
      </GradleProjectSettings>
    </option>
  </component>
app/src/main/java/com/demo/navtogether/utils/TriangleUtils.java
@@ -18,11 +18,13 @@
        System.out.println(String.format("角度 坐标计算:a:%s,b:%s,c:%s",getDegrees(pA,pB,pC),getDegrees(pB,pC,pA),getDegrees(pC,pA,pB)));
        System.out.println(String.format("角度 转换为边长计算:a:%s,b:%s,c:%s",getDegrees2(pA,pB,pC),getDegrees2(pB,pC,pA),getDegrees2(pC,pA,pB)));
        System.out.println(String.format("角度 边长计算:a:%s,b:%s,c:%s",getDegrees(a,b,c),getDegrees(b,c,a),getDegrees(c,a,b)));
        System.out.println("边长 c:"+getLengthOfHypotenuse(a,b ));
        System.out.println("边长 c:"+getHypotenuseFromLength(a,b ));
        System.out.println("边长 c:"+getLengthOfSide(a,b ,getDegrees2(pA,pB,pC)));
        System.out.format("%s 度的余弦值为 %s", Math.toRadians(90), Math.cos(Math.toRadians(90)));
    }
    /************************直角三角算法*******************************/
    /**
     * 直角三角获取斜边
@@ -30,8 +32,56 @@
     * @param b 直角边长
     * @return 斜边边长
     */
    public static Double getLengthOfHypotenuse(double a,double b){
    public static Double getHypotenuseFromLength(double a,double b){
        return Math.sqrt(a*a+b*b);
    }
    /**
     * 直角三角形 根据角度和直角边长求斜边
     * @param degree    角度
     * @param width     直角边长
     * @return 斜边边长
     */
    public static double getHypotenuseFromDegree(double degree,double width){
        double cos = Math.cos(Math.toRadians(degree));//余弦
        return width / cos;
    }
    /**
     * 直角三角形 根据角度和斜边求直角边
     * @param degree    角度
     * @param width     斜边
     * @return 斜边边长
     */
    public static double getRightSideFromDegree(double degree,double width){
        double cos = Math.cos(Math.toRadians(degree));
        return width * cos;
    }
    /**
     * 直角三角形 根据直角边和斜边求直角边
     * @param a 直角边
     * @param b 斜边
     * @return 直角边长
     */
    public static double getRightSideFromLength(double a,double b){
        return Math.sqrt(b*b - a*a);
    }
    /************************end 直角三角算法*******************************/
    /**
     * 根据 B角和C角的a边长,获取A角-C角的b边长
     * @param A
     * @param B
     * @param a
     * @return
     */
    public static double getSideFromSideAndDegree(double A,double B,double a){
        // a÷sin A == b ÷ sin B
        return a/Math.sin(Math.toRadians(A))*Math.sin(Math.toRadians(B));
    }
    /**
@@ -94,7 +144,7 @@
        return (int) (180 * radian / Math.PI);
    }
/*    *//**
    /**
     * 根据坐标 获取角度
     * @param pA  坐标
     * @param degreesPoint  坐标  获取该点的角度