Files
sjy01-image-proc/pkg/producer/grid_img.go
nuknal 2fcbc389c6 4*4*5
2024-09-10 14:13:30 +08:00

44 lines
903 B
Go

package producer
import "starwiz.cn/sjy01/image-proc/pkg/config"
type GridPoint struct {
Row, Col, H int
}
// 网格点要覆盖边界,甚至大于边界
func gridImage2(m, n, height, width, k, hmin, hmax int) []*GridPoint {
a := int((height) / (m))
var lines []int
for i := 0; i <= m; i++ {
lines = append(lines, a*i)
}
b := int((width) / (n))
var samples []int
for i := 0; i <= n; i++ {
samples = append(samples, b*i)
}
hmax = (hmax+hmin)/2.0 + config.GCONFIG.RPC.AltitudeRange/2
hmin = (hmax+hmin)/2.0 - config.GCONFIG.RPC.AltitudeRange/2
dh := (hmax - hmin) / (k)
var h []int
for i := 1; i <= k; i++ {
h = append(h, hmin+dh*i)
}
var points []*GridPoint
for l := 0; l < len(h); l++ {
for i := 0; i < len(lines); i++ {
for j := 0; j < len(samples); j++ {
p := GridPoint{lines[i], samples[j], h[l]}
points = append(points, &p)
}
}
}
return points
}