This commit is contained in:
nuknal
2024-08-22 16:32:27 +08:00
parent ca3e91b1d8
commit 6f2cfa797a
9 changed files with 300 additions and 305 deletions

View File

@@ -16,7 +16,7 @@ const (
MSSPixels = float64(payload.MSS_PIXEL_WIDTH)
MSSCellSize = 12.8 // µm
CameraRoll = 0.0 // 相机与卫星本体X轴的安装角度, degree FIXME: 安装矩阵应该由卫星方提供
CameraPitch = 0.5 // 相机与卫星本体Y轴的安装角度, degree
CameraPitch = 0.0 // 相机与卫星本体Y轴的安装角度, degree
)
// 计算过程使用PAN分辨率

View File

@@ -10,12 +10,13 @@ import (
)
type IntersectionPoint struct {
Lat float64
Lon float64
H float64
X84, Y84, Z84 float64
Lat float64
Lon float64
H float64
}
func IntersectionAttitude(q Quaternion, satPos84 []float64, satTime time.Time, ucam int) (IntersectionPoint, error) {
func Camera2GroundPoint(q Quaternion, satPos84 []float64, satTime time.Time, ucam int, groundH int) (IntersectionPoint, error) {
// alpha := FOV * math.Pi / 180.0
// alpha = -alpha/2.0 + float64(ucam)*(alpha/float64(PANPixels))
// direction := []float64{0, math.Tan(alpha), -1.3}
@@ -37,7 +38,7 @@ func IntersectionAttitude(q Quaternion, satPos84 []float64, satTime time.Time, u
dECEF := []float64{x, y, z}
// -------- 计算与地球表面的交点 --------
intersection, err := intersectWithEllipsoid(satPos84, dECEF)
intersection, err := SolveEllipticEquation(satPos84, dECEF, groundH)
if err != nil {
return IntersectionPoint{}, err
}
@@ -73,20 +74,23 @@ func IntersectionECI(Qsat2orbit, Qorbit2eci Quaternion, satPos84 []float64, satT
dECEF := []float64{x, y, z}
// -------- 计算交点 --------}
intersection, err := intersectWithEllipsoid(satPos84, dECEF)
intersection, err := SolveEllipticEquation(satPos84, dECEF, 0)
if err != nil {
return IntersectionPoint{}, err
}
lat, lon, h := ECEFGeocentricToGeodetic(intersection[0], intersection[1], intersection[2])
return IntersectionPoint{Lat: lat, Lon: lon, H: h}, nil
return IntersectionPoint{
X84: intersection[0], Y84: intersection[1], Z84: intersection[2],
Lat: lat, Lon: lon, H: h,
}, nil
}
// 计算与椭球表面的交点
func intersectWithEllipsoid(p0, d []float64) ([]float64, error) {
a2 := a * a
b2 := b * b
func SolveEllipticEquation(p0, d []float64, groundH int) ([]float64, error) {
a2 := (a + float64(groundH)) * (a + float64(groundH))
b2 := (b + float64(groundH)) * (b + float64(groundH))
A := d[0]*d[0]/a2 + d[1]*d[1]/a2 + d[2]*d[2]/b2
B := 2 * (p0[0]*d[0]/a2 + p0[1]*d[1]/a2 + p0[2]*d[2]/b2)

View File

@@ -1,8 +1,6 @@
package calculator
import (
"math"
"gonum.org/v1/gonum/mat"
"gonum.org/v1/gonum/spatial/r3"
)
@@ -28,38 +26,3 @@ func OrbitToECMatrix(pos, vec []float64) *mat.Dense {
return m
}
// IntersectionECEF 计算卫星与相机的交点,返回经纬度和高度
// FIXME: 该计算方法有误,待修正
func IntersectionECEF(Qsat2orbit Quaternion, satPos84, vec84 []float64, ucam int) (IntersectionPoint, error) {
alpha := FOV * math.Pi / 180.0
alpha = -alpha/2.0 + float64(ucam)*(alpha/float64(PANPixels))
direction := []float64{0, math.Tan(alpha), -1.3} // 卫星相机坐标系下CCD成像方向向量
// -------- 相机坐标系下CCD成像方向向量转到卫星坐标系 --------
Rcam := CameraRotMatrix(CameraRoll*math.Pi/180.0, CameraPitch*math.Pi/180.0, 0)
var dCam mat.VecDense
dCam.MulVec(Rcam, mat.NewVecDense(3, direction))
// -------- 转到轨道坐标系 --------
Rsat2orbit := Qsat2orbit.ToRotationMatrix()
var r0 mat.VecDense
r0.MulVec(Rsat2orbit, &dCam)
dOrbit := r0.RawVector().Data
// -------- 转到ECEF坐标系 --------
Rorbit2ecef := OrbitToECMatrix(satPos84, vec84)
var r1 mat.VecDense
r1.MulVec(Rorbit2ecef, mat.NewVecDense(3, dOrbit))
dECEF := r1.RawVector().Data
// -------- 计算交点 --------}
intersection, err := intersectWithEllipsoid(satPos84, dECEF)
if err != nil {
return IntersectionPoint{}, err
}
lat, lon, h := ECEFToGeodetic(intersection[0], intersection[1], intersection[2])
return IntersectionPoint{Lat: lat, Lon: lon, H: h}, err
}