From 5d5e3bca9a3538a35285ef9a90a5d423761646d4 Mon Sep 17 00:00:00 2001 From: Nicolai Ommer Date: Fri, 7 Dec 2018 22:02:59 +0100 Subject: [PATCH] [bugfix] Fixed coordinates and rotation --- pkg/vision/converter.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/vision/converter.go b/pkg/vision/converter.go index ca507ac..2222bc5 100644 --- a/pkg/vision/converter.go +++ b/pkg/vision/converter.go @@ -45,7 +45,7 @@ func ProtoToPackage(frame *sslproto.SSL_DetectionFrame, geometry *sslproto.SSL_G func createBallShape(ball *sslproto.SSL_DetectionBall) Circle { return Circle{ - Center: Point{*ball.X, *ball.Y}, + Center: Point{*ball.X, -*ball.Y}, Radius: ballRadius, Style: Style{ StrokeWidth: &ballStrokeWidth, @@ -62,8 +62,8 @@ func addGeometryShapes(pack *Package, geometry *sslproto.SSL_GeometryData) { pack.GoalDepth = float32(*geometry.Field.GoalDepth) for _, line := range geometry.Field.FieldLines { pack.Lines = append(pack.Lines, Line{ - P1: Point{*line.P1.X, *line.P1.Y}, - P2: Point{*line.P2.X, *line.P2.Y}, + P1: Point{*line.P1.X, -*line.P1.Y}, + P2: Point{*line.P2.X, -*line.P2.Y}, Style: Style{ Stroke: &white, StrokeWidth: &lineWidth, @@ -72,7 +72,7 @@ func addGeometryShapes(pack *Package, geometry *sslproto.SSL_GeometryData) { } for _, arc := range geometry.Field.FieldArcs { pack.Circles = append(pack.Circles, Circle{ - Center: Point{*arc.Center.X, *arc.Center.Y}, + Center: Point{*arc.Center.X, -*arc.Center.Y}, Radius: *arc.Radius, Style: Style{ Stroke: &white, @@ -111,7 +111,7 @@ func goalLinesPositive(geometry *sslproto.SSL_GeometryData) (lines []Line) { func createBotPath(bot *sslproto.SSL_DetectionRobot, fillColor string) Path { b := Bot{center2Dribbler, botRadius} x := float64(*bot.X) - y := float64(*bot.Y) + y := -float64(*bot.Y) o := float64(*bot.Orientation) return Path{ D: []PathElement{ @@ -148,7 +148,7 @@ func createBotPath(bot *sslproto.SSL_DetectionRobot, fillColor string) Path { func createBotId(bot *sslproto.SSL_DetectionRobot, strokeColor string) Text { return Text{ Text: strconv.Itoa(int(*bot.RobotId)), - P: Point{*bot.X, *bot.Y}, + P: Point{*bot.X, -*bot.Y}, Style: Style{ Fill: &strokeColor, }, @@ -165,17 +165,17 @@ func (b Bot) orient2CornerAngle() float64 { } func (b Bot) botRightX(orientation float64) float64 { - return math.Cos(orientation+b.orient2CornerAngle()) * b.botRadius + return math.Cos(-orientation+b.orient2CornerAngle()) * b.botRadius } func (b Bot) botRightY(orientation float64) float64 { - return math.Sin(orientation+b.orient2CornerAngle()) * b.botRadius + return math.Sin(-orientation+b.orient2CornerAngle()) * b.botRadius } func (b Bot) botLeftX(orientation float64) float64 { - return math.Cos(orientation-b.orient2CornerAngle()) * b.botRadius + return math.Cos(-orientation-b.orient2CornerAngle()) * b.botRadius } func (b Bot) botLeftY(orientation float64) float64 { - return math.Sin(orientation-b.orient2CornerAngle()) * b.botRadius + return math.Sin(-orientation-b.orient2CornerAngle()) * b.botRadius }