From e5659a16092dc90fd7b06f3659158ddae6e1edd3 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期一, 06 七月 2020 17:06:34 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
app/src/main/java/safeluck/drive/evaluation/util/Utils.java | 85 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/app/src/main/java/safeluck/drive/evaluation/util/Utils.java b/app/src/main/java/safeluck/drive/evaluation/util/Utils.java
index b7e43f5..2c1ab57 100644
--- a/app/src/main/java/safeluck/drive/evaluation/util/Utils.java
+++ b/app/src/main/java/safeluck/drive/evaluation/util/Utils.java
@@ -8,6 +8,7 @@
import com.anyun.exam.lib.MyLog;
import com.anyun.exam.lib.util.ByteUtil;
+import com.google.gson.Gson;
import com.safeluck.aykj.utils.BytesUtils;
import java.io.File;
@@ -37,7 +38,11 @@
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;
+import safeluck.drive.evaluation.app;
+import safeluck.drive.evaluation.bean.CarModel;
+import safeluck.drive.evaluation.bean.GisCarModel;
import safeluck.drive.evaluation.bean.Point;
+import safeluck.drive.evaluation.httpmodule.GsonConverterFactory;
import static java.lang.Math.cos;
import static java.lang.Math.pow;
@@ -656,4 +661,84 @@
}
}
+
+
+ public static List<CarModel> getCarModelData(Point basePoint, List<Integer> axial, List<Point> car){
+ List<CarModel> carModelList = new ArrayList<>();
+ double C02= (car.get(0).getX()-basePoint.getX())*(car.get(0).getX()-basePoint.getX()) + (car.get(0).getY()-basePoint.getY())*(car.get(0).getY()-basePoint.getY());
+ double c0 = Math.sqrt(C02);
+ CarModel carModel = new CarModel();
+ carModel.setDistance(c0);
+ carModel.setAngle(0.0);
+ carModelList.add(carModel);
+
+ for (int i = 1; i < car.size(); ++i) {
+ double dis2 = (car.get(i).getX()-basePoint.getX())*(car.get(i).getX()-basePoint.getX()) + (car.get(i).getY()-basePoint.getY())*(car.get(i).getY()-basePoint.getY());
+ double dis = Math.sqrt(dis2);
+
+ CarModel c =new CarModel();
+ c.setDistance(dis);
+
+ c.setAngle(180 * Math.acos((dis2 + C02 - ((car.get(i).getX()-car.get(0).getX())*(car.get(i).getX()-car.get(0).getX()) +
+ (car.get(i).getY()-car.get(0).getY())*(car.get(i).getY()-car.get(0).getY())))/(2*c0*dis)) / Math.PI);
+
+ if (i > axial.get(1)){
+ c.setAngle( 360.0 - c.getAngle());
+ }
+ carModelList.add(c);
+ }
+ return carModelList;
+ }
+
+ public static List<Point> getCarPoint(double pitch,double yaw,Point point){
+ pitch = 0;
+// yaw = 45;
+ Point main_ant = point;
+ List<Point> carNew = new ArrayList<>();
+ StringBuffer buffer=FileUtil.readAssetTxtFile(app.getAppContext(),"giscar.json");
+ Log.i(TAG,"giscar="+buffer.toString());
+ GisCarModel gisCarModel= new Gson().fromJson(buffer.toString(),GisCarModel.class);
+ List<Point> pointList = new ArrayList<Point>() ;
+ for (int i = 0; i < gisCarModel.getPoint().size(); i++) {
+ double x= gisCarModel.getPoint().get(i);
+ i++;
+ double y= gisCarModel.getPoint().get(i);
+ pointList.add(new Point(x,y));
+
+
+
+ }
+ double mainAnt_x = gisCarModel.getMain_ant().get(0);
+ double mainAnt_y = gisCarModel.getMain_ant().get(1);
+ List<CarModel> carModels = getCarModelData(new Point(mainAnt_x, mainAnt_y),gisCarModel.getAxial(),pointList);
+ if (carModels != null && carModels.size()>0){
+
+ for (int i = 0; i < carModels.size(); ++i) {
+ Log.i(TAG,String.format("浣嶇疆[%d],distance=%f,angle=%f",i,carModels.get(i).getDistance(),carModels.get(i).getAngle()));
+ double qrx = carModels.get(i).getDistance() * Math.sin(carModels.get(i).getAngle() * Math.PI / 180);
+ double qry = carModels.get(i).getDistance() * Math.cos(carModels.get(i).getAngle() * Math.PI / 180) * Math.cos(pitch * Math.PI / 180);
+
+ double projectDistance = Math.sqrt(Math.pow(qrx, 2) + Math.pow(qry, 2));
+ double projectAngle = Math.acos(qry / projectDistance) * 180 / Math.PI;
+
+ if (carModels.get(i).getAngle() > 180) {
+ projectAngle = 360 - projectAngle;
+ }
+
+ double X =
+ projectDistance * Math.sin(yaw * Math.PI / 180) * Math.cos(projectAngle * Math.PI / 180) -
+ projectDistance * Math.cos(yaw * Math.PI / 180) * Math.sin(projectAngle * Math.PI / 180) +
+ main_ant.getX();
+ double Y =
+ projectDistance * Math.sin(yaw * Math.PI / 180) * Math.sin(projectAngle * Math.PI / 180) +
+ projectDistance * Math.cos(yaw * Math.PI / 180) * Math.cos(projectAngle * Math.PI / 180) +
+ main_ant.getY();
+ carNew.add(new Point(X,Y));
+
+ }
+ }
+ return carNew;
+
+
+ }
}
--
Gitblit v1.8.0