本文主要是介绍JTS: 15 Angle 角度计算,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
这里写目录标题
- 版本
- 代码
版本
org.locationtech.jts:jts-core:1.19.0
链接: github
代码
package pers.stu.algorithm;import org.locationtech.jts.algorithm.Angle;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;/*** 角度使用* @author LiHan* 2023-11-06 10:11:54*/
public class AngleUse {private static final Logger LOGGER = LoggerFactory.getLogger(AngleUse.class);private Coordinate A = null;private Coordinate B = null;private Coordinate C = null;public static void main(String[] args) {AngleUse angleUse = new AngleUse();angleUse.init();angleUse.test02();}public void init() {A = new Coordinate(1, 3);B = new Coordinate(1, 1);C = new Coordinate(3, 1);}public void test00() {LOGGER.info("是否是锐角:{}", Angle.isAcute(A, B, C));LOGGER.info("是否是钝角:{}", Angle.isObtuse(A, B, C));LOGGER.info("最小夹角:{}", Angle.angleBetween(A, B, C));LOGGER.info("最小夹角:{}", Angle.toDegrees(Angle.angleBetween(A, B, C)));/*17:11:40.006 [main] INFO pers.stu.algorithm.AngleUse - 是否是锐角:false17:11:40.007 [main] INFO pers.stu.algorithm.AngleUse - 是否是钝角:false17:11:40.008 [main] INFO pers.stu.algorithm.AngleUse - 最小夹角:1.570796326794896617:11:40.008 [main] INFO pers.stu.algorithm.AngleUse - 最小夹角:90.0*/}public void test01() {//找对应的位置 0到180(逆时针)之间返回正数,180-360(顺时针)之前返回负数System.out.println(Angle.toDegrees(Angle.normalize(Angle.toRadians(50))));//50.0System.out.println(Angle.toDegrees(Angle.normalize(Angle.toRadians(181))));//-179.0System.out.println(Angle.toDegrees(Angle.normalize(Angle.toRadians(369))));//9.0System.out.println(Angle.toDegrees(Angle.normalize(Angle.toRadians(-10))));//-10.0}public void test02() {Coordinate Bi = new Coordinate(0,2);Coordinate Ai = new Coordinate(1,1);Coordinate Ci = new Coordinate(1,3);//延Ai-Bi边逆时针转到Ai-CI边的角度值System.out.println("Angle.interiorAngle(Bi,Ai,Ci)角度="+Angle.toDegrees(Angle.interiorAngle(Bi,Ai,Ci)));//Angle.interiorAngle(Bi,Ai,Ci)角度=315.0//延Ci-Ai边逆时针转到Ai-BI边的角度值System.out.println("Angle.interiorAngle(Ci,Ai,Bi)角度="+Angle.toDegrees(Angle.interiorAngle(Ci,Ai,Bi)));//Angle.interiorAngle(Ci,Ai,Bi)角度=45.0}
}
这篇关于JTS: 15 Angle 角度计算的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!