| | |
| | | |
| | | double x = parseCoordinate(device.getRealtimeX()); |
| | | double y = parseCoordinate(device.getRealtimeY()); |
| | | double heading = parseHeading(device.getHeading()); |
| | | double heading = parseHeading(device.getYaw()); |
| | | if (Double.isNaN(x) || Double.isNaN(y)) { |
| | | // Keep showing the last known mower position when temporary sensor glitches occur. |
| | | return; |
| | |
| | | double iconHeight = icon.getHeight(null); |
| | | double maxSide = Math.max(iconWidth, iconHeight); |
| | | double scaleFactor = worldSize / Math.max(maxSide, MIN_SCALE); |
| | | double rotationRadians = Math.toRadians(-headingDegrees); |
| | | // 割草机图标默认朝南,Yaw=0表示正北,需要旋转180度 |
| | | double rotationRadians = Math.toRadians(headingDegrees + 180); |
| | | |
| | | AffineTransform original = g2d.getTransform(); |
| | | AffineTransform transformed = new AffineTransform(original); |
| | |
| | | g2d.fill(fallbackShape); |
| | | g2d.setColor(Color.WHITE); |
| | | g2d.draw(fallbackShape); |
| | | double rotationRadians = Math.toRadians(-headingDegrees); |
| | | // Yaw=0表示正北(0, -1),使用sin/cos计算坐标 |
| | | // sin(180)=0, cos(180)=-1 -> 正北 |
| | | double rotationRadians = Math.toRadians(180 - headingDegrees); |
| | | double lineLength = radius; |
| | | double dx = lineLength * Math.sin(rotationRadians); |
| | | double dy = lineLength * Math.cos(rotationRadians); |