A cache-based ray tracing method, device and system
By pre-caching the surface element information in the ray tracing method and using rejection detection to eliminate non-intersecting surface elements, the problem of low computational efficiency in ray tracing is solved, achieving faster ray tracing speed and higher computational efficiency.
Patent Information
- Application Number
- CN202310193961.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-28
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2043-02-28
AI Technical Summary
Existing ray tracing methods still have room for improvement in computational efficiency and tracing speed, especially in cases involving large scenes, multiple targets, and high precision, where the computational load increases significantly, affecting computational efficiency.
A cache-based ray tracing method is adopted. By pre-calculating and caching the range of elevation and azimuth angles of the target's triangular surface model and the observation point, and combining two-level or three-level rejection detection, surface elements that cannot intersect are eliminated, reducing the number of line-surface intersection calculations and improving computational efficiency.
Without compromising accuracy, it significantly improves the speed and efficiency of ray tracing, reduces the number of line-surface intersection calculations, and increases computation speed.
Smart Images

Figure CN116109677B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of ray tracing, and more particularly, relates to a cache-based ray tracing method, device and system. BACKGROUND
[0002] Ray tracing is a technique widely used in the fields of mobile communication channel simulation, radar and millimeter wave radiation image simulation, and seismic simulation and inversion. Ray tracing is based on the principle of geometric optics. Electromagnetic waves in the microwave and millimeter wave bands can be approximately regarded as plane waves, and have similar characteristics to light. The scattering and propagation of electromagnetic waves can be handled using the principle of geometric optics.
[0003] In the ray tracing technique, the target model is usually divided into triangular face elements by using a grid division technique. By continuously calculating the intersection points of rays and target triangular face elements, the entire propagation trajectory of the rays is obtained. With the continuous deepening of research, large scenes, multiple targets, high precision and real-time performance have become the main requirements. The increase in the number of rays and triangular face elements greatly increases the amount of line-face intersection calculation, which greatly limits the calculation efficiency of ray tracing.
[0004] In order to improve the calculation efficiency of ray tracing, a millimeter wave radiation brightness temperature acquisition method based on fast ray tracing is disclosed in the patent document with the application publication number “CN105953925A”. In this method, in order to realize ray tracing, a first level of rejection detection is used, that is, before line-face intersection is performed, face elements that do not meet the condition are removed according to the idea that face elements intersecting with a ray must intersect with two mutually non-parallel planes passing through the ray, thereby quickly locking the range of face elements and reducing the number of line-face intersection calculations, and improving the calculation speed of ray tracing. However, the effect of improving the calculation efficiency is limited.
[0005] A fast ray tracing method is disclosed in the patent document with the application publication number “CN107300645A”. Based on the above-mentioned first level of rejection detection, a first level of rejection detection and a first level of line-face intersection calculation are added. The basic idea of the added rejection detection is to construct a spherical surface that can contain triangular face elements. If the ray is outside the sphere, it is impossible to intersect with the triangular face elements. The basic idea of the added line-face intersection calculation is to project the triangular face elements into two dimensions, and skip the three-dimensional inverse matrix solution. Based on the added rejection detection, the efficiency of ray tracing is further improved. However, in the process of tracing each ray, a large amount of calculation is still generated in real time, and the calculation efficiency is still greatly affected.
[0006] Overall, the calculation efficiency and tracing speed of the existing ray tracing method still need to be further improved. SUMMARY
[0007] In view of the shortcomings and improvement needs of the existing technology, the present invention provides a ray tracing method, apparatus and system based on buffering, the purpose of which is to improve the speed of ray tracing without affecting accuracy.
[0008] To achieve the above objectives, according to one aspect of the present invention, a cache-based ray tracing method is provided, comprising:
[0009] First, obtain the triangular facet model of the target and the position of the observation point. Calculate and cache the elevation and azimuth ranges of the rays from the observation point to each facet of the target. Then, trace each ray according to the following steps:
[0010] (S1) Obtain the current ray's elevation angle δ and azimuth angle. Based on the cached information, remove face cells whose pitch angle range does not include pitch angle δ, and whose azimuth angle range does not include azimuth angle. If the number of remaining face elements is 0, the tracking of the current ray ends; otherwise, the current ray is taken as the target ray, the remaining face elements are taken as candidate face elements, and the process proceeds to step (S3).
[0011] (S2) Draw two non-parallel planes through the target ray, eliminate the candidate surface elements that do not intersect with the two planes at the same time, and take the remaining surface elements as new candidate surface elements.
[0012] (S3) Perform line-surface intersection calculation on the target ray and candidate surface elements. If an intersection point exists, proceed to step (S4); otherwise, end the tracking of the current ray.
[0013] (S4) After recording the intersection point, the reflected ray of the target ray is taken as the new target ray, all surface elements are taken as new candidate surface elements, and then the process proceeds to step (S2).
[0014] Furthermore, the cache-based ray tracing method provided by the present invention also includes:
[0015] The minimum incident angle of each facet of the target is pre-calculated and cached; the minimum incident angle is the minimum value of the ray incident angles from each vertex of the facet to the vertices of other facets.
[0016] Furthermore, step (S4) includes the following steps before proceeding to step (S2):
[0017] Obtain the reflection angle θ of the reflected ray, and read the minimum incident angle θ of the current intersecting surface element from the cached information. min If θ < θ min If the current ray is not tracked, then the tracking of the current ray will end.
[0018] Furthermore, in step (S2), before performing line-surface intersection calculations on the target ray and candidate surface elements, the following steps are also included:
[0019] Prune the face elements in the candidate face elements that are occluded relative to the target ray, and take the remaining face elements as new candidate face elements.
[0020] Further, the calculation of the range of the pitch angle and the range of the azimuth angle of the ray from the observation point to any face element ΔABC is as follows:
[0021] An original coordinate system is established with the observation point as the origin; the original coordinate system is rotated to obtain a target coordinate system; in the target coordinate system, the coordinates of the target center point are [D, 0, 0], and D is the observation distance;
[0022] In the target coordinate system, the extreme points of the pitch angle on each edge of the face element ΔABC are detected, and the detection method is as follows:
[0023] For any two vertices (x1, y1, z1) and (x2, y2, z2), calculate
[0024]
[0025] If 0 < t < 1, the extreme point is located on the edge, and its coordinates are [x1+t(x2-x1), y1+t(y2-y1), z1+t(z2-z1)]; otherwise, the extreme point is located at the vertex;
[0026] The pitch angle and the azimuth angle of each vertex and the extreme point of the face element ΔABC are calculated respectively, the maximum and minimum values of the pitch angles of each vertex and the extreme point are taken as the maximum and minimum values of the range of the pitch angle of the face element ΔABC, and the maximum and minimum values of the azimuth angles of each vertex of the face element are taken as the maximum and minimum values of the range of the azimuth angle of the face element ΔABC, to obtain the range of the pitch angle and the range of the azimuth angle of the ray from the observation point to the face element ΔABC.
[0027] Further, for any face element ΔABC, the calculation method of the minimum incident angle includes:
[0028] (T1) determining the normal vector of the face element ΔABC
[0029] (T2) selecting a vertex P of another face element, calculating the angles between the vectors and and respectively;
[0030] (T3) repeating step (T2) until all vertices of all face elements other than the face element ΔABC are calculated;
[0031] (T4) determining the minimum value of the calculated angles as the minimum incident angle of the face element ΔABC.
[0032] Furthermore, the methods for determining the intersection of a plane and a surface element include:
[0033] Calculate the signs of the distances from the three vertices of the face element to the plane. If both are positive or both are negative, then the plane and the face element do not intersect; otherwise, the plane and the face element intersect.
[0034] According to another aspect of the present invention, a cache-based ray tracing device is provided, comprising: a preprocessing module and a tracing module;
[0035] The preprocessing module is used to obtain the triangular facet model of the target and the position of the observation point, calculate the elevation angle range and azimuth angle range of the rays from the observation point to each triangular facet of the target, and cache them.
[0036] The tracking module includes: a first-level rejection detection unit, a second-level rejection detection unit, a line-surface intersection calculation unit, and an iterative control unit;
[0037] The first-level rejection detection unit is used to obtain the elevation angle δ and azimuth angle of the current ray. Based on the cached information, remove face cells whose pitch angle range does not include pitch angle δ, and whose azimuth angle range does not include azimuth angle. If the number of remaining face elements is 0, the tracking of the current ray ends; otherwise, the current ray is taken as the target ray, the remaining face elements are taken as candidate face elements, and the line-face intersection calculation unit is triggered.
[0038] The second-level rejection detection unit is used to draw two non-parallel planes through the target ray, eliminate the candidate surface elements that do not intersect with the two planes at the same time, and take the remaining surface elements as new candidate surface elements, and then trigger the line-surface intersection calculation unit.
[0039] The line-surface intersection calculation unit is used to perform line-surface intersection calculations on the target ray and candidate surface elements. If an intersection point exists, the iterative control unit is triggered; otherwise, the tracking of the current ray ends.
[0040] The iterative control unit records the intersection point, uses the reflected ray as the new target ray, treats all surface elements as new candidate surface elements, and triggers the second-level rejection detection unit.
[0041] Furthermore, the ray tracing device based on caching provided by the present invention, the preprocessing module, is also used to calculate and cache the minimum incident angle of each face element of the target; the minimum incident angle is the minimum value of the ray incident angle from each vertex of the face element to the vertices of other face elements.
[0042] Furthermore, the tracking module also includes a third-level rejection detection unit, used to obtain the reflection angle θ of the reflected ray and read the minimum incident angle θ of the current intersecting surface element from the cached information. min If θ < θmin If yes, then end the current ray tracing;
[0043] And, the iteration control unit will trigger the third level rejection detection unit before triggering the second level rejection detection unit.
[0044] According to still another aspect of the present application, there is provided a cache-based ray tracing system, comprising a computer readable storage medium and a processor;
[0045] The computer readable storage medium is configured to store a computer program;
[0046] The processor is configured to read the computer program stored in the computer readable storage medium and execute the cache-based ray tracing method provided by the present application.
[0047] Overall, the above technical solutions conceived by the present application can achieve the following beneficial effects:
[0048] (1) The cache-based ray tracing method provided by the present application comprises two levels of rejection detection, i.e. the first level rejection detection and the second level rejection detection. The first level rejection detection is used in the first layer of ray tracing to eliminate the face elements that obviously do not intersect with the ray according to the pre-cached pitch angle and azimuth angle range of the face elements. In the second level rejection detection, the face elements that do not meet the requirements are eliminated according to the idea that the face elements intersecting with the ray must intersect with two planes that are not parallel to the ray, so as to further accurately lock the range of face elements that need to be calculated for line-face intersection. The two levels of rejection detection cooperate with each other to effectively reduce the number of line-face intersection calculations. Moreover, in the first level rejection detection, the pitch angle range and the azimuth angle range of each face element are pre-calculated and cached, so that the relevant information does not need to be calculated in the process of real-time ray tracing. Therefore, the present application can effectively improve the efficiency and speed of ray tracing.
[0049] (2) In the preferred scheme of the cache-based ray tracing method provided by the present application, the third level rejection detection is further introduced on the basis of the two levels of rejection detection, which is used in the second layer of ray tracing and the subsequent tracing to as early as possible to determine the case that the ray no longer intersects with the face element according to the pre-cached minimum incident angle information, and to end the tracing in advance to avoid subsequent calculation. Moreover, in the third level rejection detection, the minimum incident angle of each face element is pre-calculated and cached, so that the relevant information does not need to be calculated in the process of real-time ray tracing. Therefore, the present application can further improve the efficiency of ray tracing.
[0050] (3) The extreme values of the pitch angle and the azimuth angle of the triangular facet do not necessarily appear at the three vertices of the facet. In the preferred scheme of the ray tracing method based on the cache provided by the present application, when calculating the range of the pitch angle and the range of the azimuth angle of the ray from the observation point to any one facet, the extreme points on each edge are calculated first, and then the range of the pitch angle and the range of the azimuth angle of the facet are determined based on the pitch angle and the azimuth angle of the extreme points and the vertices. Through this calculation method, the accuracy of the range of the pitch angle and the range of the azimuth angle of the facet can be improved.
[0051] (4) In the preferred scheme of the ray tracing method based on the cache provided by the present application, before the line-facet intersection is calculated, the occluded facets are also removed, so as to further accurately lock the range of the facets that need to be calculated for the line-facet intersection, reduce the number of line-facet intersection calculations, and further improve the efficiency of the ray tracing. BRIEF DESCRIPTION OF DRAWINGS
[0052] Figure 1 The ray tracing schematic diagram provided for the embodiment of the present application;
[0053] Figure 2 The flowchart of the ray tracing method based on the cache provided for an embodiment of the present application;
[0054] Figure 3 The schematic diagram for judging whether the facet includes a ray provided for the embodiment of the present application;
[0055] Figure 4 The flowchart of the ray tracing method based on the cache provided for another embodiment of the present application;
[0056] Figure 5 The schematic diagram of the minimum incident angle of the facet provided for the embodiment of the present application. DETAILED DESCRIPTION
[0057] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application. In addition, the technical features involved in the various embodiments of the present application described below can be combined with each other as long as they do not conflict with each other.
[0058] In the present application, the terms "first", "second", etc. (if any) in the present application and the accompanying drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence.
[0059] Before the technical solutions of the present application are explained in detail, the related technical principles and technical terms are briefly introduced as follows:
[0060] For example, Figure 1As shown, for a given target, after constructing its triangular facet model, an observation point is pre-determined. Rays emanating from the observation point may intersect with and reflect from the target's facets during propagation. The reflected rays then intersect with and reflect from other facets until the ray ceases to propagate along the target. During ray propagation, the first facet to intersect with the ray is designated as the first facet, the second as the third facet, and so on. Ray tracing involves continuously calculating the intersection points of the ray emanating from the observation point with the target's triangular facets during propagation, thereby obtaining the complete propagation trajectory of the ray.
[0061] To address the technical problem of low computational efficiency in existing ray tracing methods, this invention provides a cache-based ray tracing method, apparatus, and system. The overall approach involves analyzing the constant information during ray tracing, pre-calculating and caching this information, so that during subsequent rejection detection, the range of facets requiring line-to-face intersection calculations can be quickly located without further computation. This effectively improves the computational efficiency and speed of ray tracing without compromising accuracy. Furthermore, it identifies cases where the ray no longer intersects with facets as early as possible and terminates ray tracing prematurely, avoiding unnecessary computation and further improving ray tracing speed.
[0062] The following is an example.
[0063] Example 1:
[0064] A cache-based ray tracing method, such as Figure 2 As shown, it includes:
[0065] The target's triangular facet model and the location of the observation point are obtained in advance. The elevation and azimuth ranges of the rays from the observation point to each triangular facet of the target are calculated and cached.
[0066] After determining the observation point and target location, a three-dimensional coordinate system with the observation point as the origin can be constructed. Based on this three-dimensional coordinate system, the pitch and azimuth ranges corresponding to each triangular element can be calculated; Figure 3 For example, the observation point is point O, the direction from the observation point to the center of the target is the x-axis, the y-axis is perpendicular to the x-axis and parallel to the ground, and the z-axis can be determined from the x-axis and y-axis. Figure 3 The two triangular facets included, namely facet ΔA1B1C1 and facet ΔA2B2C2, allow for pre-calculation of the pitch angle (δ) at each vertex. A1 δ B1 δ C1 δ A2 δ B2 δ C2 ) and azimuth In this coordinate system, for any vertex with coordinates (x, y, z), its pitch angle δ0 and azimuth angle are... The calculation methods are as follows:
[0067] After calculating the pitch and azimuth angles of each vertex in the face element, the maximum pitch angles of face elements ΔA1B1C1 and ΔA2B2C2 can be determined as δ. max1 =max[δ A1 δ B1 δ C1 ]、δ max2 =max[δ A2 δ B2 δ C2 The minimum pitch angles are δ min1 =min[δ A1 δ B1 δ C1 ]、δ min2 =min[δ A2 δ B2 δ C2 The maximum azimuth angles are respectively The minimum azimuth angles are respectively
[0068] Based on the above calculations, the pitch angle range of surface element ΔA1B1C1 is [δ min1 δ max1 ], Azimuth range And the pitch angle range [δ] of surface element ΔA2B2C2 min2 δ max2 ], Azimuth range It will be cached.
[0069] The pitch and azimuth ranges of each element are determined by the position of the target and the observation point, and only need to be calculated once.
[0070] like Figure 2 As shown, based on the pre-calculated and cached information above, this embodiment traces each ray according to the following steps:
[0071] (S1) Obtain the current ray's elevation angle δ and azimuth angle. Based on the cached information, remove face cells whose pitch angle range does not include pitch angle δ, and whose azimuth angle range does not include azimuth angle. If the number of remaining face elements is 0, the tracking of the current ray ends; otherwise, the current ray is taken as the target ray, the remaining face elements are taken as candidate face elements, and the process proceeds to step (S3).
[0072] Still with Figure 3 For example, regarding the rays within them Obtain the pitch angle range [δ] of ΔA1B1C1 from the pre-cached information. min1 δ max1 ], Azimuth range And the pitch angle range [δ] of surface element ΔA2B2C2 min2 δ max2 ], Azimuth range ray Pitch angle δ and azimuth angle Compared with the obtained pitch and azimuth ranges respectively, surface element ΔA1B1C1 does not satisfy δ min1 ≤δ≤δ max1 and The removed element ΔA2B2C2 satisfies δ min2 ≤δ≤δ max2 and Reserved;
[0073] (S2) Draw two non-parallel planes through the target ray, eliminate the candidate surface elements that do not intersect with the two planes at the same time, and take the remaining surface elements as new candidate surface elements;
[0074] (S3) Perform line-surface intersection calculation on the target ray and candidate surface elements. If an intersection point exists, proceed to step (S4); otherwise, end the tracking of the current ray.
[0075] In this embodiment, the method for determining whether a plane intersects with a surface element is as follows: calculate the sign of the distance from the three vertices of the surface element to the plane. If both are positive or both are negative, then the plane and the surface element do not intersect; otherwise, if the signs are two positive and one negative or two negative and one positive, then the plane and the surface element intersect; (S4) after recording the intersection point, take the reflected ray of the target ray as the new target ray, take all surface elements as new candidate surface elements, and proceed to step (S2).
[0076] The cache-based ray tracing method provided by the embodiment comprises two-stage rejection detection, i.e., first-stage rejection detection and second-stage rejection detection; the first-stage rejection detection is used in the first layer of ray tracing, and the face element obviously not intersecting with the ray is eliminated according to the pre-cached pitch angle range and azimuth angle range of the face element; in the second-stage rejection detection, the face element not satisfying the condition is eliminated according to the idea that the face element intersecting with the ray must intersect with two planes not parallel to each other passing through the ray, so as to further accurately lock the range of the face element needing line-face intersection calculation; the two-stage rejection detection cooperates with each other, effectively reduces the number of line-face intersection calculation, and since the pitch angle range and the azimuth angle range of each face element are pre-calculated and cached in the first-stage rejection detection, the relevant information does not need to be calculated in the process of ray tracing, therefore, the efficiency of ray tracing can be effectively improved, and the speed of ray tracing can be improved.
[0077] In order to more accurately lock the range of the face element needing line-face intersection, the step (S2) of the embodiment further comprises the following before the line-face intersection calculation is performed on the target ray and the candidate face element:
[0078] The face element of the candidate face element being occluded relative to the target ray is eliminated, and the remaining face element is taken as a new candidate face element.
[0079] Optionally, the face element normal vector direction of the embodiment is directed from the inside of the target to the outside of the target, and whether the face element is occluded is judged by calculating the dot product of the observation vector (the vector corresponding to the target ray) and the face element normal vector; the dot product being positive indicates that the face element is occluded.
[0080] Embodiment 2:
[0081] A cache-based ray tracing method, as shown in Figure 4 The embodiment is similar to the above-mentioned embodiment 1, and the difference lies in that the embodiment further comprises: pre-calculating the minimum incident angle of each face element of the target and caching; the minimum incident angle is the minimum value of the incident angle of the ray from each vertex of the face element to the vertex of the other face element.
[0082] For any face element ΔABC, the calculation method of the minimum incident angle comprises:
[0083] (T1) determining the normal vector of the face element ΔABC
[0084] (T2) selecting a vertex P of the other face element, respectively calculating the angles of vectors and and ;
[0085] The angle between any two vectors can be calculated by the expression .
[0086] (T3) repeat step (T2) until all vertices of all facets except facet ΔABC are calculated;
[0087] (T4) determine the minimum value of the calculated included angles as the minimum incident angle of facet ΔABC.
[0088] Based on the above calculation steps, the minimum incident angle corresponding to each facet can be calculated, and these information will be cached for direct calling in the ray tracing process. The minimum incident angle of each target facet is determined by the geometric characteristics of the target itself, and only needs to be calculated once.
[0089] Based on the cached information, compared with the above embodiment 1, in step (S4) of the present embodiment, before turning to step (S2), further includes:
[0090] obtain the reflection angle θ of the reflected ray (i.e. the incident angle of the incident ray), and read the minimum incident angle θ of the current intersecting facet from the cached information min , if θ < θ min , it means that the reflected ray does not intersect with other facets, then end the current ray tracing; if θ ≥ θ min , it means that the reflected ray may intersect with other facets, which needs to be judged and calculated subsequently.
[0091] For example, assume that the target has four facets: ΔABC, ΔA1B1C1, ΔA2B2C2 and ΔA3B3C3, wherein the incident ray Figure 5 intersects with facet ΔABC, and the reflected ray of facet ΔABC is From the cached information, the minimum incident angle θ of facet ΔABC is called min , and compared with θ, since , θ < θ min , it means that the reflected ray does not intersect with other facets, and the tracing will be directly ended, and subsequent calculation will not be performed. Figure 5
[0092] In the present embodiment, the specific implementation of the remaining steps can refer to the description in the above embodiment 1, which will not be repeated here.
[0093] The present embodiment further introduces a third level of rejection detection on the basis of the above embodiment 1, which is used to determine as early as possible whether the ray no longer intersects with the facet according to the pre-cached minimum incident angle information in the second layer and subsequent tracing of the ray tracing, and ends the tracing in advance, avoiding subsequent calculation. At the same time, in the third level of rejection detection, the minimum incident angle of each facet is pre-calculated and cached, and the related information does not need to be calculated in the process of ray tracing, therefore, the efficiency of ray tracing can be further improved.
[0094] Embodiment 3
[0095] A cache-based ray tracing method, the embodiment is similar to the above-mentioned embodiment 1, the difference is that the calculation method of the elevation angle range and the azimuth angle range of the ray from the observation point to each face element of the target in the embodiment is different from that in the above-mentioned embodiment 1.
[0096] Considering that the extreme values of the elevation angle and the azimuth angle of the face element do not necessarily appear on the three vertices of the face element, directly using the elevation angle and the azimuth angle of the vertices of the face element to determine the elevation angle range and the azimuth angle range of the face element may have errors with the actual situation, therefore, in the embodiment, the extreme points are considered when calculating the elevation angle range and the azimuth angle range of the ray from the observation point to each face element of the target, accordingly, in the embodiment, the calculation method of the elevation angle range and the azimuth angle range of the ray from the observation point to any face element ΔABC is as follows:
[0097] Establishing a original coordinate system with the observation point as the origin; rotating the original coordinate system to obtain a target coordinate system; in the target coordinate system, the coordinate of the target center point is [D, 0, 0], and D is the observation distance; the coordinate in the target coordinate system is the coordinate in the original coordinate system multiplied by the rotation matrix R, and the expression is as follows:
[0098]
[0099] Wherein, α and β are the observation elevation angle and the observation azimuth angle;
[0100] In the target coordinate system, detecting the extreme points of the elevation angle on each edge of the face element ΔABC, and the detection method is as follows:
[0101] For any two vertices (x1, y1, z1) and (x2, y2, z2), calculating
[0102]
[0103] If 0<t<1, the extreme point is located on the edge, and the coordinate is [x1+t(x2-x1), y1+t(y2-y1), z1+t(z2-z1)]; otherwise, the extreme point is located on the vertex;
[0104] Respectively calculating the elevation angle and the azimuth angle of each vertex and the extreme point of the face element ΔABC; the calculation method of the elevation angle and the azimuth angle can refer to the calculation method in the above-mentioned embodiment 1, which will not be repeated here;
[0105] The maximum and minimum values of the elevation angles at each vertex and extreme point are taken as the maximum and minimum values of the elevation angle range of surface element ΔABC, and the maximum and minimum values of the azimuth angles at each vertex of surface element ΔABC are taken as the maximum and minimum values of the azimuth angle range of surface element ΔABC, thus obtaining the elevation angle range and azimuth angle range of the ray from the observation point to surface element ΔABC.
[0106] In this embodiment, the extreme points on the edge formed by any two vertices (x1, y1, z1) and (x2, y2, z2) in a surface element are determined based on the following principle:
[0107] Let the two vertices above be P1 and P2 respectively, then a point P(x) on line segment P1P2 p y p z p The coordinates of ) are:
[0108]
[0109] The elevation and azimuth angles of point P are as follows:
[0110]
[0111]
[0112] Where r represents the distance from point P to the origin of the coordinate system;
[0113] Since both arccosx and arctanx are monotonic within their domains, we only need to analyze z. p / r and y p / x p To determine the monotonicity of the expression, take its derivative:
[0114]
[0115]
[0116] Where a, b, and c are represented by the following formulas:
[0117] a = (x2 - x1) 2 +(y2-y1) 2 +(z2-z1) 2 (6)
[0118] b=2[x1(x2-x1)+y1(y2-y1)+z1(z2-z1)] (7)
[0119] c = x1 2 +y1 2 +z1 2 (8)
[0120] As to the azimuth angle, in formula (5), when x1 and x2 are of the same sign, the denominator is always greater than 0, and x1y2-x2y1 is a constant value, so the azimuth angle is monotonic on the line segment P1P2, and the extreme value is at the two ends of the line segment; when x1 and x2 are of different signs, there is a case that the denominator is 0 (x p =0), the azimuth angle is discontinuous at this point, and the extreme value is inside the line segment.
[0121] In this embodiment, the original coordinate system is rotated to rotate the target center point to the positive half of the x-axis, and the coordinate is [D, 0, 0], where D is the observation distance, and the rotation matrix R can be represented as:
[0122]
[0123] The original coordinate system is denoted as (X, Y, Z), and the target coordinate system obtained by rotation is denoted as (X', Y', Z'), so the target coordinate in the target coordinate system is the original coordinate multiplied by the rotation matrix R. It can be seen that the x coordinates of the target are of the same sign after the coordinate system is rotated in the above manner, so that the extreme value of the azimuth angle is located at the vertex of the triangular facet.
[0124] As to the pitch angle, the extreme point is at the point where the derivative is 0, and the denominator of formula (4) is always greater than 0, that is, the numerator is equal to 0:
[0125] [(z2-z1)b-2z1a]t+2(z2-z1)c-bz1=0 (10) The solution is:
[0126]
[0127] After calculating the above formula, if 0≤t p ≤1, the extreme value is inside the line segment, and the extreme point coordinate is obtained:
[0128]
[0129] The pitch angle of the extreme point is obtained by substituting into formula (2); if 0≤t p ≤1 is not satisfied, the extreme value is at the two ends of the line segment, that is, the extreme point is located at the vertex.
[0130] Based on the above calculation method, the accuracy of the range of the facet pitch angle and the range of the azimuth angle can be effectively improved in this embodiment, so as to improve the accuracy and efficiency of the ray tracing.
[0131] In this embodiment, the implementation manners of the remaining steps can refer to the description of embodiment 1, which will not be repeated here.
[0132] Embodiment 4:
[0133] A cache-based ray tracing device, comprising: a preprocessing module and a tracing module;
[0134] a preprocessing module, configured to obtain a triangular facet model of the target, calculate a range of the pitch angle and a range of the azimuth angle of a ray from an observation point to each triangular facet of the target, and cache the ranges;
[0135] The tracking module comprises a first-level rejection detection unit, a second-level rejection detection unit, and an iteration control unit.
[0136] The first-level rejection detection unit is configured to obtain a pitch angle δ and an azimuth angle of a current ray According to the cached information, eliminate a facet whose range of the pitch angle does not contain the pitch angle δ, and a facet whose range of the azimuth angle does not contain the azimuth angle If the number of the remaining facets is 0, end the tracking of the current ray; otherwise, take the current ray as a target ray, take the remaining facets as candidate facets, and trigger the second-level rejection detection unit.
[0137] The second-level rejection detection unit is configured to perform line-facet intersection calculation on the target ray and the candidate facets, and if there is an intersection point, trigger the iteration control unit; otherwise, end the tracking of the current ray.
[0138] The iteration control unit is configured to, after recording the intersection point, take a reflected ray as a new target ray, take all the facets as new candidate facets, and trigger the second-level rejection detection unit.
[0139] In this embodiment, the specific implementation manners of the modules and units can refer to the descriptions in Embodiments 1 or 3, which will not be repeated here.
[0140] Embodiment 5
[0141] A ray tracking device based on caching, which is similar to Embodiment 4, and the difference is that, in this embodiment, the preprocessing module is further configured to calculate a minimum incident angle of each facet of the target and cache the minimum incident angle; the minimum incident angle is the minimum value of the incident angles of rays from each vertex of the facet to the vertices of other facets.
[0142] In addition, the tracking module further comprises a third-level rejection detection unit configured to obtain a reflection angle θ of a reflected ray, and read the minimum incident angle θ min of the current intersection facet from the cached information, and if θ < θ min , end the tracking of the current ray.
[0143] In addition, the iteration control module will first trigger the third-level rejection detection unit before triggering the second-level rejection detection unit.
[0144] In this embodiment, the specific implementation manners of the modules and units can refer to the descriptions in Embodiments 1 and 2, which will not be repeated here.
[0145] Embodiment 6:
[0146] A cache-based ray tracing system comprises a computer readable storage medium and a processor;
[0147] The computer readable storage medium is used for storing a computer program;
[0148] The processor is used for reading the computer program stored in the computer readable storage medium, and executing the cache-based ray tracing method provided in any one of Embodiments 1-3.
[0149] The ray tracing methods disclosed in “CN105953925A” and “CN107300645A” are taken as comparative methods of the ray tracing method based on three-level rejection detection in the present application, and different ray tracing methods are compared and analyzed through simulation experiments, so as to further analyze and illustrate the beneficial effects that can be achieved by the present application.
[0150] Compared with the above two ray tracing methods, the core difference of the cache-based ray tracing method provided by the present application is that the target information cached in advance is called in the ray tracing loop (i.e. in the ray tracing process), which reduces the calculation amount in the ray tracing loop, while the other two methods perform calculation in the ray tracing loop, and calculation is required for each ray during tracking, which will generate a large amount of calculation. The present application only needs to perform calculation and caching once outside the ray tracing loop (i.e. before formal ray tracing), and the information cached in advance is called during ray tracing, which avoids complex calculation and reduces calculation amount.
[0151] The simulation experiment is as follows:
[0152] Program testing is performed under the win7 system, the same triangular facet point array (20716 points forming 41436 triangles) is input, the maximum coordinate value is 10m, the observation distance is 20000m, the same result is output, and the control variable method is used, other preparation programs are the same, only the core algorithm part is changed. The running time of the existing method one is 28.5 seconds, the running time of the existing method two is 23.2 seconds, and the running time of the present application is 11.2 seconds. It can be seen that the method proposed in the present application further reduces the program running time on the basis of the original fast ray tracing algorithm. In addition, with the increase of the number of target facets and the decrease of the observation distance, the improvement of the speed calculation efficiency is more obvious.
[0153] Those skilled in the art will readily understand that the above description is only a preferred embodiment of the present application, and is not intended to limit the present application. Any modification, equivalent replacement and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A ray tracing method based on caching, characterized in that, Comprising: Pre-obtain the triangular facet model of the target and the positions of the observation points, calculate the elevation angle range and azimuth angle range of the rays from the observation points to each facet of the target, and cache them; Perform the tracing of each ray according to the following steps: (S1) Obtain the elevation angle δ and azimuth angle φ of the current ray, and according to the cached information, eliminate the facets whose elevation angle ranges do not contain the elevation angle δ, and the facets whose azimuth angle ranges do not contain the azimuth angle φ. If the number of remaining facets is 0, end the tracing of the current ray; Otherwise, take the current ray as the target ray, take the remaining facets as candidate facets, and transfer to step (S3); (S2) Make two non-parallel planes passing through the target ray, eliminate the facets among the candidate facets that do not intersect both of the made planes simultaneously, and take the remaining facets as the new candidate facets; (S3) Perform a line-plane intersection calculation on the target ray and the candidate facets. If there is an intersection point, transfer to step (S4); otherwise, end the tracing of the current ray; (S4) After recording the intersection point, take the reflected ray of the target ray as the new target ray, take all the facets as the new candidate facets, and transfer to step (S2); The above-mentioned ray tracing method based on caching further includes: Pre-calculate the minimum incident angle of each facet of the target and cache it; the minimum incident angle is the minimum value of the incident angles of the rays from the vertices of the facet to the vertices of other facets; And, in step (S4), before transferring to step (S2), it further includes: Obtain the reflection angle θ of the reflected ray, and read the minimum incident angle θ of the current intersecting surface element from the cached information. min If θ < θ min If so, the current ray tracking will end; The calculation methods of the elevation angle range and azimuth angle range of the ray from the observation point to any facet ΔABC are as follows: Taking the observation point as the origin, establish an original coordinate system; rotate the original coordinate system to obtain a target coordinate system; in the target coordinate system, the coordinates of the target center point are [D, 0, 0], where D is the observation distance; In the target coordinate system, detect the extreme points of the elevation angle on each side of the facet ΔABC. The detection method is: For any two vertices (x1, y1, z1) and (x2, y2, z2), calculate If 0 < t < 1, the extreme point is located on this side, and its coordinates are [x1 + t(x2 - x1), y1 + t(y2 - y1), z1 + t(z2 - z1)]; otherwise, the extreme point is located at the vertex; Calculate the elevation angles and azimuth angles of each vertex and extreme point of the facet ΔABC respectively. Take the maximum and minimum values of the elevation angles among the elevation angles of each vertex and extreme point as the maximum and minimum values of the elevation angle range of the facet ΔABC, and take the maximum and minimum values of the azimuth angles among the azimuth angles of each vertex of the facet as the maximum and minimum values of the azimuth angle range of the facet ΔABC, to obtain the elevation angle range and azimuth angle range of the ray from the observation point to the facet ΔABC.
2. The ray tracing method based on caching as described in claim 1, characterized in that, In step (S2), before performing the line-plane intersection calculation on the target ray and the candidate facets, it further includes: Eliminate the facets among the candidate facets that are blocked relative to the target ray, and take the remaining facets as the new candidate facets.
3. The ray tracing method based on caching as described in claim 1, characterized in that, For any facet ΔABC, its calculation method of the minimum incident angle includes: (T1) Determine the normal vector of the surface element ΔABC. ; (T2) Select a vertex P of another face element and calculate the vector respectively. , and and The included angle; Repeat step (T2) until all vertices of all facets outside the facet ΔABC are computed; (T4) Determine the minimum value among the computed angles as the minimum incident angle of the facet ΔABC.
4. The ray tracing method based on caching as described in claim 1, characterized in that, The methods for determining the intersection between a plane and a facet include: Calculate the signs of the distances from the three vertices of the facet to the plane. If they are all positive or all negative, it is determined that the plane and the facet do not intersect; otherwise, it is determined that the plane and the facet intersect.
5. A cache-based ray tracing device, characterized in that, Include: A preprocessing module and a tracking module; The preprocessing module is used to obtain the triangular facet model of the target and the position of the observation point, calculate the elevation angle range and azimuth angle range of the ray from the observation point to each triangular facet of the target, and cache them; The tracking module includes: a first-level rejection detection unit, a second-level rejection detection unit, a line-plane intersection calculation unit, and an iteration control unit; The first-level rejection detection unit is used to obtain the elevation angle δ and azimuth angle φ of the current ray, eliminate the facets whose elevation angle ranges do not contain the elevation angle δ and the facets whose azimuth angle ranges do not contain the azimuth angle φ according to the cached information. If the number of remaining facets is 0, end the tracking of the current ray; otherwise, use the current ray as the target ray, use the remaining facets as candidate facets, and trigger the line-plane intersection calculation unit; The second-level rejection detection unit is used to make two non-parallel planes passing through the target ray, eliminate the facets among the candidate facets that do not intersect both of the made planes simultaneously, and use the remaining facets as new candidate facets, and then trigger the line-plane intersection calculation unit; The line-plane intersection calculation unit is used to perform line-plane intersection calculation on the target ray and the candidate facets. If there is an intersection point, trigger the iteration control unit; otherwise, end the tracking of the current ray; The iteration control unit is used to record the intersection point, use the reflected ray as the new target ray, use all facets as the new candidate facets, and trigger the second-level rejection detection unit; The preprocessing module is also used to calculate the minimum incident angle of each facet of the target and cache it; the minimum incident angle is the minimum value of the incident angles of the rays from the vertices of a facet to the vertices of other facets; Furthermore, the tracking module also includes a third-level rejection detection unit, used to obtain the reflection angle θ of the reflected ray and read the minimum incident angle θ of the current intersecting surface element from the cached information. min If θ < θ min If so, the current ray tracking will end; Moreover, the iteration control unit will trigger the third-level rejection detection unit before triggering the second-level rejection detection unit; The calculation methods for the elevation angle range and azimuth angle range of the ray from the observation point to any facet ΔABC are as follows: Taking the observation point as the origin, establish an original coordinate system; rotate the original coordinate system to obtain a target coordinate system; in the target coordinate system, the coordinates of the target center point are [D, 0, 0], where D is the observation distance; In the target coordinate system, detect the extreme points of the elevation angle on each side of the facet ΔABC. The detection method is: For any two vertices (x1, y1, z1) and (x2, y2, z2), calculate If 0 < t < 1, the extreme point is located on this side, and its coordinates are [x1 + t(x2 - x), y1 + t(y2 - y1), z1 + t(z2 - z1)]; otherwise, the extreme point is located at the vertex. Calculate the pitch and azimuth angles of each vertex and extreme point of surface element ΔABC. Take the maximum and minimum values of the pitch angles of each vertex and extreme point as the maximum and minimum values of the pitch angle range of surface element ΔABC, and take the maximum and minimum values of the azimuth angles of each vertex of surface element ΔABC as the maximum and minimum values of the azimuth angle range of surface element ΔABC. This gives the pitch and azimuth angle ranges of the ray from the observation point to surface element ΔABC.
6. A cache-based ray tracing system, characterized in that, Includes computer-readable storage media and processors; The computer-readable storage medium is used to store computer programs; The processor is used to read the computer program stored in the computer-readable storage medium and execute the cache-based ray tracing method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Millimeter wave radiation brightness temperature acquisition method based on quick ray tracing
CN105953925A
Rapid ray tracing method and system
CN107300645A