Как вращать Vec4 на сфере - PullRequest
0 голосов
/ 23 апреля 2020

Редактировать: мне удалось решить проблему, и теперь я могу нарисовать 3D след самолета

Я работаю с WorldWind Java. Я хочу повернуть Vec4 по осям x, y и z на земной сфере. Я нашел функцию, вычисляющую касательную на север. У меня вопрос, как я могу повернуть этот вектор.

   public Vec4 computeNorthPointingTangentAtLocation(Angle latitude, Angle longitude)
    {
       // Latitude is treated clockwise as rotation about the X-axis. We flip the latitude value so that a positive
        // rotation produces a clockwise rotation (when facing the axis).
        latitude = latitude.multiply(-1.0);

        double cosLat = latitude.cos();
        double sinLat = latitude.sin();
        double cosLon = longitude.cos();
        double sinLon = longitude.sin();

        // The north-pointing tangent is derived by rotating the vector (0, 1, 0) about the Y-axis by longitude degrees,
        // then rotating it about the X-axis by -latitude degrees. This can be represented by a combining two rotation
        // matrices Rlat, and Rlon, then transforming the vector (0, 1, 0) by the combined transform:
        //
        // NorthTangent = (Rlon * Rlat) * (0, 1, 0)
        //
        // Since the input vector only has a Y coordinate, this computation can be simplified. The simplified
        // computation is shown here as NorthTangent = (x, y, z).
        //
        double x = sinLat * sinLon;
        double y = cosLat;
        double z = sinLat * cosLon;

        return new Vec4(x, y, z).normalize3();
    }

enter image description here

...