gocv v0.36.1 opencv 4.9.0
This commit is contained in:
@@ -7,13 +7,6 @@ import (
|
||||
"gonum.org/v1/gonum/mat"
|
||||
)
|
||||
|
||||
// 常量
|
||||
const (
|
||||
focal = 1.3 // 焦距, m
|
||||
FOV = 1.7 // 视场角,degree
|
||||
nPixels = 9344 // 像素数
|
||||
)
|
||||
|
||||
type IntersectionPoint struct {
|
||||
Lat float64
|
||||
Lon float64
|
||||
@@ -22,46 +15,56 @@ type IntersectionPoint struct {
|
||||
|
||||
func Intersection(q Quaternion, satPos84 []float64, satTime time.Time, ucam int) IntersectionPoint {
|
||||
alpha := FOV * math.Pi / 180.0
|
||||
alpha = -alpha/2.0 + float64(ucam)*(alpha/float64(nPixels))
|
||||
alpha = -alpha/2.0 + float64(ucam)*(alpha/float64(PANPixels))
|
||||
direction := []float64{0, math.Tan(alpha), -1.3}
|
||||
|
||||
// -------- 相机坐标系下CCD成像方向向量转到卫星坐标系 --------
|
||||
Rcam := mat.NewDense(3, 3, []float64{
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1,
|
||||
})
|
||||
var dCam mat.VecDense
|
||||
dCam.MulVec(Rcam, mat.NewVecDense(3, direction))
|
||||
|
||||
// -------- 转到ECI坐标系 --------
|
||||
Ratt := q.ToRotationMatrix()
|
||||
RattT := &mat.Dense{}
|
||||
RattT.Inverse(Ratt)
|
||||
|
||||
v := mat.NewVecDense(3, direction)
|
||||
var result mat.VecDense
|
||||
result.MulVec(Ratt, v)
|
||||
eciDirection := result.RawVector().Data
|
||||
result.MulVec(Ratt, &dCam)
|
||||
dECI := result.RawVector().Data
|
||||
|
||||
// intersection := intersectWithEllipsoid(satPos, eciDirection)
|
||||
// lat, lon, _ := J2000ToWGS84(intersection[0], intersection[1], intersection[2], satTime)
|
||||
// -------- 转到ECEF坐标系 --------
|
||||
x, y, z := ECItoECEF(dECI[0], dECI[1], dECI[2], satTime)
|
||||
dECEF := []float64{x, y, z}
|
||||
|
||||
x, y, z := ECItoECEF(eciDirection[0], eciDirection[1], eciDirection[2], satTime)
|
||||
ecefDirection := []float64{x, y, z}
|
||||
intersection := intersectWithEllipsoid(satPos84, ecefDirection)
|
||||
// -------- 计算与地球表面的交点 --------
|
||||
intersection := intersectWithEllipsoid(satPos84, dECEF)
|
||||
lat, lon, h := ECEFToGeodetic(intersection[0], intersection[1], intersection[2])
|
||||
return IntersectionPoint{Lat: lat, Lon: lon, H: h}
|
||||
|
||||
}
|
||||
|
||||
func Intersection2(Qsat2orbit, Qorbit2eci Quaternion, satPos84 []float64, satTime time.Time, ucam int) IntersectionPoint {
|
||||
alpha := FOV * math.Pi / 180.0
|
||||
alpha = -alpha/2.0 + float64(ucam)*(alpha/float64(nPixels))
|
||||
alpha = -alpha/2.0 + float64(ucam)*(alpha/float64(PANPixels))
|
||||
direction := []float64{0, math.Tan(alpha), -1.3} // 卫星(相机)坐标系下CCD成像方向向量
|
||||
|
||||
// -------- 相机坐标系下CCD成像方向向量转到卫星坐标系 --------
|
||||
Rcam := mat.NewDense(3, 3, []float64{
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1,
|
||||
})
|
||||
var dCam mat.VecDense
|
||||
dCam.MulVec(Rcam, mat.NewVecDense(3, direction))
|
||||
|
||||
// -------- 转到轨道坐标系 --------
|
||||
Rsat2orbit := Qsat2orbit.ToRotationMatrix()
|
||||
Rsat2orbitT := &mat.Dense{}
|
||||
Rsat2orbitT.Inverse(Rsat2orbit)
|
||||
var r0 mat.VecDense
|
||||
r0.MulVec(Rsat2orbit, mat.NewVecDense(3, direction))
|
||||
r0.MulVec(Rsat2orbit, &dCam)
|
||||
dOrbit := r0.RawVector().Data
|
||||
|
||||
// -------- 转到ECI坐标系 --------
|
||||
Rorbit2eci := Qorbit2eci.ToRotationMatrix()
|
||||
Rorbit2eciT := &mat.Dense{}
|
||||
Rorbit2eciT.Inverse(Rorbit2eci)
|
||||
var r1 mat.VecDense
|
||||
r1.MulVec(Rorbit2eci, mat.NewVecDense(3, dOrbit))
|
||||
dECI := r1.RawVector().Data
|
||||
|
||||
Reference in New Issue
Block a user