Free-form surface ray tracing method and device, electronic equipment and computer readable storage medium

By using a method of generating low-order polynomials through bounding boxes and 3D voxel meshes, the problem of solving for intersection points in ray tracing of freeform surfaces is solved, achieving ray tracing with nanometer-level precision and supporting the independent development of domestic optical software.

CN121784962APending Publication Date: 2026-04-03GUANGDONG INST OF SEMICON IND TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-12
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

Existing techniques cannot effectively describe arbitrary freeform surfaces in ray tracing, making it difficult to solve for the intersection points of rays and surfaces. Furthermore, existing methods have the problem of not being able to guarantee nanometer-level accuracy.

Method used

A method based on bounding boxes and 3D voxel meshes is adopted. By generating low-order polynomials, the intersection points of light rays and freeform surfaces are fitted. The bounding box is used to quickly determine whether the light rays intersect the freeform surface. Ingress and egress polynomials are generated within the actual mesh that the light rays pass through, so as to achieve precise positioning of the light rays on the freeform surface.

Benefits of technology

It achieves nanometer-level precision ray tracing without relying on the original design parameters, improves the self-development capability of optical design software, and reduces computational complexity and errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121784962A_ABST
    Figure CN121784962A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a free-form surface ray tracing method and device, electronic equipment and a computer readable storage medium, and relates to the technical field of optical simulation. According to the method, a traditional method of describing the whole free-form surface by using a global single function is abandoned, a low-order incident polynomial and a low-order emergent polynomial are only generated for an incident grid and an emergent grid through which incident light actually passes, and real on-demand local modeling is realized. In the whole process, discrete point cloud coordinates of the free-form surface are completely used as unique input, any preset analytical equation model is not needed, and original design parameters of an optical element are not depended. No matter how complex free-form surfaces are, only a few voxel grids through which the light actually passes need to be processed, the local geometric morphology of the free-form surfaces can be accurately described by using a low-order polynomial, and then the light equation of the incident light and the two local polynomials are subjected to simultaneous solution, so that the incident coordinates and the emergent coordinates of the light on the free-form surfaces can be accurately determined; and the error is stably controlled at the nanoscale.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of optical simulation technology, and more specifically, to a method, apparatus, electronic device, and computer-readable storage medium for ray tracing on freeform surfaces. Background Technology

[0002] Currently, in my country's optical design field, optical simulation typically relies on foreign optical design software. Therefore, it is essential to focus on developing domestically produced optical simulation software with independent intellectual property rights. Ray tracing algorithms are the core technology and cornerstone of modern optical design, belonging to the underlying logic of optical design software. Their core idea is to represent light propagation as a series of rays, each with a direction vector and spatial coordinates. Based on the laws of geometric optics, assuming light propagates in a straight line in a uniform medium, the precise intersection points of the rays with the surface of the optical element are calculated to obtain the intersection points. Furthermore, at the interface, the Snell's law of refraction and the law of reflection are followed to calculate the direction of light propagation after passing through the surface.

[0003] In ray tracing algorithms, commonly used optical element surface types include spheres, aspherical surfaces, and freeform surfaces. Existing methods are quite mature for solving the intersection points of rays with spheres and aspherical surfaces. However, for optical freeform surfaces, due to the complexity of their surface description, there is currently a lack of a mature and universal method for describing freeform optical elements.

[0004] Current mainstream ray tracing methods for freeform surfaces are driven by analytical equations, meaning the surface must be defined by continuous mathematical expressions, such as Zernike polynomials, XY polynomials, Q-type polynomials, and NURBS (Non-Uniform Rational B-Splines). These methods approximate the freeform surface by constructing complex polynomials and then solve for the intersection points of rays with the surface using numerical iteration methods. In industry, freeform surfaces are also commonly represented using NURBS or B-splines, which similarly describe the freeform surface using specific analytical equations and then calculate the intersection points of rays with the surface based on this parametric model. Alternatively, methods discretize the optical surface, approximating it with a large number of tiny triangles and then solving for the intersection points of rays with these triangles.

[0005] In freeform surface ray tracing, a single "universal equation" cannot be used to describe any freeform surface. Therefore, numerical iterative methods based on analytical equations typically require different polynomial types and orders for different scenarios to comprehensively describe the freeform surface. Analytical model-driven freeform surface ray tracing is the mainstream approach in optical design software. This method predefines the freeform surface as a known analytical function, meaning it has a strong dependence on the original design model. When the accurate mathematical expression of the freeform surface cannot be obtained, it becomes impossible to solve for the intersection points of the rays and the surface.

[0006] When using NURBS or B-splines to represent freeform surfaces for ray tracing, extremely high precision is required in optics, typically at the nanometer level. However, the fitting error of NURBS is unacceptable in optics, often leading to intersection errors at the micrometer or even millimeter level. Using triangular infinitesimals to approximate freeform surfaces requires a large triangulation density; otherwise, the surface approximation error is significant. Furthermore, approximating a continuous, twice-differentiable optical surface with triangular planes implies abrupt changes in the edges between adjacent triangles, leading to discontinuities in the normal vector and consequently errors in the calculation of ray refraction. Summary of the Invention

[0007] In view of this, the purpose of the present invention is to provide a freeform surface ray tracing method, apparatus, electronic device and computer-readable storage medium that can achieve nanoscale ray tracing without relying on the original design parameters of optical components.

[0008] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows: In a first aspect, the present invention provides a method for ray tracing on a freeform surface, the method comprising: Obtain the equation of the incident ray; the equation includes the coordinates of the ray's origin and the ray's unit movement vector; Determine whether the incident ray intersects the bounding box based on the coordinates of the ray's origin, the ray's unit movement vector, and the bounding box of the freeform surface; If the incident ray intersects the bounding box, the incident mesh and the exit mesh are determined in the three-dimensional voxel mesh of the freeform surface based on the ray origin coordinates and the ray unit movement vector; the three-dimensional voxel mesh is generated based on the point cloud coordinates of the bounding box and the freeform surface. An injection polynomial is generated based on the point cloud coordinates contained in the injection grid, and an exit polynomial is generated based on the point cloud coordinates contained in the exit grid; both the injection polynomial and the exit polynomial are low-order polynomials. The incident coordinates and exit coordinates of the incident ray on the freeform surface are determined based on the ray equation, the incident polynomial, and the exit polynomial.

[0009] In an optional implementation, determining whether the incident ray intersects the bounding box based on the ray origin coordinates, the ray unit movement vector, and the bounding box of the freeform surface includes: The entry time into the bounding box and the exit time from the bounding box are determined based on the coordinates of the ray origin, the unit movement vector of the ray, and the bounding box of the freeform surface. If the time of entering the bounding box does not exceed the time of exiting the bounding box and the time of exiting the bounding box is greater than zero, it is determined that the incident ray intersects with the bounding box; If the time for the incident ray to enter the bounding box exceeds the time for the ray to exit the bounding box, or if the time for the ray to exit the bounding box is not greater than zero, it is determined that the incident ray does not intersect the bounding box.

[0010] In an optional implementation, determining the entry into the bounding box time and the exit from the bounding box time based on the ray origin coordinates, the ray unit movement vector, and the bounding box of the freeform surface includes: The horizontal axis entry time, vertical axis entry time, vertical axis entry time, horizontal axis exit time, vertical axis exit time, and vertical axis exit time are determined based on the bounding box, the coordinates of the ray origin, and the ray unit movement vector. The maximum value among the horizontal axis entry time, the vertical axis entry time, and the vertical axis entry time is determined as the injection time into the bounding box. The minimum value among the horizontal axis departure time, the vertical axis departure time, and the vertical axis departure time is determined as the ejection bounding box time.

[0011] In an optional implementation, determining the injection and exit meshes in a three-dimensional voxel mesh of the freeform surface based on the ray origin coordinates and the ray unit movement vector includes: The tracing start point grid is determined based on the intersection point of the incident ray and the bounding box; Based on the tracing start grid and the ray unit movement vector, three candidate grids adjacent to the tracing start grid are determined in the three-dimensional voxel grid; Calculate the time taken for the starting grid to reach each of the candidate grids, and determine the candidate grid with the shortest time as the target grid; If the target mesh is the surface voxel mesh corresponding to the freeform surface, the first surface voxel mesh is determined as the injection mesh, and the second surface voxel mesh is determined as the ejection mesh; If the target mesh is not the surface voxel mesh corresponding to the freeform surface, the target mesh is determined as the new tracing starting point mesh, and the traversal continues along the direction of the incident light until the incident mesh and the exit mesh are obtained.

[0012] In an optional implementation, generating the injection polynomial based on the point cloud coordinates contained in the injection mesh includes: If the point cloud coordinates contained in the injected mesh exceed a preset number, obtain a preset third-order polynomial; Substitute the point cloud coordinates contained in the injection grid into the preset third-order polynomial, and solve the coefficients of the preset third-order polynomial by the least squares method to obtain the injection polynomial. If the point cloud coordinates contained in the injected mesh do not exceed a preset number, obtain a preset second-order polynomial; Substitute the point cloud coordinates contained in the injection mesh into the preset second-order polynomial, and solve the coefficients of the preset second-order polynomial by the least squares method to obtain the injection polynomial.

[0013] In an optional implementation, determining the incident coordinates and exit coordinates of the incident ray on the freeform surface based on the ray equation, the incident polynomial, and the exit polynomial includes: Establish the injection function based on the ray equation and the injection polynomial; The injection function is iteratively solved, and the time corresponding to when the value of the injection function satisfies the convergence condition is determined as the injection time. The injection coordinates are determined based on the injection time and the ray equation. Establish the emission function based on the ray equation and the emission polynomial; The emission function is iteratively solved, and the time corresponding to when the value of the emission function satisfies the convergence condition is determined as the emission time. The emission coordinates are then determined based on the emission time and the ray equation.

[0014] In an optional implementation, before obtaining the ray equation of the incident ray, the method further includes: Obtain the original coordinates of multiple point clouds on the freeform surface; The original coordinates of all the points cloud are moved as a whole to obtain the point cloud coordinates corresponding to each of the original point cloud coordinates; the values ​​of the point cloud coordinates in the three axes are all non-negative. Construct the bounding box of the freeform surface based on all the point cloud coordinates; The bounding box is divided into multiple voxel grids according to a preset grid size; The voxel mesh containing the point cloud coordinates is determined as the surface voxel mesh corresponding to the freeform surface, thus obtaining the three-dimensional voxel mesh.

[0015] In a second aspect, the present invention provides a freeform surface ray tracing device, the device comprising: The acquisition module is used to acquire the ray equation of the incident ray; the ray equation includes the coordinates of the ray's origin and the ray's unit movement vector; The processing module is used to determine whether the incident ray intersects the bounding box based on the ray origin coordinates, the ray unit movement vector, and the bounding box of the freeform surface; if the incident ray intersects the bounding box, it determines the injection grid and the exit grid in the three-dimensional voxel grid of the freeform surface based on the ray origin coordinates and the ray unit movement vector; the three-dimensional voxel grid is generated based on the point cloud coordinates of the bounding box and the freeform surface; A generation module is used to generate an injection polynomial based on the point cloud coordinates contained in the injection grid, and to generate an exit polynomial based on the point cloud coordinates contained in the exit grid; both the injection polynomial and the exit polynomial are low-order polynomials; the injection coordinates and exit coordinates of the incident ray on the freeform surface are determined based on the ray equation, the injection polynomial, and the exit polynomial.

[0016] Thirdly, the present invention provides an electronic device including a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor can execute the computer program to implement the freeform surface ray tracing method described in any of the foregoing embodiments.

[0017] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the freeform surface ray tracing method as described in any of the foregoing embodiments.

[0018] Compared to existing technologies, the freeform surface ray tracing method, apparatus, electronic device, and computer-readable storage medium provided in this invention abandon the traditional approach of describing the entire freeform surface with a single global function. Instead, it generates low-order incident and exit polynomials for the point cloud data contained in the two specific voxels through which the incident ray actually passes, respectively, to achieve truly on-demand local modeling. The entire process uses the discrete point cloud coordinates of the freeform surface as the only input, without requiring any pre-defined analytical equation model or relying on the original design parameters of the optical elements.

[0019] No matter how complex the freeform surface, only a few voxel meshes that the light actually passes through need to be processed. Low-order polynomials can accurately characterize its local geometry. Then, by simultaneously solving the ray equation of the incident ray with these two local polynomials, the incident and exit coordinates of the light ray on the freeform surface can be accurately determined, with errors consistently controlled at the nanometer level. Because it is completely independent of the original design parameters, it can effectively support the independent development of domestically produced optical software.

[0020] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0021] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 A schematic flowchart of a freeform surface ray tracing method provided by an embodiment of the present invention is shown.

[0023] Figure 2 This diagram illustrates another flowchart of the freeform surface ray tracing method provided in an embodiment of the present invention.

[0024] Figure 3 A block diagram of a freeform surface ray tracing device provided in an embodiment of the present invention is shown.

[0025] Figure 4 A block diagram of an electronic device provided in an embodiment of the present invention is shown. Detailed Implementation

[0026] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0027] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0028] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0029] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0030] Please refer to Figure 1 , Figure 1 A schematic flowchart of a freeform surface ray tracing method provided by an embodiment of the present invention is shown. The method includes the following steps: Step S10: Obtain the ray equation of the incident ray; the ray equation includes the coordinates of the ray's origin and the ray's unit movement vector.

[0031] In this embodiment of the invention, obtaining the ray equation of the incident ray is the starting point of the entire tracing process. The ray equation is composed of the ray origin coordinates and the ray unit movement vector. The ray origin coordinates represent the starting position of the ray in space, while the ray unit movement vector describes the direction and step ratio of the ray's forward extension. Together, they uniquely determine an infinitely long straight line trajectory.

[0032] Specifically, the equation of the incident ray. As shown below:

[0033] in, The coordinates of the origin of the incident ray are denoted as . ; It is the unit displacement vector of light, denoted as ,satisfy t is the time it takes for the incident light to reach the voxel grid.

[0034] Step S20: Determine whether the incident ray intersects the bounding box based on the coordinates of the ray's origin, the ray's unit movement vector, and the bounding box of the freeform surface.

[0035] In this embodiment of the invention, the bounding box, which is the smallest cuboid that closely fits the shape of the freeform surface, is used to quickly check whether the incident light ray might encounter the freeform surface. If the incident light ray does not intersect with the bounding box, it means that the incident light ray has not entered the possible spatial region of the freeform surface at all, and cannot even pass through the outermost bounding box. Therefore, there is no need to continue calculation, and all subsequent steps are skipped, thereby avoiding invalid calculations and significantly improving the overall processing efficiency.

[0036] Step S30: If the incident ray intersects the bounding box, determine the injection grid and the exit grid in the three-dimensional voxel grid of the freeform surface according to the coordinates of the ray's starting point and the ray's unit movement vector; the three-dimensional voxel grid is generated based on the point cloud coordinates of the bounding box and the freeform surface.

[0037] In this invention, if the incident ray intersects with the rectangular bounding box, the actual contact area between the ray and the freeform surface is further precisely located using a three-dimensional voxel mesh of the freeform surface. It should be understood that each voxel in the three-dimensional voxel mesh may carry local spatial information of the freeform surface, allowing the ray path to be decomposed into traceable mesh traversal processes. This determines the incident mesh traversed when the incident ray enters the freeform surface and the exit mesh traversed when the incident ray leaves the freeform surface, thereby transforming the abstract problem of intersection points into a concrete problem of mesh indexing.

[0038] Step S40: Generate an injection polynomial based on the point cloud coordinates contained in the injection grid, and generate an exit polynomial based on the point cloud coordinates contained in the exit grid; both the injection polynomial and the exit polynomial are low-order polynomials.

[0039] In this embodiment of the invention, for the two tiny regions where the incident light actually enters and exits (i.e., the incident grid and the exit grid), a low-order polynomial is used for local fitting, avoiding the use of complex formulas to describe the entire freeform surface. Since the number of point cloud coordinates within the incident or exit grid is limited and the spatial span is small, low-order fitting can ensure sufficient accuracy.

[0040] Step S50: Determine the incident coordinates and exit coordinates of the incident ray on the freeform surface based on the ray equation, the incident polynomial, and the exit polynomial.

[0041] In this embodiment of the invention, the incident coordinates of the incident ray on the freeform surface are determined according to the ray equation and the incident polynomial, and the exit coordinates of the incident ray on the freeform surface are determined according to the ray equation and the exit polynomial. The incident coordinates are the three-dimensional coordinates of the incident ray entering the freeform surface, and the exit coordinates are the three-dimensional coordinates of the incident ray leaving the freeform surface.

[0042] In summary, the freeform surface ray tracing method provided by this invention abandons the traditional approach of describing the entire freeform surface with a single global function. Instead, it generates low-order incident and exit polynomials for the point cloud data contained in the two specific voxels through which the incident ray actually passes, achieving truly on-demand local modeling. The entire process uses the discrete point cloud coordinates of the freeform surface as the only input, without requiring any pre-defined analytical equation model or relying on the original design parameters of the optical elements.

[0043] No matter how complex the freeform surface, only a few voxel meshes that the light actually passes through need to be processed. Low-order polynomials can accurately characterize its local geometry. Then, by simultaneously solving the ray equation of the incident ray with these two local polynomials, the incident and exit coordinates of the light ray on the freeform surface can be accurately determined, with errors consistently controlled at the nanometer level. Because it is completely independent of the original design parameters, it can effectively support the independent development of domestically produced optical software.

[0044] Alternatively, one possible implementation method for determining whether the incident ray intersects with the bounding box is provided below. Figure 1 The sub-steps of step S20 may include: Step S200: Determine the entry time into the bounding box and the exit time from the bounding box based on the ray origin coordinates, the ray unit movement vector, and the bounding box of the freeform surface.

[0045] In this embodiment of the invention, the time for the light to enter the bounding box and the time for the light to leave the bounding box are calculated based on the coordinates of the starting point of the incident light, the unit movement vector of the light, and the bounding box of the freeform surface, i.e., the time for the light to enter the bounding box and the time for the light to leave the bounding box.

[0046] Step S210: If the time of entering the bounding box does not exceed the time of exiting the bounding box and the time of exiting the bounding box is greater than zero, it is determined that the incident ray intersects with the bounding box.

[0047] In this embodiment of the invention, if the time of entering the bounding box does not exceed the time of exiting the bounding box, and the time of exiting the bounding box is greater than zero, it indicates that the incident light has indeed penetrated the internal region of the bounding box and there is a possibility of contact with the freeform surface.

[0048] Step S220: If the time for the incident ray to enter the bounding box exceeds the time for the ray to exit the bounding box, or if the time for the ray to exit the bounding box is not greater than zero, it is determined that the incident ray does not intersect the bounding box.

[0049] In this embodiment of the invention, if the time for the incident light to enter the bounding box exceeds the time for the incident light to exit the bounding box, or if the time for the incident light to exit the bounding box is not greater than zero, it indicates that the principle of light travel is not followed at all. Therefore, it is determined that the incident light does not penetrate the internal area of ​​the bounding box, that is, the incident light does not intersect with the bounding box.

[0050] As can be seen, this embodiment of the invention can accurately determine whether a ray has passed through the bounding box by simply determining that the entry time is not later than the exit time and the exit time is positive. When the incident ray does not intersect the bounding box, it is impossible to continue solving for the precise intersection point between the incident ray and the freeform surface. Therefore, based on the fact that the incident ray does not intersect the bounding box, subsequent calculations for invalid rays can be avoided, thereby improving the efficiency of ray tracing on freeform surfaces.

[0051] Optionally, regarding how to determine the bounding box entry time and bounding box exit time, the following is a possible implementation. Sub-steps of step S200 may include: Step S201: Determine the horizontal axis entry time, vertical axis entry time, vertical axis entry time, horizontal axis exit time, vertical axis exit time, and vertical axis exit time based on the bounding box, the coordinates of the ray's starting point, and the ray's unit movement vector.

[0052] In this embodiment of the invention, the minimum and maximum values ​​of the bounding box of the freeform surface in the three directions of the horizontal axis (X), vertical axis (Y), and vertical axis (Z) are used (i.e., , , , , , ), combined with the coordinates of the starting point of the incident ray. and the unit movement vector of light Calculate the time required to reach each plane of the bounding box.

[0053] For example, calculating the time required for an incident ray to reach two planes of the bounding box perpendicular to the horizontal axis yields the arrival time. The corresponding plane time and arrival The corresponding plane time .

[0054]

[0055]

[0056] Similarly, by calculating the time required for the incident ray to reach the two planes of the bounding box perpendicular to the vertical axis, we obtain... and Calculate the time required for the incident ray to reach the two planes of the bounding box perpendicular to the vertical axis, and obtain... and .

[0057] in,

[0058]

[0059]

[0060]

[0061] Next, let's take the X-axis as an example. When the incident ray travels along the positive X-axis, the ray... The time it takes for the direction to enter the bounding box is When the incident ray travels along the negative X-axis, the ray... The time it takes for the direction to enter the bounding box is Therefore, the incident light rays at The time for the direction to enter the bounding box (i.e., the time for entry in the horizontal direction) is The incident light is The time it takes for the direction to leave the bounding box (i.e., the time it takes to leave in the horizontal direction) is .

[0062] Similarly, the incident light ray at The time for the direction to enter the bounding box (i.e., the time for entry along the vertical axis) is: The incident light is The time it takes for the direction to leave the bounding box (i.e., the time it takes to leave along the vertical axis) is The incident light rays at The time for the direction to enter the bounding box (i.e., the vertical axis entry time) is: The incident light is The time it takes for the direction to leave the bounding box (i.e., the time it takes to leave in the vertical direction) is .

[0063] Step S202: Determine the maximum value among the horizontal axis entry time, the vertical axis entry time, and the vertical axis entry time as the time to enter the bounding box.

[0064] Furthermore, for the incident light ray to truly "begin to enter" the bounding box, it must simultaneously reach the boundaries of the bounding box in all three axes; that is, the latest entry time marks the complete entry. Therefore, the maximum value among the entry times in the horizontal, vertical, and axial directions is determined as the time of entry into the bounding box. .

[0065] in,

[0066] Step S203: Determine the minimum value among the horizontal axis departure time, the vertical axis departure time, and the vertical axis departure time as the ejection bounding box time.

[0067] As soon as a ray crosses the boundary of the bounding box in any axis, it has left the bounding box. Therefore, the minimum value among the departure time in the horizontal axis, the departure time in the vertical axis, and the departure time in the y-axis direction is determined as the exit time from the bounding box. .

[0068] in,

[0069] As can be seen, the embodiments of the present invention calculate the time for the incident light to enter and leave the bounding box in the three directions of the horizontal axis, vertical axis and vertical axis respectively, and then take the maximum value of the three entry times as the time of entering the bounding box and the minimum value of the three exit times as the time of exiting the bounding box, so as to quickly and accurately determine whether the light intersects with the bounding box.

[0070] Alternatively, one possible implementation for determining the injection and exit meshes is provided below. Figure 1 The sub-steps of step S30 may include: Step S300: Determine the starting point grid for tracing based on the intersection of the incident ray and the bounding box.

[0071] In this embodiment of the invention, when the incident light ray passes through the bounding box, it will intersect with the surface of the bounding box at a point. This intersection point is the starting position of the light ray entering the bounding box, that is, the incident light ray and the bounding box's entry intersection point. The voxel mesh where the entry intersection point falls is determined as the current tracing starting point mesh.

[0072] Assume the index of the starting grid of the tracing point is (i, j, k), where i, j, and k correspond to the grid numbers along the horizontal, vertical, and triangular axes, respectively, and the minimum corner point of the bounding box... The corresponding index is (1, 1, 1), and the entire three-dimensional voxel mesh is thus uniformly indexed.

[0073] It should be understood that (i+1, j, k) represents the index moving forward one voxel grid along the positive horizontal axis, (i, j+1, k) represents the index moving forward one voxel grid along the positive vertical axis, and (i, j, k+1) represents the index moving forward one voxel grid along the positive vertical axis.

[0074] Step S310: Determine three candidate grids adjacent to the tracing start grid in the three-dimensional voxel grid based on the tracing start grid and the ray unit movement vector.

[0075] In this embodiment of the invention, starting from the current tracing origin grid, the ray can only enter three adjacent grids that share a face with the current tracing origin grid, that is, move one voxel grid along the positive or negative X, Y, and Z axes respectively. The specific direction depends on the sign of the ray's unit movement vector. If , then the candidate grid index along the positive X-axis is (i+1, j, k); if Then the candidate grid index along the negative X-axis is (i-1, j, k). Similarly, the candidate grid indices in the y and z directions can be obtained.

[0076] Step S320: Calculate the time taken for the starting grid to reach each candidate grid, and determine the candidate grid with the shortest time as the target grid.

[0077] In this embodiment of the invention, the distance between the tracing starting point grid and the candidate grid in the horizontal axis direction, and the unit movement vector of the ray are used as the basis for the tracing. The time taken for the starting grid to reach the corresponding candidate grid in the horizontal direction is calculated. Similarly, the time taken for the starting grid to reach the corresponding candidate grid in the vertical direction and the time taken for the starting grid to reach the corresponding candidate grid in the number axis direction are calculated.

[0078] It should be understood that the time taken for the ray to reach each candidate grid from the starting grid reflects the order in which the ray arrives at the voxel boundary in the corresponding direction. The candidate grid corresponding to the minimum value is the target grid that the ray will actually enter.

[0079] Step S330: If the target mesh is a surface voxel mesh corresponding to a freeform surface, the first surface voxel mesh is determined as the injection mesh, and the second surface voxel mesh is determined as the ejection mesh.

[0080] In this embodiment of the invention, if the target mesh is a surface voxel mesh corresponding to a freeform surface, it means that the light has touched the freeform surface. At this time, the first surface voxel table encountered is recorded as the incident mesh. After finding the incident mesh, the coordinates of the incident mesh are changed to the new tracing starting mesh, and steps S310-330 are repeated to continue traversing along the direction of the incident light until the second surface voxel table is encountered, and the second surface voxel mesh encountered is determined as the exit mesh.

[0081] Step S340: If the target mesh is not the surface voxel mesh corresponding to the freeform surface, the target mesh is determined as the new tracing starting point mesh, and the traversal continues along the direction of the incident light until the incident mesh and the exit mesh are obtained.

[0082] In this embodiment of the invention, if the target mesh found this time does not belong to the surface voxel mesh corresponding to the freeform surface, the target mesh found this time is used as the new tracing starting point mesh, and steps S310-330 are repeated to continue traversing along the direction of the incident light until two surface voxel meshes are found successively.

[0083] As can be seen, the embodiments of the present invention, without needing to solve complex surface equations, use a voxel mesh discretization structure to efficiently approximate the actual intersection point of a free surface and a light ray by calculating time, comparing speeds, and skipping grids, thus reducing computational overhead while maintaining sufficient accuracy.

[0084] Alternatively, one possible implementation for generating the injection polynomial is provided below. Figure 1 The sub-steps of step S40 may include: Step S400: If the point cloud coordinates contained in the injected grid exceed the preset number, obtain the preset third-order polynomial.

[0085] In this embodiment of the invention, the point cloud coordinates contained in the injected mesh are obtained. If the point cloud coordinates contained in the injected mesh are greater than a preset number (e.g., 10), a preset third-order polynomial is obtained. The preset third-order polynomial is:

[0086] in, to These 10 coefficients are unknowns and need to be solved.

[0087] Step S410: Substitute the point cloud coordinates contained in the injection grid into the preset third-order polynomial, and solve the coefficients of the preset third-order polynomial by the least squares method to obtain the injection polynomial.

[0088] In this embodiment of the invention, the coordinates of each point cloud contained in the injection grid are substituted into a preset third-order polynomial to obtain the polynomial corresponding to each point cloud coordinate. The least squares method is then used to solve the polynomials corresponding to all point cloud coordinates contained in the injection grid, yielding the specific values ​​of 10 coefficients. These 10 coefficient values ​​are then substituted into the preset third-order polynomial to obtain the injection polynomial.

[0089] Step S420: If the point cloud coordinates contained in the injected grid do not exceed the preset number, obtain the preset second-order polynomial.

[0090] Step S430: Substitute the point cloud coordinates contained in the injection grid into the preset second-order polynomial, and solve the coefficients of the preset second-order polynomial by the least squares method to obtain the injection polynomial.

[0091] In this embodiment of the invention, if the point cloud coordinates contained in the injected mesh are not greater than a preset number (e.g., 10), a preset second-order polynomial is obtained. The preset second-order polynomial is:

[0092] in, to These six coefficients are unknowns and need to be solved.

[0093] Similarly, the coefficients of a pre-defined second-order polynomial are solved using the least squares method based on the point cloud coordinates contained in the injection mesh, thus obtaining the injection polynomial. Since the injection polynomial is generated based on the point cloud coordinates contained in the injection mesh, it can accurately represent the freeform surface where the injection point is located.

[0094] It should be understood that generating the emission polynomial based on the point cloud coordinates contained in the emission mesh includes: If the point cloud coordinates contained in the emitted grid exceed the preset number, obtain the preset third-order polynomial; Substitute the point cloud coordinates contained in the ejection grid into the preset third-order polynomial, and solve the coefficients of the preset third-order polynomial by the least squares method to obtain the ejection polynomial. If the point cloud coordinates contained in the emitted grid do not exceed the preset number, obtain the preset second-order polynomial; Substitute the point cloud coordinates contained in the ejection grid into a preset second-order polynomial, and solve the coefficients of the preset second-order polynomial using the least squares method to obtain the ejection polynomial.

[0095] As can be seen, the embodiments of the present invention dynamically select the polynomial order for surface fitting based on the number of point cloud coordinates contained in the incident or emitting mesh: when the number of point clouds is large, a preset third-order polynomial is used for fitting; when the number of point clouds is small, a preset second-order polynomial with a simpler structure and lighter computation is used. This approach of adaptively selecting a low-order polynomial according to the actual amount of data ensures that the fitting process always focuses on the local point cloud within a single voxel mesh. When processing multiple incident rays, to ensure the continuity of the normal of the fitted surface between adjacent voxel meshes, when generating the local polynomial corresponding to any surface voxel mesh, not only the point cloud coordinates contained in that mesh are used, but also all point cloud coordinates in adjacent voxel meshes that fall within a sphere centered at the current mesh's geometric center and with the voxel's side length as the radius are introduced to participate in least-squares fitting, thereby ensuring the continuity of the normal of the fitted freeform surface between adjacent voxel meshes. This reduces the requirements for computational resources and iteration stability, and can more realistically restore the geometric shape of the freeform surface in the local region, improving the ability to accurately describe the local morphology.

[0096] Alternatively, one possible implementation for generating the injection polynomial is provided below. Figure 1 The sub-steps of step S50 may include: Step S500: Establish the injection function based on the ray equation and the injection polynomial.

[0097] In this embodiment of the invention, based on the ray equation of the incident ray, the parametric equations of the incident ray in the three-axis directions can be obtained, that is, the parametric equation corresponding to the horizontal axis is... The parametric equation corresponding to the vertical axis is: The parametric equation corresponding to the vertical axis is: .

[0098] Assume the injection polynomial is , to light and y Substitution injection polynomial In this process, we obtain the height at which the light ray should theoretically fall on the freeform surface. And then, in conjunction with the actual light itself By taking the difference, we construct an injection function F that is only related to the time variable t. F The time corresponding to when this function's value is zero is precisely the moment when light actually enters the freeform surface.

[0099] Step S510: Iteratively solve the injection function, determine the injection time when the value of the injection function satisfies the convergence condition, and determine the injection coordinates based on the injection time and the ray equation.

[0100] In this embodiment of the invention, the injection function is solved iteratively, for example, by using Newton's iteration algorithm. Starting from an initial time, the iterative formula is repeatedly applied. The estimated value is updated, and at each step, it is rapidly approximated to zero using the current value and derivative of the injection function. Less than the preset convergence tolerance (e.g., 10) 11 If the value of the injection function satisfies the convergence condition, it is considered to be close enough to the true intersection point, and the corresponding time is determined as the injection time.

[0101] Next, by substituting the incident time into the ray equation, we can obtain the first spatial coordinates of the intersection between the incident ray and the freeform surface, which is the incident coordinate.

[0102] Step S520: Establish the emission function based on the ray equation and the emission polynomial.

[0103] Step S530: Iteratively solve the emission function, determine the time when the emission function satisfies the convergence condition as the emission time, and determine the emission coordinates based on the emission time and the ray equation.

[0104] In this embodiment of the invention, the exit coordinates are obtained in the same way as the injection coordinates.

[0105] As can be seen, in determining the injection coordinates and the injection coordinates, the embodiments of the present invention do not require fitting the entire freeform surface, nor do they rely on the design drawings or design parameters of the optical elements. They can achieve nanometer-level precision intersection positioning solely based on the measured point cloud.

[0106] Optionally, regarding how to construct a 3D voxel mesh, one possible implementation is provided below. Please refer to... Figure 2 ,exist Figure 1 Before step S10, it may also include: Step S01: Obtain the original coordinates of multiple point clouds of the freeform surface.

[0107] In this embodiment of the invention, a discrete set of original point cloud coordinates of the surface (i.e., freeform surface) of the optical element under test is obtained. It should be understood that freeform surfaces in actual measurements usually exist in the form of a large number of discrete three-dimensional coordinate points, which are called the original point cloud coordinates. The values ​​of each original point cloud coordinate (x, y, z) in the three directions may be negative, which is not conducive to the unified implementation of subsequent mesh generation and calculation logic.

[0108] Step S02: Move all the original point cloud coordinates as a whole to obtain the point cloud coordinates corresponding to each original point cloud coordinate; the point cloud coordinates are not negative in any of the three axes.

[0109] In this embodiment of the invention, when moving the original coordinates of the point cloud as a whole, it is necessary to first find the minimum values ​​of all the original coordinates of the point cloud in the x, y, and z axes, denoted as... , , Then construct an offset. By adding an offset to each original point cloud coordinate, a new set of point cloud coordinates is obtained. In this way, all point cloud coordinates have non-negative values ​​in the three axes, eliminating the interference caused by coordinate signs for subsequent spatial modeling.

[0110] Step S03: Construct the bounding box of the freeform surface based on all point cloud coordinates.

[0111] In this embodiment of the invention, based on this set of non-negative point cloud coordinates, the maximum spatial coverage area is further determined. That is, the maximum value in the three-axis directions is obtained from this set of point cloud coordinates, denoted as... , , Then, obtain the minimum value in each of the three axes from this set of point cloud coordinates; this is... , , Next, using and Eight vertices are generated by combining them, and then eight more vertices are used to construct the axial bounding box (AABB bounding box) of the freeform surface.

[0112] Step S04: Divide the bounding box into multiple voxel meshes according to the preset mesh size.

[0113] Step S05: Determine the voxel mesh containing point cloud coordinates as the surface voxel mesh corresponding to the freeform surface to obtain a three-dimensional voxel mesh.

[0114] In this embodiment of the invention, the bounding box of the freeform surface is uniformly divided into multiple small cubic units, i.e., voxel grids, according to a preset grid size (e.g., 1 mm × 1 mm × 1 mm).

[0115] The number of grid cells along the x-axis is: Similarly, we obtain and Ultimately forming a A three-dimensional zero matrix of size is used, meaning that the initial state of all voxel meshes is set to 2 (i.e., empty voxels). Finally, all point cloud coordinates are traversed, determining which voxel mesh each point falls into, and updating the corresponding matrix element from the initial 0 to 1, indicating that the voxel mesh contains point cloud coordinates. After the traversal is complete, a three-dimensional voxel mesh is obtained.

[0116] It should be noted that the voxel mesh containing point cloud coordinates is the same as the surface voxel mesh corresponding to the freeform surface. The point cloud coordinates contained in each surface voxel mesh will be stored for later review when generating the injection and exit polynomials.

[0117] Based on the same inventive concept, the basic principle and technical effects of the freeform surface ray tracing device provided in this embodiment are the same as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments.

[0118] Please refer to Figure 3 , Figure 3 This is a block diagram of a freeform surface ray tracing device 400 provided in an embodiment of the present invention. The freeform surface ray tracing device 400 includes an acquisition module 410, a processing module 420, and a generation module 430.

[0119] The acquisition module 410 is used to acquire the ray equation of the incident ray; the ray equation includes the coordinates of the ray's origin and the ray's unit movement vector.

[0120] The processing module 420 is used to determine whether the incident ray intersects the bounding box based on the ray origin coordinates, the ray unit movement vector, and the bounding box of the freeform surface. If the incident ray intersects the bounding box, the injection grid and the ejection grid are determined in the three-dimensional voxel grid of the freeform surface based on the ray origin coordinates and the ray unit movement vector. The three-dimensional voxel grid is generated based on the point cloud coordinates of the bounding box and the freeform surface.

[0121] The generation module 430 is used to generate an injection polynomial based on the point cloud coordinates contained in the injection grid, and to generate an exit polynomial based on the point cloud coordinates contained in the exit grid; both the injection polynomial and the exit polynomial are low-order polynomials; the injection coordinates and exit coordinates of the incident ray on the freeform surface are determined based on the ray equation, the injection polynomial and the exit polynomial.

[0122] In summary, the freeform surface ray tracing device provided in this embodiment of the invention abandons the traditional approach of describing the entire freeform surface with a single global function. Instead, it generates low-order incident and exit polynomials for the point cloud data contained in the two specific voxels through which the incident ray actually passes, respectively, thus achieving truly on-demand local modeling. The entire process uses the discrete point cloud coordinates of the freeform surface as the only input, without requiring any pre-set analytical equation model or relying on the original design parameters of the optical elements.

[0123] No matter how complex the freeform surface, only a few voxel meshes that the light actually passes through need to be processed. Low-order polynomials can accurately characterize its local geometry. Then, by simultaneously solving the ray equation of the incident ray with these two local polynomials, the incident and exit coordinates of the light ray on the freeform surface can be accurately determined, with errors consistently controlled at the nanometer level. Because it is completely independent of the original design parameters, it can effectively support the independent development of domestically produced optical software.

[0124] Optionally, the processing module 420 is specifically used to determine the time of entering the bounding box and the time of exiting the bounding box based on the coordinates of the ray's starting point, the ray's unit movement vector, and the bounding box of the freeform surface; if the time of entering the bounding box does not exceed the time of exiting the bounding box and the time of exiting the bounding box is greater than zero, it is determined that the incident ray intersects the bounding box; if the time of entering the bounding box exceeds the time of exiting the bounding box or the time of exiting the bounding box is not greater than zero, it is determined that the incident ray does not intersect the bounding box.

[0125] Optionally, the processing module 420 is specifically used to determine the horizontal axis entry time, vertical axis entry time, horizontal axis exit time, vertical axis exit time, and vertical axis exit time based on the bounding box, the ray origin coordinates, and the ray unit movement vector; to determine the maximum value among the horizontal axis entry time, vertical axis entry time, and vertical axis entry time as the time to enter the bounding box; and to determine the minimum value among the horizontal axis exit time, vertical axis exit time, and vertical axis exit time as the time to exit the bounding box.

[0126] Optionally, the processing module 420 is specifically used to determine the tracing start grid based on the incident intersection point of the incident ray and the bounding box; determine three candidate grids adjacent to the tracing start grid in the three-dimensional voxel grid based on the tracing start grid and the unit movement vector of the ray; calculate the time taken for the tracing start grid to reach each candidate grid, and determine the candidate grid with the shortest time as the target grid; If the target mesh is a surface voxel mesh corresponding to a freeform surface, the first surface voxel mesh is determined as the incident mesh, and the second surface voxel mesh is determined as the exit mesh; if the target mesh is not a surface voxel mesh corresponding to a freeform surface, the target mesh is determined as the new tracing starting point mesh, and the traversal continues along the direction of the incident light until the incident mesh and the exit mesh are obtained.

[0127] Optionally, the generation module 430 is specifically used to: if the point cloud coordinates contained in the injected mesh exceed a preset number, obtain a preset third-order polynomial; substitute the point cloud coordinates contained in the injected mesh into the preset third-order polynomial, and solve the coefficients of the preset third-order polynomial using the least squares method to obtain the injected polynomial; if the point cloud coordinates contained in the injected mesh do not exceed a preset number, obtain a preset second-order polynomial; substitute the point cloud coordinates contained in the injected mesh into the preset second-order polynomial, and solve the coefficients of the preset second-order polynomial using the least squares method to obtain the injected polynomial.

[0128] Optionally, the generation module 430 is specifically used to establish an injection function based on the ray equation and the injection polynomial; to iteratively solve the injection function, and to determine the injection time when the value of the injection function satisfies the convergence condition, and to determine the injection coordinates based on the injection time and the ray equation; to establish an emission function based on the ray equation and the emission polynomial; to iteratively solve the emission function, and to determine the emission time when the value of the emission function satisfies the convergence condition, and to determine the emission coordinates based on the emission time and the ray equation.

[0129] Optionally, the processing module 420 is also used to obtain multiple point cloud original coordinates of the freeform surface; to move all the point cloud original coordinates as a whole to obtain the point cloud coordinates corresponding to each point cloud original coordinate; the point cloud coordinates are all non-negative in the three axes; to construct the bounding box of the freeform surface based on all the point cloud coordinates; to divide the bounding box into multiple voxel meshes according to a preset mesh size; and to determine the voxel mesh containing the point cloud coordinates as the surface voxel mesh corresponding to the freeform surface to obtain a three-dimensional voxel mesh.

[0130] Please refer to Figure 4This is a block diagram illustrating an electronic device 500 provided in an embodiment of the present invention. The electronic device 500 includes, but is not limited to, a personal computer (PC), a personal digital assistant (PDA), a laptop computer, a tablet computer, and a server. The electronic device 500 includes a memory 510, a processor 520, and a communication module 530. The memory 510, processor 520, and communication module 530 are electrically connected directly or indirectly to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.

[0131] The memory 510 is used to store programs or data. The memory 510 may be, but is not limited to, random access memory, read-only memory, programmable read-only memory, erasable read-only memory, electrically erasable read-only memory, etc.

[0132] The processor 520 is used to read / write data or programs stored in the memory 510 and perform corresponding functions. For example, when a computer program stored in the memory 510 is executed by the processor 520, the freeform surface ray tracing method disclosed in the above embodiments can be implemented.

[0133] The communication module 530 is used to establish a communication connection between the electronic device 500 and other communication terminals via a network, and to send and receive data via the network.

[0134] It should be understood that, Figure 4 The structure shown is only a schematic diagram of the electronic device 500. The electronic device 500 may also include components that are larger than those shown. Figure 4 The more or fewer components shown, or having the same Figure 4 The different configurations shown. Figure 4 The components shown can be implemented using hardware, software, or a combination thereof.

[0135] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor 520, implements the freeform surface ray tracing method disclosed in the above embodiments.

[0136] This invention also provides a program product that, when executed by processor 520, implements the freeform surface ray tracing method disclosed in the above embodiments.

[0137] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0138] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0139] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0140] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for ray tracing on freeform surfaces, characterized in that, The method includes: Obtain the equation of the incident ray; the equation includes the coordinates of the ray's origin and the ray's unit movement vector; Determine whether the incident ray intersects the bounding box based on the coordinates of the ray's origin, the ray's unit movement vector, and the bounding box of the freeform surface; If the incident ray intersects the bounding box, the incident mesh and the exit mesh are determined in the three-dimensional voxel mesh of the freeform surface based on the ray origin coordinates and the ray unit movement vector; the three-dimensional voxel mesh is generated based on the point cloud coordinates of the bounding box and the freeform surface. An injection polynomial is generated based on the point cloud coordinates contained in the injection grid, and an exit polynomial is generated based on the point cloud coordinates contained in the exit grid; both the injection polynomial and the exit polynomial are low-order polynomials. The incident coordinates and exit coordinates of the incident ray on the freeform surface are determined based on the ray equation, the incident polynomial, and the exit polynomial.

2. The freeform surface ray tracing method according to claim 1, characterized in that, The step of determining whether the incident ray intersects the bounding box based on the ray origin coordinates, the ray unit movement vector, and the bounding box of the freeform surface includes: The entry time into the bounding box and the exit time from the bounding box are determined based on the coordinates of the ray origin, the unit movement vector of the ray, and the bounding box of the freeform surface. If the time of entering the bounding box does not exceed the time of exiting the bounding box and the time of exiting the bounding box is greater than zero, it is determined that the incident ray intersects with the bounding box; If the time for the incident ray to enter the bounding box exceeds the time for the ray to exit the bounding box, or if the time for the ray to exit the bounding box is not greater than zero, it is determined that the incident ray does not intersect the bounding box.

3. The freeform surface ray tracing method according to claim 2, characterized in that, The step of determining the entry and exit times of the bounding box based on the ray origin coordinates, the ray unit movement vector, and the bounding box of the freeform surface includes: The horizontal axis entry time, vertical axis entry time, vertical axis entry time, horizontal axis exit time, vertical axis exit time, and vertical axis exit time are determined based on the bounding box, the coordinates of the ray origin, and the ray unit movement vector. The maximum value among the horizontal axis entry time, the vertical axis entry time, and the vertical axis entry time is determined as the injection time into the bounding box. The minimum value among the horizontal axis departure time, the vertical axis departure time, and the vertical axis departure time is determined as the ejection bounding box time.

4. The freeform surface ray tracing method according to claim 1, characterized in that, The step of determining the injection and exit meshes in the three-dimensional voxel mesh of the freeform surface based on the ray origin coordinates and the ray unit movement vector includes: The tracing start point grid is determined based on the intersection point of the incident ray and the bounding box; Based on the tracing start grid and the ray unit movement vector, three candidate grids adjacent to the tracing start grid are determined in the three-dimensional voxel grid; Calculate the time taken for the starting grid to reach each of the candidate grids, and determine the candidate grid with the shortest time as the target grid; If the target mesh is the surface voxel mesh corresponding to the freeform surface, the first surface voxel mesh is determined as the injection mesh, and the second surface voxel mesh is determined as the ejection mesh; If the target mesh is not the surface voxel mesh corresponding to the freeform surface, the target mesh is determined as the new tracing starting point mesh, and the traversal continues along the direction of the incident light until the incident mesh and the exit mesh are obtained.

5. The freeform surface ray tracing method according to claim 1, characterized in that, The step of generating the injection polynomial based on the point cloud coordinates contained in the injection mesh includes: If the point cloud coordinates contained in the injected mesh exceed a preset number, obtain a preset third-order polynomial; Substitute the point cloud coordinates contained in the injection grid into the preset third-order polynomial, and solve the coefficients of the preset third-order polynomial by the least squares method to obtain the injection polynomial. If the point cloud coordinates contained in the injected mesh do not exceed a preset number, obtain a preset second-order polynomial; Substitute the point cloud coordinates contained in the injection mesh into the preset second-order polynomial, and solve the coefficients of the preset second-order polynomial by the least squares method to obtain the injection polynomial.

6. The freeform surface ray tracing method according to claim 1, characterized in that, Determining the incident coordinates and exit coordinates of the incident ray on the freeform surface based on the ray equation, the incident polynomial, and the exit polynomial includes: Establish the injection function based on the ray equation and the injection polynomial; The injection function is iteratively solved, and the time corresponding to when the value of the injection function satisfies the convergence condition is determined as the injection time. The injection coordinates are determined based on the injection time and the ray equation. Establish the emission function based on the ray equation and the emission polynomial; The emission function is iteratively solved, and the time corresponding to when the value of the emission function satisfies the convergence condition is determined as the emission time. The emission coordinates are then determined based on the emission time and the ray equation.

7. The freeform surface ray tracing method according to claim 1, characterized in that, Before obtaining the equation of the incident ray, the following is also included: Obtain the original coordinates of multiple point clouds on the freeform surface; The original coordinates of all the points cloud are moved as a whole to obtain the point cloud coordinates corresponding to each of the original point cloud coordinates; the values ​​of the point cloud coordinates in the three axes are all non-negative. Construct the bounding box of the freeform surface based on all the point cloud coordinates; The bounding box is divided into multiple voxel grids according to a preset grid size; The voxel mesh containing the point cloud coordinates is determined as the surface voxel mesh corresponding to the freeform surface, thus obtaining the three-dimensional voxel mesh.

8. A freeform surface ray tracing device, characterized in that, The device includes: The acquisition module is used to acquire the ray equation of the incident ray; the ray equation includes the coordinates of the ray's origin and the ray's unit movement vector; The processing module is used to determine whether the incident ray intersects the bounding box based on the ray origin coordinates, the ray unit movement vector, and the bounding box of the freeform surface; if the incident ray intersects the bounding box, it determines the injection grid and the exit grid in the three-dimensional voxel grid of the freeform surface based on the ray origin coordinates and the ray unit movement vector; the three-dimensional voxel grid is generated based on the point cloud coordinates of the bounding box and the freeform surface; A generation module is used to generate an injection polynomial based on the point cloud coordinates contained in the injection grid, and to generate an exit polynomial based on the point cloud coordinates contained in the exit grid; both the injection polynomial and the exit polynomial are low-order polynomials; the injection coordinates and exit coordinates of the incident ray on the freeform surface are determined based on the ray equation, the injection polynomial, and the exit polynomial.

9. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a computer program that can be executed by the processor to implement the freeform surface ray tracing method according to any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the freeform surface ray tracing method as described in any one of claims 1-7.