Method and device for realizing click target under J2000 coordinate system based on osgEarth and medium
By using the OSG point sprites method and the occlusion detection and coordinate conversion algorithm under the J2000 coordinate system in the osgEarth simulation scenario, the problems of inaccurate target recognition and waste of computing resources in the osgEarth simulation scenario are solved, and efficient and reliable target recognition and information interaction are achieved.
Patent Information
- Application Number
- CN202510402472.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2045-04-01
AI Technical Summary
In the osgEarth simulation scenario, when there are many spatial targets, it is difficult to accurately identify specific targets through intuitive interaction, and the problems of earth occlusion and coordinate conversion cannot be effectively solved, resulting in reduced discrimination between targets and waste of computing resources.
The OSG point elves method is used to add target points under the J2000 coordinate system, and combined with occlusion detection and coordinate conversion algorithms, the target is judged by mouse click selection, and high-reliability target recognition and information interaction, including occlusion judgment, coordinate conversion and pixel distance threshold judgment.
It realizes efficient target recognition and information interaction, reduces the occlusion error rate, reduces computing resource consumption, supports real-time interaction of large-scale targets, and meets the high-precision needs of space missions.
Smart Images

Figure CN120408947A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of space target simulation based on osgEarth in the aerospace field, and particularly to a method, device and medium for realizing point selection of a target in the J2000 coordinate system based on osgEarth. Background Art
[0002] In the field of computer simulation technology, especially in scenarios such as spacecraft orbit visualization and large-scale space target monitoring, the system usually needs to display thousands of space target entities simultaneously. To ensure the scene rendering efficiency, the prior art generally adopts simplified drawing methods such as Point Sprite, and abstracts complex three-dimensional models into pixel points in the two-dimensional screen space for display, as Figure 2 shown. However, while this optimization method improves the rendering performance, it significantly reduces the distinguishability between target entities, and the operator cannot accurately identify a specific target and obtain its attribute information through intuitive interaction (such as mouse point selection).
[0003] Traditional point selection determination methods mostly construct a collision detection mechanism based on the two-dimensional plane coordinate system, and have the following technical limitations: (1) In the osgEarth simulation scene, when the number of targets in the scene is large, in order to improve the display efficiency, points are used to represent each target in the scene. When the target point is selected by the mouse, it is impossible to distinguish the target attributes represented by each target point. (2) The influence of the earth curvature on the visibility of space targets is not considered. When there is an earth occlusion between the ground observation point and the target, a point selection response may still be wrongly triggered. (3) When performing coordinate transformation using the earth-fixed coordinate system, it is difficult to adapt to the dynamic characteristics of the J2000 inertial coordinate system of space targets, resulting in cumulative errors in projection calculation. (4) There is a lack of an efficient occlusion culling strategy during large-scale target traversal detection, causing unnecessary consumption of computing resources. In addition, existing space visualization solutions based on the osgEarth engine mostly focus on the rendering of surface elements, and have not effectively solved the problem of high-precision conversion between the J2000 coordinate system and the screen coordinate system in the deep space environment.
[0004] Therefore, there is an urgent need to develop a space target point selection determination method applicable to the osgEarth platform and compatible with the J2000 coordinate system. While ensuring the scene rendering efficiency, through an accurate earth occlusion judgment and coordinate transformation mechanism, a high-reliability target recognition and information interaction function can be realized, and it can be determined which target is currently selected through point selection, distinguish the targets, and display the information of the targets themselves. Summary of the Invention
[0005] In view of the above problems, the purpose of the present invention is to provide a method, device and medium for realizing point selection of targets in the J2000 coordinate system based on osgEarth, which can realize high-reliability target recognition and information interaction functions and improve the display efficiency when there are a large number of targets in the osgEarth simulation scene.
[0006] An embodiment of the present invention provides a method, device and medium for realizing point selection of targets in the J2000 coordinate system based on osgEarth.
[0007] First aspect: A method for realizing point selection of targets in the J2000 coordinate system based on osgEarth, including the steps of:
[0008] S1. Add target points to the simulation scene;
[0009] S2. Traverse the position information of all target points, and judge whether the simulated earth is blocked by the viewpoint position and whether the target points are blocked by the simulated earth;
[0010] S3. Convert the J2000 position coordinates of the unblocked target points to the screen coordinate system;
[0011] S4. Compare the position of the target point in the screen coordinate system with the position of the mouse click, judge whether the current target point is selected by the mouse, and display the information of the target point selected by the mouse.
[0012] Further, when adding target points in S1, the size, color and texture of the target points are set by using the OSG Point Sprite method.
[0013] Further, when judging whether the target points are blocked by the earth in S2, judge whether the simulated earth is blocked by the viewpoint position, and the formula is expressed as:
[0014] cv = camPos / EarthRadiu
[0015] Where cv is the unit viewpoint position vector normalized to the earth radius, camPos is the current viewpoint position, and EarthRadiu is the radius of the simulated earth;
[0016] When cv.length() < 1, the current viewpoint position is less than the earth radius, and the simulated earth is blocked;
[0017] When cv.length() ≥ 1, the current viewpoint position is greater than or equal to the earth radius, and the simulated earth is not blocked.
[0018] Further, when judging whether the target points are blocked by the earth in S2, judge whether the target points are blocked by the simulated earth, and the formula is expressed as:
[0019] t = Pos / EarthRadius;
[0020] vt = t - cv;
[0021] vhSquared = cv.x() * cv.x() + cv.y() * cv.y() + cv.z() * cv.z() - 1.0;
[0022] vtSquared = vt.x() * vt.x() + vt.y() * vt.y() + vt.z() * vt.z();
[0023] vtDotVc = -(vt.x() * cv.x() + vt.y() * cv.y() + vt.z() * cv.z());
[0024] Wherein, cv is the unit view point position vector of the current view point normalized to the Earth radius; t is the unit target point position vector of the target normalized to the Earth radius; vt is the vector pointing from the view point position to the target position, vhSquared represents the distance from the current view point to the ground, vtSquared represents the distance in the direction from the view point to the target; vtDotVc is the dot product of vt and cv. Calculate the projections of vtDotVc on vt and cv respectively. If vtDotVc is greater than vhSquared and vtDotVc * vtDotVc / vtSquared > vhSquared, then the current point is not blocked by the simulated Earth.
[0025] Further, in S3, convert the J2000 position coordinates of the unblocked target point to the screen coordinate system; including the steps:
[0026] S31. Transform the J2000 position coordinates of the current target point using the camera view matrix and the camera projection matrix. The formula is expressed as:
[0027] outpos = outpos * viewMatrix;
[0028] outpos = outpos * projMatrix;
[0029] Wherein, outpos is the target point position. For the convenience of calculation, add a component w to the target point and convert it to "homogeneous coordinates", outpos = vec4d outpos(Pos.x(), Pos.y(), Pos.z(), 1), 1 is the initial value of outpos.w, viewMatrix is the camera view matrix, and viewMatrix is the camera projection matrix; after the matrix transformation, the clip coordinates are obtained.
[0030] S32. Then, calculate the normalized device coordinates (NDC) through perspective division. The x and y values of the NDC coordinates are within the range of -1.0 to 1.0, and the z-axis ranges from 0 to 1;
[0031] The formula is expressed as:
[0032] outpot.x() = outpos.x() / outpos.w();
[0033] outpot.y() = outpos.y() / outpos.w();
[0034] outpot.z() = outpos.z() / outpos.w();
[0035] Among them, when outpos.w < 0, it means that the current target point is on the back side of the earth, and outpot.x(), outpot.y() and outpot.z() are the coordinates of the target point in the NDC coordinate system;
[0036] S33. Convert the NDC coordinate system coordinates to screen coordinate system coordinates. The formula is expressed as:
[0037] outpos.x = outpos.x() * 0.5 + 0.5;
[0038] outpos.y = outpos.y() * 0.5 + 0.5;
[0039] outpos.z = outpos.z() * 0.5 + 0.5;
[0040] Among them, outpos.x, outpos.y and outpos.z are values within the range of 0 to 1;
[0041] S34. Calculate the position of the target point in the screen coordinates using the calculated values from 0 to 1. The formula is expressed as:
[0042] screenPos.x() = outpos.x * nScreenW;
[0043] screenPos.y() = outpos.y * nScreenH;
[0044] Among them, nScreenW and nScreenH are the width and height of the target point in the screen coordinate system.
[0045] Further, in step S4, comparing the position of the target point in the screen coordinate system with the position of the mouse click to determine whether the current target point is selected by the mouse includes:
[0046] S41. Obtain the screen position coordinates mousePos of the mouse click;
[0047] S42. Calculate the position distance between the screen position of the mouse click and the target point in the screen coordinate position. The formula is expressed as:
[0048] disrr = pow(mousePos.x() - screenPos.x(), 2) + pow(mousePos.y() - screenPos.y(), 2);
[0049] distance = sqrt(disrr);
[0050] Among them, mousePos.x() is the x point of the screen coordinates of the mouse click, and mousePos.y() is the y point of the screen coordinates of the mouse click;
[0051] S43. Set the pixel value pixelSize occupied by the target point. Compare the difference between the pixel value pixelSize and the position distance. If the difference between the two points is less than pixelSize / 2.0, the mouse click position selects the target point.
[0052] Second aspect: An electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements the steps of the method provided in the first aspect.
[0053] Third aspect: A non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the method provided in the first aspect.
[0054] Advantages of the present invention:
[0055] 1. The present invention adopts the OSG Point Sprite method to achieve the point display of a large number of spatial target points. By judging which target point is currently selected through mouse clicks, distinguishing target points, and displaying the information of the target points themselves, it realizes the high-reliability target point recognition and information interaction function, and improves the display efficiency.
[0056] 2. The present invention realizes the occlusion detection accuracy through vector normalization calculation and double geometric condition judgment (vtDotVc > vhSquared and secondary projection verification), completely avoiding the misselection problem caused by the earth's curvature. Compared with the traditional two-dimensional plane detection method, the occlusion misjudgment rate is reduced. Through accurate earth occlusion judgment and coordinate conversion mechanism, it realizes the high-reliability target recognition and information interaction function.
[0057] 3. The present invention directly performs spatial projection calculations using the J2000 inertial coordinate system, eliminating the dynamic errors caused by the Earth's rotation in the Earth-fixed coordinate system. The cumulative error of the conversion of the projection coordinates of the ten-thousand-level target is small, meeting the accuracy requirements of the aerospace level, and enabling efficient conversion of the dynamic coordinate system.
[0058] 4. The present invention integrates point sprite rendering and GPU-accelerated matrix operations, reducing the time consumption of coordinate conversion to within 5 ms. Combining the two-level occlusion culling strategy (viewpoint position screening + target point occlusion detection), the consumption of computing resources is reduced, supporting real-time point selection responses for 100,000-level targets, and enabling real-time interaction for large-scale targets.
[0059] 5. The present invention can ensure the consistency of point selection accuracy at different resolutions through screen coordinate mapping with dynamic calibration of the viewport size. The point selection error is stably lower than 0.1 pixel, and it can adaptively optimize the screen projection.
[0060] 6. The present invention uses a pixel distance threshold determination to expand the fault tolerance radius of the point selection operation. Combining with 7px point pixel optimization, the success rate of user operations is improved, the response delay is reduced, and the interaction efficiency is significantly enhanced.
[0061] 7. Through deep integration with the osgEarth engine, the present invention supports multi-scale simulations from low Earth orbit (LEO) to deep space exploration, meeting the high-precision interaction requirements such as spacecraft rendezvous and docking. It effectively solves the inherent contradiction of "rendering efficiency - operation accuracy" in the visualization of large-scale space targets, providing a reliable real-time interaction solution for fields such as space mission simulation and space situation awareness. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 It is a schematic flow chart of a method for implementing point selection of a target based on osgEarth in the J2000 coordinate system according to the present invention;
[0063] Figure 2 It is a schematic diagram after adding target points in the osgEarth simulation scene according to the present invention;
[0064] Figure 3 It is a schematic diagram after the mouse clicks on a target point in the osgEarth simulation scene according to the present invention;
[0065] Figure 4 It is a schematic diagram of the device (NDC) coordinate system according to the present invention;
[0066] Figure 5 It is a schematic diagram of the screen coordinate system according to the present invention;
[0067] Figure 6 It is a schematic diagram of the structure of the electronic device according to the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0068] Embodiments of the present invention will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where the same or similar reference signs denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the drawings are exemplary and are only used to explain the present invention and should not be construed as a limitation of the present invention.
[0069] In implementing certain simulation scenarios in the aerospace field, when the number of targets in the scenario is large, in order to improve the display efficiency, points are used to represent each target in the scenario, which results in the inability to distinguish which target each point represents.
[0070] In view of the above problems, the present invention provides a method for realizing point selection of targets (comprehensive situation points) based on osgEarth in the J2000 coordinate system. Figure 1 The following is a schematic flowchart of the method for realizing point selection of targets based on osgEarth in the J2000 coordinate system provided by the embodiments of the present invention. The method includes:
[0071] S1. Add target points to the simulation scenario.
[0072] As Figure 2 shown, osgEarth is an open-source geospatial SDK and terrain engine that can provide support for (OpenSceneGraph OSG) applications; first, add multiple target points to the simulation scenario through the OSG Point Sprite method, and set the size, color, and texture of the target points.
[0073] The OSG Point Sprite method is an open-source 3D graphics library that supports various graphics rendering functions. In OSG, Point Sprite is a graphics technology for rendering point-like objects. Point Sprite can apply texture mapping so that each point can have a different appearance, such as size, color, and texture. In the application of space simulation engineering, Point Sprite can be used to visualize a large number of data points, such as space targets like satellites.
[0074] Through the OSG Point Sprite method, a large number of space targets can be converted into target points for representation.
[0075] S2. Traverse the position information of all target points, and determine whether the simulated earth is blocked by the viewpoint position and whether the target points are blocked by the simulated earth.
[0076] Loop through the added target point J2000 position information, marked as Pos, obtain the current view point position camPos through osgViewer, the radius of the earth is EarthRadiu, calculate whether the current view point is less than the radius of the earth through the current view point position camPos and the radius of the earth EarthRadiu, and the formula is expressed as:
[0077] cv = camPos / EarthRadiu
[0078] Among them, cv is the normalized ratio of the view point position to the radius of the earth, camPos is the current view point position, and EarthRadiu is the radius of the simulated earth;
[0079] When cv.length() < 1, the current view point position is less than the radius of the earth, the view point is inside the earth, the earth is not visible, and the simulated earth is blocked;
[0080] When cv.length() ≥ 1, the current view point position is greater than or equal to the radius of the earth, and the simulated earth is not blocked.
[0081] Then, judge whether the target is blocked by the earth through the current view point position and the target position, and the formula is expressed as:
[0082] vhSquared = cv.x() * cv.x() + cv.y() * cv.y() + cv.z() * cv.z() - 1.0;
[0083] t = Pos / EarthRadius;
[0084] vt = t - cv;
[0085] vtSquared = vt.x() * vt.x() + vt.y() * vt.y() + vt.z() * vt.z();
[0086] vtDotVc = -(vt.x() * cv.x() + vt.y() * cv.y() + vt.z() * cv.z());
[0087] Wherein, vtDotVc and vhSquared are defined variables, cv is the unit view point position vector with the current view point normalized to the Earth's radius; t is the unit target point position vector with the target normalized to the Earth's radius; vt is the vector pointing from the view point position to the target position, vhSquared represents the distance from the current view point to the ground, and vtSquared represents the distance in the direction from the view point to the target; vtDotVc is the dot product of vt and cv. The projections of vtDotVc on vt and cv are calculated respectively. If vtDotVc is greater than vhSquared and vtDotVc * vtDotVc / vtSquared > vhSquared, then the current point is not blocked by the simulated Earth.
[0088] S2. Convert the J2000 position coordinates of the unblocked target points to the screen coordinate system.
[0089] Convert the target J2000 position to the screen coordinates. Through the osg camera transformation matrix, convert the current J2000 point position to the screen coordinates, including:
[0090] Obtain the camera view matrix:
[0091] viewMatrix = cam->getViewmatrix();
[0092] Obtain the camera projection matrix:
[0093] projMatrix = cam->getProjectionMatrix();
[0094] outpos is the current target point position. For the convenience of calculation, add a component w to the target point to convert it to "homogeneous coordinates". The current target point position is vec4d outpos(Pos.x(), Pos.y(), Pos.z(), 1), where 1 is the initial value of outpos.w. Then, perform the conversion through the camera view matrix and the camera projection matrix. viewMatrix is the camera view matrix, and viewMatrix is the camera projection matrix. After the matrix transformation, the clip coordinates are obtained;
[0095] outpos = outpos * viewMatrix;
[0096] outpos = outpos * projMatrix;
[0097] After conversion, the normalized device coordinates (NDC) are obtained through perspective division. The x and y values of the NDC coordinates are in the range of -1.0 to 1.0, and the z-axis ranges from 0 to 1. If outpos.w < 0 is calculated, it means the current point is on the back side of the earth and is removed. For the target points where outpos.w ≥ 0;
[0098] Perform the conversion to obtain:
[0099] outpot.x() = outpos.x() / outpos.w();
[0100] outpot.y() = outpos.y() / outpos.w();
[0101] outpot.z() = outpos.z() / outpos.w();
[0102] The device coordinate system (x-axis to the right, y-axis up, z far point at the center of the plane) is as Figure 4 shown. Through the conversion between the device coordinate system and the screen coordinate system, as Figure 5 shown, the formula is expressed as:
[0103] outpos.x = outpos.x() * 0.5 + 0.5;
[0104] outpos.y = outpos.y() * 0.5 + 0.5;
[0105] outpos.z = outpos.z() * 0.5 + 0.5;
[0106] Calculate the width and height of the current viewport in the screen coordinate system:
[0107] nScreenW = cam->getViewport()->width();
[0108] nScreenH = cam->getViewport()->height();
[0109] Calculate the position of the current point in the screen coordinates:
[0110] screenPos.x() = outpos.x * nScreenW;
[0111] screenPos.y() = outpos.y * nScreenH;
[0112] screenPos.x() and screenPos.y() are the positions of the target point in the screen coordinate system.
[0113] S4. Compare the position of the target point in the screen coordinate system with the position selected by the mouse, determine whether the current target point is selected by the mouse, and display the information of the target point selected by the mouse.
[0114] By comparing the screen position mousePos selected by the mouse and the screen position of the converted J2000 point, determine whether the current target point is selected, set the pixel value pixelSize occupied by the target point, for example, pixelSize = 7.0, and calculate:
[0115] disrr = pow(mousePos.x() - screenPos.x(), 2) + pow(mousePos.y() - screenPos.y(), 2);
[0116] distance = sqrt(disrr);
[0117] Among them, mousePos.x() and mousePos.y() are the positions of the mouse selection position in the screen coordinate system.
[0118] If the distance between the two points is less than pixelSize / 2.0, the current selection position selects the target point.
[0119] Application example:
[0120] In the satellite simulation monitoring system, 10,000 space targets (J2000 coordinates) are loaded. When the user clicks on the screen:
[0121] The system quickly traverses all targets and eliminates the target points blocked by the earth (about 30%).
[0122] The remaining target points calculate the screen coordinates through matrix transformation, and the time consumption is <5ms.
[0123] Judge the selected target according to the pixel threshold (7px), and the error rate is <0.1%.
[0124] Implementation effect:
[0125] Accurately display the information of the point selected by the mouse, the click display response time is <10ms, meeting the real-time requirements of space missions;
[0126] The occlusion calculation accuracy is improved to 99.9%, avoiding misselection.
[0127] The coordinate conversion efficiency is increased by 50%, supporting real-time interaction of tens of thousands of targets.
[0128] The present invention also provides an electronic device. Figure 6 It is a schematic structural diagram of the electronic device provided by the embodiment of the present invention, as Figure 6As shown, the electronic device may include: a processor, a communications interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus. The processor may call logic instructions in the memory to execute the following method, for example:
[0129] S1. Add a target point in the simulation scenario;
[0130] S2. Traverse the position information of all target points, and determine whether the simulated earth is blocked by the viewpoint position and whether the target point is blocked by the simulated earth;
[0131] S3. Convert the J2000 position coordinates of the unblocked target points to the screen coordinate system;
[0132] S4. Compare the position of the target point in the screen coordinate system with the position selected by the mouse, determine whether the current target point is selected by the mouse, and display the information of the target point selected by the mouse.
[0133] In addition, when the logic instructions in the above-mentioned memory are implemented in the form of software functional units and sold or used as an independent product, they may be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, may be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.
[0134] The embodiments of the present invention further provide a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is used to execute the methods provided in the above-mentioned various embodiments, for example, including:
[0135] [[ID=2l]]S1. Add a target point in the simulation scenario;
[0136] S2. Traverse the position information of all target points, and determine whether the simulated earth is blocked by the viewpoint position and whether the target point is blocked by the simulated earth;
[0137] S3. Convert the J2000 position coordinates of the unblocked target points to the screen coordinate system;
[0138] S4. Compare the position of the target point in the screen coordinate system with the position selected by the mouse to determine whether the current target point is selected by the mouse, and display the information of the target point selected by the mouse.
[0139] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative work.
[0140] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0141] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or perform equivalent replacements for some of the technical features. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for implementing point - selected target in the J2000 coordinate system based on osgEarth, characterized in that, Including the steps: S1. Add target points in the simulation scenario; S2. Traverse the position information of all target points, and judge whether the simulated earth is blocked by the viewpoint position and whether the target points are blocked by the simulated earth; S3. Convert the J2000 position coordinates of the unblocked target points to the screen coordinate system; S4. Compare the position of the target point in the screen coordinate system with the position selected by the mouse, judge whether the current target point is selected by the mouse, and display the information of the target point selected by the mouse.
2. A method for implementing point selection of a target in the J2000 coordinate system based on osgEarth according to claim 1, characterized in that When adding target points in S1, use the OSG Point Sprite method to set the size, color, and texture of the target points.
3. A method for implementing point selection of a target in the J2000 coordinate system based on osgEarth according to claim 1, characterized in that, When judging whether the target points are blocked by the earth in S2, judge whether the simulated earth is blocked by the viewpoint position, and the formula is expressed as: cv = camPos / EarthRadiu where cv is the unit viewpoint position vector normalized to the earth radius, camPos is the current viewpoint position, and EarthRadiu is the radius of the simulated earth; When cv.length() < 1, the current viewpoint position is less than the earth radius, and the simulated earth is blocked; When cv.length() ≥ 1, the current viewpoint position is greater than or equal to the earth radius, and the simulated earth is not blocked.
4. A method for implementing point selection of a target in the J2000 coordinate system based on osgEarth according to claim 1, characterized in that, When judging whether the target points are blocked by the earth in S2, judge whether the target points are blocked by the simulated earth, and the formula is expressed as: t = Pos / EarthRadius; vt = t - cv; vhSquared = cv.x() * cv.x() + cv.y() * cv.y() + cv.z() * cv.z() - 1.0; vtSquared = vt.x() * vt.x() + vt.y() * vt.y() + vt.z() * vt.z(); vtDotVc = -(vt.x() * cv.x() + vt.y() * cv.y() + vt.z() * cv.z()); where cv is the unit viewpoint position vector of the current viewpoint normalized to the earth radius; t is the unit target point position vector of the target normalized to the earth radius; vt is the vector pointing from the viewpoint position to the target position, vhSquared represents the distance from the current viewpoint to the ground, vtSquared represents the distance in the direction from the viewpoint to the target; vtDotVc is the dot product of vt and cv. Calculate the projections of vtDotVc on vt and cv respectively. If vtDotVc is greater than vhSquared and vtDotVc * vtDotVc / vtSquared > vhSquared, then the current point is not blocked by the simulated earth.
5. A method for implementing point selection of a target in the J2000 coordinate system based on osgEarth according to claim 1, characterized in that, In S3, convert the J2000 position coordinates of the unblocked target points to the screen coordinate system; Including the steps: S31. Transform the J2000 position coordinates of the current target point using the camera view matrix and the camera projection matrix, and the formula is expressed as: outpos = outpos * viewMatrix; outpos = outpos * projMatrix; Among them, outpos is the position of the target point. For the convenience of calculation, a component w is added to the target point and converted into "homogeneous coordinates", outpos = vec4d outpos(Pos.x(), Pos.y(), Pos.z(), 1), where 1 is the initial value of outpos.w, viewMatrix is the camera view matrix, and viewMatrix is the camera projection matrix; after matrix transformation, the clip coordinates are obtained; S32. Then, the normalized device coordinates (NDC) are calculated through perspective division. The x and y values of the NDC coordinates are in the space from -1.0 to 1.0, and on the z-axis, it is from 0 to 1; The formula is expressed as: outpot.x() = outpos.x() / outpos.w(); outpot.y() = outpos.y() / outpos.w(); outpot.z() = outpos.z() / outpos.w(); Among them, when outpos.w < 0, it means that the current target point is on the back of the earth; S33. Convert the coordinates of the NDC coordinate system to the coordinates of the screen coordinate system. The formula is expressed as: outpos.x = outpos.x() * 0.5 + 0.5; outpos.y = outpos.y() * 0.5 + 0.5; outpos.z = outpos.z() * 0.5 + 0.5; Among them, outpos.x, outpos.y, and outpos.z are values within the range from 0 to 1; S34. Calculate the position of the target point in the screen coordinates using the calculated values from 0 to 1. The formula is expressed as: screenPos.x() = outpos.x * nScreenW; screenPos.y() = outpos.y * nScreenH; Among them, nScreenW and nScreenH are the width and height of the target point in the screen coordinate system.
6. A method for implementing point selection of a target in the J2000 coordinate system based on osgEarth according to claim 1, characterized in that, In step S4, the position of the target point in the screen coordinate system is compared with the position of the mouse click to determine whether the current target point is selected by the mouse, including: S41. Obtain the screen position coordinates mousePos of the mouse click; S42. Calculate the position distance between the screen position of the mouse click and the position of the target point in the screen coordinates. The formula is expressed as: disrr = pow(mousePos.x() - screenPos.x(), 2) + pow(mousePos.y() - screenPos.y(), 2); distance = sqrt(disrr); Among them, mousePos.x() is the x point of the screen coordinates of the mouse click, and mousePos.y() is the y point of the screen coordinates of the mouse click; S43. Set the pixel value pixelSize occupied by the target point, compare the difference between the pixel value pixelSize and the position distance. If the difference between the two points is less than pixelSize / 2.0, the mouse click position selects the target point.
7. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method for implementing point selection of a target based on osgEarth in the J2000 coordinate system as described in any one of claims 1 to 6.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method for implementing point selection of a target based on osgEarth in the J2000 coordinate system as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Construction method for 3D dynamic visual simulation platform for multimode navigation
CN106845032A
Giant constellation ground coverage capability analysis simulation system and method based on cellular grid
CN117527034A
Precise following interaction method and device based on Unreal Engine platform and storage medium
CN118885102A
Method, system and equipment for simulating radiation characteristics of rotary scanning carbon monitoring satellite
CN119004818A
State display
JP2010145239A