cgcs2000坐标系与wgs84坐标系之间的旋转矩阵
时间: 2023-09-13 13:08:12 浏览: 182
CGCS2000坐标系和WGS84坐标系之间的转换需要进行三次旋转,分别是绕Z轴旋转、绕Y轴旋转和绕Z轴旋转。下面是这三次旋转对应的旋转矩阵:
绕Z轴旋转:
```
cosθ -sinθ 0
sinθ cosθ 0
0 0 1
```
其中,θ为两个坐标系之间的经度差,单位为弧度。
绕Y轴旋转:
```
cosθ 0 sinθ
0 1 0
-sinθ 0 cosθ
```
其中,θ为两个坐标系之间的纬度差,单位为弧度。
绕Z轴旋转:
```
cosθ -sinθ 0
sinθ cosθ 0
0 0 1
```
其中,θ为两个坐标系之间的方位角差,单位为弧度。
将这三个旋转矩阵相乘,即可得到CGCS2000坐标系和WGS84坐标系之间的旋转矩阵。
相关问题
gcj02转cgcs2000坐标系
### GCJ-02到CGCS2000坐标的转换方法
GCJ-02坐标系是中国国内使用的地理加密坐标系,而CGCS2000(China Geodetic Coordinate System 2000)则是中国国家大地坐标系。两者之间的差异主要体现在定义方式以及地球椭球参数的不同。
#### 转换原理概述
要实现从GCJ-02到CGCS2000的转换,通常需要经过以下几个逻辑过程:
1. **GCJ-02 到 WGS-84 的逆向偏移**
首先通过反向计算去除GCJ-02相对于WGS-84所施加的扰动偏差[^1]。此部分涉及复杂的算法处理,因为GCJ-02本身是对WGS-84进行了特定加密的结果。
2. **WGS-84 到 CGCS2000 的七参数变换**
完成第一步之后,可以利用经典的七参数法完成从WGS-84到CGCS2000的转换。该方法基于两个不同空间直角坐标系间的旋转、平移和尺度变化来建立映射关系[^1]。
以下是具体的技术细节与代码示例:
---
#### 实现步骤说明
##### 步骤一:GCJ-02 -> WGS-84 反解密
由于GCJ-02是在WGS-84基础上加上了一定程度上的随机干扰项得到的新坐标位置,因此可以通过已知的经验公式尝试还原原始未受保护的位置数据。注意这里存在一定的误差范围取决于实际应用环境的要求精度水平。
```java
public class GcjToWgs {
public static double[] gcjToWgs(double lat, double lon){
if(outOfChina(lat,lon)){
return new double[]{lat,lon};
}
double dLat = transformLat(lon - 105.0, lat - 35.0);
double dLon = transformLon(lon - 105.0, lat - 35.0);
double radLat = lat / 180.0 * Math.PI;
double magic = Math.sin(radLat);
magic = 1 - 0.00669342162296594323 * magic * magic;
double sqrtMagic = Math.sqrt(magic);
dLat = (dLat * 180.0) / ((6378245 * (1 - 0.00669342162296594323)) / (magic * sqrtMagic) * Math.PI);
dLon = (dLon * 180.0) / (6378245 / sqrtMagic * Math.cos(radLat) * Math.PI);
double mgLat = lat + dLat;
double mgLon = lon + dLon;
return delta(mgLat,mgLon,lat,lon); // 返回调整后的纬度经度数组
}
private static boolean outOfChina(double latitude,double longitude){
if(longitude<72.004 ||longitude>137.8347)return true;
if(latitude<0.8293||latitude>55.8271)return true;
return false;
}
private static double transformLat(double x,double y){
double ret= -100.0+2.0*x+3.0*y+0.2*y*y+0.1*x*y+(x*Math.pow(y,2));
return ret;
}
private static double transformLon(double x,double y){
double ret=300.0+1.0*x+2.0*y+0.1*x*x+0.1*x*y+(y*Math.pow(x,2));
return ret;
}
private static double[] delta(double lattitude,double longtitude,double orginLatitude,double originLongitude){
double d1=Math.toRadians(lattitude-originLatitude);
double d2=Math.toRadians(longtitude-originLongitude);
return new double[]{lattitude-d1*111111,longtitude-d2*111111};// 近似简化版距离修正因子
}
}
```
##### 步骤二:WGS-84 -> CGCS2000 使用七参数模型
对于第二步操作,则需要用到精确测量得出的标准转换系数来进行矩阵运算。这些数值一般由官方机构发布,在某些情况下也可能采用近似的平均值作为替代方案之一。
假设我们已经获取到了一组适用于目标区域内的七参数集{ΔX, ΔY, ΔZ, Rx, Ry, Rz, Scale},那么就可以按照如下方式进行编程实现了:
```java
import Jama.Matrix;
public class WgsToCgcs{
public static void main(String args[]){
/* Example Input */
double [] wgsCoord={...}; // Replace with actual coordinates.
Matrix T=new Matrix(new double[][]{{wgsCoord[0]},
{wgsCoord[1]},
{wgsCoord[2]}});
// Define seven parameters here according to your area of interest.
double dx=-100.0,dy=-200.0,dz=-300.0,
rx=0.0000,-ry=0.0000,rz=0.0000,scaleFactor=1.0000000115;// Hypothetical values.
Matrix R=createRotationMatrix(rx, ry, rz);
Matrix S=createScaleMatrix(scaleFactor);
Matrix D=createTranslationVector(dx, dy, dz);
Matrix result=(S.times(R)).times(T).plus(D);
System.out.println("Converted Coordinates:");
System.out.printf("%.6f %.6f %.6f",result.get(0,0),result.get(1,0),result.get(2,0));
}
private static Matrix createRotationMatrix(double rx,double ry,double rz){
double thetaRx=Math.toRadians(rx/3600),
thetaRy=Math.toRadians(-ry/3600),
thetaRz=Math.toRadians(rz/3600);
Matrix Rx=new Matrix(new double [][] {{1 , 0 , 0 },
{0 ,Math.cos(thetaRx),-Math.sin(thetaRx)},
{0 ,Math.sin(thetaRx), Math.cos(thetaRx)} });
Matrix Ry=new Matrix(new double [][] {{Math.cos(thetaRy) ,0 ,Math.sin(thetaRy)},
{0 ,1 , 0},
{-Math.sin(thetaRy) ,0 ,Math.cos(thetaRy)}} );
Matrix Rz=new Matrix(new double [][] {{Math.cos(thetaRz),-Math.sin(thetaRz),0},
{Math.sin(thetaRz), Math.cos(thetaRz),0},
{ 0, 0,1}} );
return Rz.times(Ry.times(Rx));
}
private static Matrix createScaleMatrix(double scaleFactor){
return new Matrix(new double [][] {{scaleFactor,0 ,0 },
{0 ,scaleFactor,0 },
{0 ,0 ,scaleFactor}});
}
private static Matrix createTranslationVector(double dx,double dy,double dz){
return new Matrix(new double [][] {{dx},{dy},{dz}});
}
}
```
以上展示了如何编写Java程序执行GCJ-02至CGCS2000之间相互转变的过程。需要注意的是,这仅是一个理论框架示意;真实场景下可能还需要考虑更多因素比如局部变形校正等问题才能达到更高精准度需求。
阅读全文
相关推荐













