Earth display in equatorial coordinate system in JavaFX 3D (1)

Earth display in equatorial coordinate system in JavaFX 3D (1)

This article is the 11th day of JavaFX Advent Calendar 2017. The 10th day is HASUNUMA Kenji's About the current state of JavaFX-Maven-Plugin.

Introduction

From this summer, I started to make a program to display the orbits of the earth and artificial satellites in 3D using the 3D function of JavaFX. If completed, today's Advent Calendar will start by presenting a screen showing many orbits around the earth, but unfortunately it is not completed. Today, in order to display the satellite orbit, the equatorial coordinate system mainly used in the satellite orbit (right-handed Cartesian coordinate system with the center of the earth as the origin, the rotation axis of the earth as the Z axis, and the equatorial plane as the XY plane) Introducing how to define and display the earth.

Hello world of 3D graphics

The sample program of displaying the earth by 3D programming, that is, pasting a world map on a sphere with a texture map and displaying it as the earth, is often used as a Hello world program in the 3D graphics world. The following is an example of a 3D earth display created with JavaFX. image.png

Previously Understanding JavaFX 3D on how to program to display the Earth with JavaFX 3D capabilities. % E3% 82% 92% E7% 90% 86% E8% A7% A3% E3% 81% 99% E3% 82% 8B) I wrote the article.

At this time, the JavaFX 3D coordinate system is such that the Z axis is the depth direction of the screen, the X axis is the right direction of the screen, and the Y axis is the bottom direction of the screen. The JavaFX 3D display is the world seen from a camera (perspective camera) placed in this coordinate system. The default perspective camera is at the origin and the camera is oriented positively on the Z axis. The following figure shows the position and orientation of this coordinate system and camera.

image.png

Equatorial coordinate system

The orbit of the artificial satellite is represented by a coordinate system with the center of the earth as the origin, the rotation axis of the earth as the Z axis (positive in the north pole direction), the X axis in the direction of the vernal equinox, and the X and Y axes on the equatorial plane. I will. image.png

This is the same right-handed Cartesian coordinate system as the Hello world Earth display, but in a different orientation.

I want to display the model defined in the equatorial coordinate system in the same orientation

I sought a way to display the model (Earth) so that the North Pole of the Earth is at the top of the screen.

If you change the coordinate axes with Affine transformation, the texture will be ...

3D graphics control the position and orientation of the camera to freely change the display, but if you are not familiar with 3D, you tend to try to display the model and axes by affine transformation instead of controlling the camera. This summer, I wrote the following about the texture map (left and right flipped, top and bottom flipped, etc.) when the orientation of the coordinate axes was changed by Affine transformation. JavaFX 3D Texture Mapping and Affine Transformation

In JavaFX 3D, if you specify to change the orientation of the coordinate axes by Affine transformation, the texture map will also be affected.

Camera position and orientation

By changing the position and orientation of the camera, I would like to make the Z axis up and down in the screen display. I wrote about this next. About JavaFX 3D coordinate system and camera orientation

To summarize the above blog in one word, by rotating the camera orientation 90 degrees along the X axis, the Z axis will be displayed vertically on the screen.

Display the Earth in the equatorial coordinate system

image.png

This screen is a JavaFX program that controls the position and orientation of the camera so that the Z axis is in the vertical direction of the screen to display the earth.

With the center of the earth as the origin, the X-axis, Y-axis, and Z-axis are shown with red, green, and blue cylinders and spheres at the positive end points, respectively. In addition, the XY plane, YZ plane, and ZX plane are displayed in wireframe. (It's a little confusing)

The control panel on the right has controls that control the position and orientation of the camera.

This program is currently under active development at the following repositories: https://github.com/torutk/javafx-satorbit

The following is an excerpt of the code that controls the direction of the camera.

SatelliteOrbits3dView.java (excerpt)


    private final Rotate azimuthRotate = new Rotate(0, Rotate.Y_AXIS); //Camera longitude (around the equator) rotation
    private final Rotate elevationRotate = new Rotate(0, Rotate.X_AXIS); //Camera latitude (around the meridian) rotation
    private final Translate distanceTranslate = new Translate(0, 0, CAMERA_DISTANCE); //Camera distance
 
    //Coordinate conversion sequence that determines the position and orientation of the camera
    private final Transform[] cameraTransforms = new Transform[] {
        new Rotate(-90, Rotate.X_AXIS), //Rotate the camera so that the Z-axis positive direction is on the screen
        azimuthRotate,
        elevationRotate,
        distanceTranslate
    };

    void rotationCamera() {
        subScene.setCamera(createCamera(cameraTransforms));
    }
    //Create a camera.
    private PerspectiveCamera createCamera(Transform... args) {
        PerspectiveCamera camera = new PerspectiveCamera(true);
        camera.setFieldOfView(45.0);
        camera.setFarClip(400);
        camera.getTransforms().addAll(args);
        return camera;
    }

Here, we have a camera that always faces the origin. The position and direction of the camera are defined by Transform []. Each time you control the camera (change the position or direction), create a camera and set it in the scene.

I would like to give a detailed explanation next time.

Recommended Posts

Earth display in equatorial coordinate system in JavaFX 3D (1)
Display a loading image in JavaFX and then display another image