张世豪
2 天以前 45a35805eb1e59972ad9a9c80815f2c030dc69bb
src/gecaoji/Gecaoji.java
@@ -62,7 +62,7 @@
        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;
@@ -151,7 +151,8 @@
        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);
@@ -176,9 +177,11 @@
        g2d.fill(fallbackShape);
        g2d.setColor(Color.WHITE);
        g2d.draw(fallbackShape);
    double rotationRadians = Math.toRadians(-headingDegrees);
    double lineLength = radius;
    double dx = lineLength * Math.sin(rotationRadians);
        // 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);
    g2d.drawLine(
        (int) Math.round(position.x),