CoordinateUtil.java
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.jkdata.tool;
import java.util.HashMap;
import java.util.Map;
public class CoordinateUtil {
public static Map<String,Double> changCoordinate (String floor, String x1, String y1){
Map<String,Double> map = new HashMap<>();//初始化
map.put("x", 0.00);
map.put("y", 0.00);
double py_x = 0.00;
double py_y = 0.00;
double sin = Math.sin(CommonConstant.XZJD);
double cos = Math.cos(CommonConstant.XZJD);
System.out.println("sin:"+sin+",cos:"+cos);
if("B2".equals(floor)){
//平移到原点
double x0 = Double.valueOf(x1) - CommonConstant.LT_B2_X;
double y0 = Double.valueOf(y1) - CommonConstant.LT_B2_Y;
System.out.println("平移后的坐标:x0:"+x0+",y0:"+y0);
//旋转坐标
double x = x0*sin + y0*cos;
double y = y0*sin - x0*cos;
System.out.println("旋转后坐标为:X:"+x+",Y:"+y);
//平移后的坐标
py_x = x + CommonConstant.MQ_B2_X/CommonConstant.BLC_X;
py_y = y + CommonConstant.MQ_B2_Y/CommonConstant.BLC_Y;
System.out.println("平移后的坐标为:X:"+py_x+",Y:"+py_y);
}else if("B1".equals(floor)){
//平移到原点
double x0 = Double.valueOf(x1) - CommonConstant.LT_B1_X;
double y0 = Double.valueOf(y1) - CommonConstant.LT_B1_Y;
System.out.println("平移后的坐标:x0:"+x0+",y0:"+y0);
//旋转坐标
double x = x0*sin + y0*cos;
double y = y0*sin - x0*cos;
System.out.println("旋转后坐标为:X:"+x+",Y:"+y);
//平移后的坐标
py_x = x + CommonConstant.MQ_B1_X/CommonConstant.BLC_X;
py_y = y + CommonConstant.MQ_B1_Y/CommonConstant.BLC_Y;
System.out.println("平移后的坐标为:X:"+py_x+",Y:"+py_y);
}else{
py_x = 0.00;
py_y = 0.00;
}
//放大后的坐标
double fd_x = CommonConstant.BLC_X*py_x;
double fd_y = CommonConstant.BLC_Y*py_y;
System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y);
map.put("x",fd_x);
map.put("y",fd_y);
return map;
}
}