🔥 移除不合理astar设计

This commit is contained in:
kercylan98
2023-06-19 18:14:53 +08:00
parent ad1794a9e3
commit 6c5f0c01a1
13 changed files with 109 additions and 594 deletions
+32 -3
View File
@@ -7,12 +7,41 @@ import (
func newShape[V generic.SignedNumber](s geometry.Shape[V]) *shape[V] {
return &shape[V]{
Shape: s,
Shape: s,
centroid: geometry.CalcRectangleCentroid(s),
boundingRadius: geometry.CalcBoundingRadius(s),
edges: s.Edges(),
}
}
type shape[V generic.SignedNumber] struct {
geometry.Shape[V]
links []*shape[V]
portals []geometry.Line[V]
links []*shape[V]
portals []geometry.Line[V]
boundingRadius V
centroid geometry.Point[V]
edges []geometry.Line[V]
weight V
x, y V
}
func (slf *shape[V]) Edges() []geometry.Line[V] {
return slf.edges
}
func (slf *shape[V]) BoundingRadius() V {
return slf.boundingRadius
}
func (slf *shape[V]) Centroid() geometry.Point[V] {
return slf.centroid
}
func (slf *shape[V]) IsWall() bool {
return slf.weight == 0
}
func (slf *shape[V]) GetCost(point geometry.Point[V]) V {
return geometry.CalcDistance(geometry.DoublePointToCoordinate(slf.Centroid(), point))
}