2022-10-19 07:10:11 +00:00
|
|
|
package dnmshared
|
|
|
|
|
|
|
|
import (
|
2022-10-22 05:38:10 +00:00
|
|
|
"fmt"
|
2022-12-25 12:17:22 +00:00
|
|
|
. "jsexport/battle"
|
|
|
|
"resolv"
|
2022-10-22 05:38:10 +00:00
|
|
|
"strings"
|
2022-10-19 07:10:11 +00:00
|
|
|
)
|
|
|
|
|
2022-12-25 07:39:30 +00:00
|
|
|
func NormVec2D(dx, dy float64) Vec2D {
|
|
|
|
return Vec2D{X: dy, Y: -dx}
|
|
|
|
}
|
|
|
|
|
2022-10-22 05:38:10 +00:00
|
|
|
func ConvexPolygonStr(body *resolv.ConvexPolygon) string {
|
2023-02-17 07:38:37 +00:00
|
|
|
var s []string = make([]string, body.Points.Cnt)
|
|
|
|
for i := int32(0); i < body.Points.Cnt; i++ {
|
|
|
|
p := body.GetPointByOffset(i)
|
2022-12-15 02:03:48 +00:00
|
|
|
s[i] = fmt.Sprintf("[%.2f, %.2f]", p[0]+body.X, p[1]+body.Y)
|
2022-10-22 05:38:10 +00:00
|
|
|
}
|
|
|
|
|
2022-11-12 12:34:38 +00:00
|
|
|
return fmt.Sprintf("{\n%s\n}", strings.Join(s, ",\n"))
|
2022-10-22 05:38:10 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 05:55:43 +00:00
|
|
|
func RectCenterStr(body *resolv.Object, halfBoundingW, halfBoundingH, topPadding, bottomPadding, leftPadding, rightPadding, spaceOffsetX, spaceOffsetY float64) string {
|
2022-12-18 03:39:25 +00:00
|
|
|
return fmt.Sprintf("{%.2f, %.2f}", body.X+leftPadding+halfBoundingW-spaceOffsetX, body.Y+bottomPadding+halfBoundingH-spaceOffsetY)
|
2022-12-16 05:55:43 +00:00
|
|
|
}
|