An octree-based digital twin scene crowd interaction space indexing method and system

By using an octree-based spatial indexing method, the problem of real-time simulation of large-scale crowd interaction scenarios in complex three-dimensional space was solved, achieving efficient three-dimensional space management and accurate simulation results.

CN122132415APending Publication Date: 2026-06-02SHENZHEN UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN UNIV
Filing Date
2026-04-30
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing technologies struggle to support real-time simulation of large-scale crowd interaction scenarios, especially in complex three-dimensional spaces where computational complexity is high and vertical relationships, terrain undulations, and dynamic occlusion effects cannot be accurately handled, leading to distorted simulation results.

Method used

An octree-based spatial indexing method is adopted, which constructs a three-dimensional spatial index through an octree spatial partitioning algorithm. Combined with point and axis-aligned bounding box and sphere intersection test algorithms, it enables efficient management and querying of three-dimensional spatial crowd interaction data.

Benefits of technology

It enables the natural expression and efficient management of interactive data of people in three-dimensional space, improving computational efficiency and the realism of simulation results, especially the simulation accuracy in complex three-dimensional scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122132415A_ABST
    Figure CN122132415A_ABST
Patent Text Reader

Abstract

This invention belongs to the field of image processing technology and discloses a method and system for indexing the spatial interaction of crowds in a digital twin scene based on an octree. The method includes: determining a target three-dimensional space containing pedestrian data; constructing an octree corresponding to the target three-dimensional space based on an octree spatial partitioning algorithm; wherein the root node of the octree is the target three-dimensional space, and the leaf nodes are the smallest three-dimensional spaces partitioned in the octree; responding to a spatial query request, recursively traversing all nodes of the octree based on an intersection test algorithm to obtain leaf nodes that meet preset query conditions; merging the pedestrian data stored in the obtained leaf nodes, and outputting a set of potential interactive objects based on the merged result. This invention utilizes the recursive subdivision capability of the octree in three-dimensional space, and integrates intersection test algorithms for three basic geometric shapes: points, axis-aligned bounding boxes, and spheres, to achieve natural expression and efficient management of three-dimensional spatial crowd interaction data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of digital twin city technology, and in particular to a method and system for indexing the spatial interaction of people in a digital twin scene based on an octree. Background Technology

[0002] With the development of intelligent transportation systems and digital twin cities, the demand for high-precision, low-latency perception and management of dynamic entities in three-dimensional space, such as vehicles, pedestrians, and non-motorized vehicles, is becoming increasingly urgent.

[0003] Pedestrian simulation technology, by constructing mathematical models to simulate the movement patterns of crowds, has become a core supporting tool in fields such as public management, architectural design optimization, and emergency evacuation plan development. Currently, pedestrian simulation scenarios are evolving from the traditional two-dimensional plane to three-dimensional space, such as conducting detailed simulations of pedestrian flow at multi-level interchanges, large-scale integrated transportation hubs, and even at the city-wide scale; this trend places unprecedented demands on the computational efficiency and scene realism of simulation technology.

[0004] High-fidelity simulation of large-scale crowd interactions is crucial for ensuring the close alignment between digital twin scenarios and the physical world. Existing technologies, such as 2D mesh partitioning, quadtree indexing, and KD-tree indexing, are ill-suited to the complex 3D spatial characteristics and large-scale concurrency requirements of digital twins, exhibiting significant limitations. Specifically, on the one hand, existing pedestrian interaction models often employ global traversal or uniform mesh partitioning methods for selecting interaction objects, resulting in a quadratic increase in computational complexity with the number of pedestrians, making it difficult to support real-time simulations of thousands or more people. On the other hand, existing methods are largely based on 2D planar assumptions, failing to accurately handle vertical relationships, terrain undulations, floor separation, and dynamic occlusion effects in 3D space, leading to distortion in simulation results in complex 3D scenes such as multi-story buildings, sloping terrain, and indoor-outdoor blending environments.

[0005] Existing technologies still have the problem that pedestrian interaction models cannot support real-time simulation of scenarios with large-scale concurrent demands. Therefore, existing technologies need to be improved. Summary of the Invention

[0006] The technical problem to be solved by the present invention is to provide a digital twin scene crowd interaction space indexing method and system based on octree, in order to solve the problem that existing pedestrian interaction models are difficult to support real-time simulation of large-scale concurrent demand scenarios.

[0007] The technical solution adopted by this invention to solve the technical problem is as follows: In a first aspect, the present invention provides a method for indexing the spatial interaction of people in a digital twin scene based on an octree, including: Determine the target three-dimensional space and acquire pedestrian data in the target three-dimensional space; An octree corresponding to the target three-dimensional space is constructed based on an octree space partitioning algorithm; wherein, the root node of the octree is the target three-dimensional space, and the leaf nodes are the smallest three-dimensional spaces partitioned in the octree; In response to a spatial query request, the system recursively traverses all nodes of the octree based on an intersection test algorithm to obtain leaf nodes that meet the preset query conditions. The pedestrian data stored in the leaf nodes are merged, and the result is output as a set of potential interactive objects.

[0008] In one implementation, constructing the octree corresponding to the target three-dimensional space based on the octree space partitioning algorithm includes: The target three-dimensional space is segmented based on the octree space partitioning algorithm, and the root node and the child nodes generated in each segmentation are used as the parent node. All the parent nodes are divided, and each division generates eight child nodes of the parent nodes; When the generated child node meets the preset termination condition, the splitting of the current child node is terminated, and the current child node is taken as a leaf node. When all generated child nodes meet the preset termination condition, the segmentation of the target three-dimensional space is terminated, and an octree of the target three-dimensional space is obtained.

[0009] In one implementation, the preset termination condition includes: The number of pedestrian data in the generated child nodes meets the preset pedestrian data threshold. Or the depth of the generated child nodes reaches a preset depth threshold.

[0010] In one implementation, the step of splitting all the parent nodes, with each split generating eight child nodes for each parent node, includes: Determine the X-axis, Y-axis, and Z-axis of the three-dimensional space; The three-dimensional space corresponding to the parent node is uniformly divided into eight child nodes along the X-axis, Y-axis, and Z-axis.

[0011] In one implementation, the intersection test algorithm includes: The intersection test algorithm between points and volumes is used to determine whether a target 3D coordinate point is located within the volume of a target octree node; An intersection test algorithm between axis-aligned bounding boxes and volumes is used to determine and filter out all octree nodes that overlap with the axis-aligned bounding boxes. The intersection test algorithm between the sphere and the volume is used to find all octree nodes within a preset radius from the target point.

[0012] In one implementation, the response space query request recursively traverses all nodes of the octree based on an intersection test algorithm to obtain leaf nodes that satisfy preset query conditions, including: Determine the intersection test algorithm corresponding to the spatial query request; All nodes of the octree are traversed recursively, and an intersection test is performed on the current node of each traversal based on a determined intersection test algorithm. If the current node being traversed fails the intersection test, skip the current node. If the current node passes the intersection test, determine the node type of the current node; if the node type of the current node is a non-leaf node, continue traversing the current node; if the node type of the current node is a leaf node, stop traversing the current node.

[0013] In one implementation, the step of determining the intersection test algorithm corresponding to the spatial query request includes: Determine the query type of the spatial query request; wherein the query type includes point query, region query, and range query; When the query type is a point query, the intersection test algorithm between the point and the volume is executed; When the query type is a region query, the intersection test algorithm between the axis-aligned bounding box and the volume is executed; When the query type is a range query, the intersection test algorithm between the sphere and the volume is executed.

[0014] Secondly, the present invention provides a digital twin scene crowd interaction space indexing system based on an octree, comprising: The spatial determination module is used to determine the target three-dimensional space containing pedestrian data; The spatial segmentation module is used to construct an octree corresponding to the target three-dimensional space based on the octree spatial partitioning algorithm; wherein the root node of the octree is the target three-dimensional space, and the leaf nodes are the smallest three-dimensional spaces segmented in the octree; The node query module is used to respond to spatial query requests. Based on the intersection test algorithm, it recursively traverses all nodes of the octree to obtain leaf nodes that meet the preset query conditions. The results output module is used to merge the pedestrian data stored in the acquired leaf nodes and output a set of potential interactive objects based on the merged results.

[0015] Thirdly, the present invention provides a terminal, comprising: a processor and a memory, wherein the memory stores an octree-based digital twin scene crowd interaction space indexing program, and the octree-based digital twin scene crowd interaction space indexing program, when executed by the processor, is used to implement the operation of the octree-based digital twin scene crowd interaction space indexing method as described in the first aspect.

[0016] Fourthly, the present invention also provides a computer-readable storage medium storing an octree-based digital twin scene crowd interaction space indexing program, which, when executed by a processor, is used to implement the operation of the octree-based digital twin scene crowd interaction space indexing method as described in the first aspect.

[0017] The present invention, by employing the above technical solution, has the following effects: This invention provides a digital twin scene crowd interaction space indexing method and system based on octrees, comprising: determining a target three-dimensional space containing pedestrian data; constructing an octree corresponding to the target three-dimensional space based on an octree space partitioning algorithm; wherein the root node of the octree is the target three-dimensional space, and the leaf nodes are the smallest three-dimensional spaces partitioned in the octree; responding to a space query request, recursively traversing all nodes of the octree based on an intersection test algorithm to obtain leaf nodes that meet preset query conditions; merging the pedestrian data stored in the obtained leaf nodes, and outputting a set of potential interactive objects based on the merging result; this invention can utilize the recursive subdivision capability of octrees in three-dimensional space, and integrate intersection test algorithms for three basic geometric shapes: points, axis-aligned bounding boxes, and spheres, to achieve natural expression and efficient management of three-dimensional space crowd interaction data. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.

[0019] Figure 1 This is a flowchart of the digital twin scene crowd interaction space indexing method based on octree in this invention.

[0020] Figure 2 This is a flowchart of a method for partitioning a target three-dimensional space based on an octree space algorithm in one implementation of the present invention.

[0021] Figure 3This is a flowchart of a method for obtaining leaf nodes that meet preset query conditions based on an intersection test algorithm in one implementation of the present invention.

[0022] Figure 4 This is a functional schematic diagram of the terminal in one implementation of the present invention.

[0023] The objectives, features, and advantages of this invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0024] To make the objectives, technical solutions, and advantages of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0025] Exemplary methods High-fidelity simulation of large-scale crowd interactions is crucial for ensuring the close alignment between digital twin scenarios and the physical world. Existing technologies struggle to adapt to the complex three-dimensional spatial characteristics and large-scale concurrency requirements of digital twins, exhibiting significant shortcomings. Specifically, on the one hand, existing pedestrian interaction models often employ global traversal or uniform grid partitioning methods for selecting interaction objects, resulting in computational complexity increasing quadratically with the number of pedestrians, making it difficult to support real-time simulations of thousands or more people. On the other hand, existing methods are largely based on two-dimensional planar assumptions, failing to accurately handle vertical relationships, terrain undulations, floor separation, and dynamic occlusion effects in three-dimensional space, leading to distortion in simulation results in complex three-dimensional scenes such as multi-story buildings, sloping terrain, and indoor-outdoor blending environments.

[0026] In existing technologies, the two-dimensional grid spatial partitioning method is the most commonly used optimization method for social force models. It is widely used in evacuation simulation scenarios with low spatial complexity, such as subway stations and stadiums. Its core idea is to divide the simulation two-dimensional plane into uniform grid cells. Each pedestrian only needs to interact with other pedestrians in the same cell and adjacent cells. By using a pre-set grid of fixed size, the global O(n) time complexity can be reduced. 2 The computational complexity is reduced to local computation, and the complexity depends on the average number of pedestrians within the grid.

[0027] The quadtree indexing method, as an improvement on the two-dimensional mesh method, recursively divides the two-dimensional space into four rectangular sub-regions, achieving adaptive subdivision. Compared to the two-dimensional mesh space partitioning method with a fixed mesh size, quadtrees allow for dynamic adjustment of the region partitioning granularity based on the density of pedestrian distribution. More refined partitioning is performed in densely populated areas, while larger nodes are maintained in sparse areas, thus allocating computational resources more efficiently. This method is suitable for simulating large-scale two-dimensional scenes with uneven pedestrian distribution, but its essence remains a two-dimensional spatial indexing structure and cannot be directly applied to three-dimensional scenes with height differences.

[0028] The KD-tree (K-Dimensional Tree) indexing method utilizes a binary tree structure designed for high-dimensional space retrieval, which can also be used for organizing and querying points in three-dimensional space. Each time, a KD-tree recursively selects a spatial axis, such as the X, Y, or Z axis, and splits the space into two half-spaces at the median point of that axis. This method excels at nearest neighbor search for static point sets and is often used in computer graphics to accelerate static scenes such as ray tracing. However, to maintain the balance of the tree structure, the KD-tree indexing method requires frequent reconstruction or complex rotation operations when the object's position is dynamically updated, such as when a pedestrian is continuously moving. Therefore, the maintenance overhead is significant in dynamic simulation scenes, making it difficult to guarantee real-time performance.

[0029] Existing technologies still have the problem that pedestrian interaction models cannot support real-time simulation of scenarios with large-scale concurrent demands. Therefore, existing technologies need to be improved.

[0030] To address the above technical problems, this invention provides a digital twin scene crowd interaction space indexing method based on an octree, comprising: determining a target three-dimensional space containing pedestrian data; constructing an octree corresponding to the target three-dimensional space based on an octree space partitioning algorithm; wherein the root node of the octree is the target three-dimensional space, and the leaf nodes are the smallest three-dimensional spaces partitioned in the octree; responding to a space query request, recursively traversing all nodes of the octree based on an intersection test algorithm to obtain leaf nodes that meet preset query conditions; merging the pedestrian data stored in the obtained leaf nodes, and outputting a set of potential interactive objects based on the merging result; this invention can utilize the recursive subdivision capability of the octree in three-dimensional space, and integrate intersection test algorithms for three basic geometric shapes: points, axis-aligned bounding boxes, and spheres, to achieve natural expression and efficient management of three-dimensional space crowd interaction data.

[0031] like Figure 1 As shown, this embodiment of the invention provides a method for indexing the interaction space of a digital twin scene based on an octree, comprising the following steps: Step S100: Determine the target three-dimensional space and obtain pedestrian data in the target three-dimensional space.

[0032] In this embodiment, the target area to be simulated for large-scale crowd interaction is determined. The target area is the target three-dimensional space, which is the three-dimensional space in the digital twin scene. It can be the three-dimensional space of a multi-story building, sloping terrain, indoor-outdoor integrated environment, etc.

[0033] It should be noted that in the context of digital twins, when calculating and extrapolating the spatiotemporal distribution of pedestrian groups, for each individual in the pedestrian group, it is necessary to clarify their spatial relative relationship with other individuals in order to continue to define and calculate their attributes such as physical compression and group interaction.

[0034] In this embodiment, pedestrian data in the target three-dimensional space is acquired. The pedestrian data refers to the spatial relationships between pedestrians at different heights and on different terrains in a three-dimensional traffic scene. For example, pedestrian data is the real-time spatiotemporal distribution data of a group of pedestrians, which includes at least the three-dimensional coordinates, movement speed, and movement direction of the pedestrians.

[0035] In this embodiment, it is first necessary to determine the X-axis, Y-axis and Z-axis of the three-dimensional space, and to determine the spatial range of the target three-dimensional space. Specifically, the spatial range of the three-dimensional space is defined by the center point O and the size S of the three-dimensional space.

[0036] like Figure 1 As shown, this embodiment of the invention provides a method for indexing the interaction space of a digital twin scene based on an octree, comprising the following steps: Step S200: Construct an octree corresponding to the target three-dimensional space based on the octree space partitioning algorithm; wherein the root node of the octree is the target three-dimensional space, and the leaf nodes are the smallest three-dimensional spaces partitioned in the octree.

[0037] like Figure 2 The diagram shows a flowchart of the method for partitioning the target 3D space based on the octree space algorithm in this embodiment. The octree space partitioning algorithm is used to segment the target 3D space. The octree space partitioning algorithm is performed recursively. Each segmentation is performed along the X-axis, the Y-axis and the Z-axis, and the 3D space corresponding to the parent node is evenly divided into eight child nodes. Each child node corresponds to a quadrant of the parent node in the 3D space. The segmentation of the child nodes stops when the segmented child nodes meet the preset termination condition. The segmentation of the target 3D space is terminated when all child nodes meet the preset termination condition.

[0038] In this embodiment, the octree space partitioning algorithm adopts a strategy that combines generics and object-oriented approaches. The Octtree class serves as the core controller, inheriting from the general root node base class. It is responsible for managing the lifecycle of the tree and providing query interfaces to the outside world. The space partitioning logic is encapsulated in VolumeSplitter, which achieves uniform space cutting.

[0039] Specifically, in one implementation of this embodiment, step S200 includes the following steps: Step S201: The target three-dimensional space is segmented based on the octree space partitioning algorithm, and the root node and the child nodes generated in each segmentation are taken as the parent node.

[0040] In this embodiment, the target three-dimensional space is segmented based on the octree space partitioning algorithm. The octree space partitioning algorithm segments the target three-dimensional space in a recursive form and with a uniform partitioning strategy. The node to be segmented in each segment is taken as the parent node. The first segmentation of the target three-dimensional space takes the root node as the parent node, and the parent node of each subsequent segmentation is the child node generated in the previous segmentation.

[0041] Step S202: Divide all the parent nodes, and generate eight child nodes for each parent node in each division.

[0042] In this embodiment, each segmentation is performed along the X-axis, Y-axis, and Z-axis, uniformly dividing the three-dimensional space corresponding to the parent node into eight child nodes, with each child node corresponding to a quadrant of the parent node in the three-dimensional space.

[0043] Taking the root node as an example, the target's three-dimensional space center corresponding to the root node is O, and its size is S. First, calculate the sub-volume size of the child nodes generated by segmenting the root node. When the three-dimensional space is uniformly divided into eight child nodes, the volume is the same as the original volume. Then the child volume size is half the parent volume size. Specifically, the child volume size... The calculation formula is as follows: ; Then, the offset from the parent volume to the child center is calculated. The corresponding formula is as follows: ; Furthermore, by applying the offsets to the positive and negative directions of the three axes respectively, the center coordinates of the eight child nodes are calculated, and the parent volume center is defined as... Then the center coordinates of the child node It can be represented as: ; in, , represents the Hadamard product (multiplication of corresponding components). The direction sign vector takes eight possible values: (1, 1, 1), (-1, 1, 1)...(-1, -1, -1), corresponding to the sign of the vector in the eight quadrants formed by the X, Y, and Z axes.

[0044] Step S203: When the generated child node meets the preset termination condition, terminate the splitting of the current child node and treat the current child node as a leaf node.

[0045] In this embodiment, the preset termination condition includes: the number of pedestrian data in the generated child node meets the preset pedestrian data threshold; or the depth of the generated child node reaches the preset depth threshold.

[0046] Specifically, when the number of pedestrian data in the generated child node meets the preset pedestrian data threshold, the segmentation of the current child node is terminated, and the current child node is taken as a leaf node. If the number of pedestrian data in the generated child node does not meet the preset pedestrian data threshold, but the depth of the current child node reaches the preset depth threshold, the segmentation of the current child node is terminated, and the current child node is treated as a leaf node.

[0047] In this embodiment, the threshold setting for the preset termination condition is determined based on the size of the target three-dimensional space. For example, for various general digital twin three-dimensional scenes that include multi-story buildings, sloping terrain, and indoor-outdoor blended environments, the minimum spatial volume threshold of the target three-dimensional space is set to... The reference target's three-dimensional spatial dimensions are The corresponding pedestrian data threshold is 10, meaning that when the number of pedestrian data in a child node is less than 10, the current child node is treated as a leaf node.

[0048] In this embodiment, the preset depth threshold is set to 6 layers, meaning that during spatial segmentation, if the generated child node space volume is greater than 6 layers, the threshold will be lower than 6 layers. However, if the depth of the child node segmentation has reached 6 levels, then the segmentation of the current child node is terminated, and the current child node is designated as a leaf node.

[0049] In one implementation of the embodiment, the preset termination condition further includes: when the number of iterations corresponding to the current child node reaches the maximum number of iterations threshold, terminating the segmentation of the current child node and treating the current child node as a leaf node.

[0050] In this embodiment, for each child node marked as a leaf node, it is necessary to store all pedestrian data in the current child node, that is, all pedestrian data in the three-dimensional space corresponding to the child node.

[0051] Step S204: When all generated child nodes meet the preset termination condition, terminate the segmentation of the target three-dimensional space to obtain the octree of the target three-dimensional space.

[0052] In this embodiment, when all generated child nodes meet the preset termination condition, the segmentation of the target three-dimensional space is terminated, thereby obtaining an octree of the target three-dimensional space. The root node of the octree is the target three-dimensional space, and the leaf nodes are the smallest three-dimensional spaces segmented in the octree. The number of pedestrian data in each leaf node meets the preset pedestrian data threshold.

[0053] In one implementation of this embodiment, after a child node that has reached a preset depth is marked as a leaf node, if the number of pedestrian data in the leaf node does not meet the preset pedestrian data threshold, the pedestrian data in the node is directly stored.

[0054] In one implementation of this embodiment, the segmentation of the target 3D space based on the octree space partitioning algorithm can also use a non-uniform segmentation strategy. For example, segmentation can be based on the centroid of all pedestrian positions within the current node or the median along a specific coordinate axis. This scheme may generate node partitions that better fit the object distribution, but its computational complexity is high.

[0055] Furthermore, the triggering condition for the octree space partitioning algorithm in this embodiment can also be adjusted. For example, the overall density of the space contained in the node or a preset fixed depth threshold can be used as the recursion termination condition, rather than relying entirely on the absolute number of objects within the node.

[0056] In this embodiment, an octree-based spatial partitioning algorithm is used to construct the octree corresponding to the target three-dimensional space. This algorithm can dynamically adjust the node depth according to pedestrian density and express the topological relationship of the three-dimensional space through node encoding, thus solving the problem that traditional two-dimensional models cannot distinguish pedestrians on different floors.

[0057] like Figure 1 As shown, this embodiment of the invention provides a method for indexing the interaction space of a digital twin scene based on an octree, comprising the following steps: Step S300: In response to the space query request, traverse all nodes of the octree recursively based on the intersection test algorithm to obtain the leaf nodes that meet the preset query conditions.

[0058] In this embodiment, the intersection testing algorithm includes: a point-volume intersection testing algorithm, an axis-aligned bounding box-volume intersection testing algorithm, and a sphere-volume intersection testing algorithm. The three types of intersection testing algorithms define three different geometric shapes, specifically: Point, Box (Axis Aligned Bounding Box, AABB), and Sphere. Based on the above three types of intersection testing algorithms, the intersection test between these three geometric shapes and the node volumes in the octree is implemented, enabling the system to efficiently perform spatial query operations such as "finding the leaf node where a point is located", "finding all leaf nodes that overlap with a specific bounding box", and "finding leaf nodes located within a specific sphere".

[0059] The point-volume intersection test algorithm is used to determine whether a target 3D coordinate point is located within the volume of a target octree node. This algorithm is based on a spatial inclusion test, which determines the inclusion relationship by comparing the coordinates of a point with the boundary range of the volume. If the X-axis, Y-axis, and Z-axis coordinates of a point are all located between the minimum and maximum boundaries corresponding to the volume, then the point is determined to be within the volume.

[0060] Specifically, the query point that the spatial query request needs to query is defined as follows: This query point That is, the target's three-dimensional coordinates, with its volume center being... The volume dimensions are Then the half-size vector of the target 3D point Defined as: ; Using the following criteria, a target 3D point passes the intersection test corresponding to the intersection test algorithm between the point and the volume if and only if the following set of inequalities are simultaneously true, i.e., the intersection test returns true: ; in, , and Center of volume 3D coordinates; , and Half-size vector 3D coordinates; , and For query point The three-dimensional coordinates.

[0061] The intersection test algorithm between axis-aligned bounding boxes and volumes is used to identify and filter all octree nodes that overlap with the axis-aligned bounding boxes. The intersection test corresponding to this algorithm is a simplified version based on the separation axis alignment. For axis alignment, when two axis-aligned cubes intersect, it means that their projection intervals on the X, Y, and Z axes overlap. In other words, when the query box intersects with the octree node volume, their projection intervals on the X, Y, and Z axes overlap.

[0062] Specifically, first calculate the minimum boundary of the query box. and maximum boundary And the boundary range of the node volume, and then compare the intervals of the two axis by axis to see if they are separated. Let the center of the query box be... The size is The center of the node volume is ,size Calculate their respective half-size vectors, we have: ; .

[0063] Furthermore, the boundary interval of the query box is The boundary interval of the node volume is The condition for their intersection is that the intervals along the three axes overlap, that is: .

[0064] The intersection test algorithm for spheres and volumes is used to find all octree nodes within a preset radius of the target point, and is often used for range-triggered or nearest-neighbor searches. The core of this algorithm is finding the point on the node volume (AABB) that is closest to the center of the sphere. If the distance from the center of the sphere to this closest point is less than the radius of the sphere, then the sphere and volume intersect. The method for finding the closest point is to "clamp" the coordinates of the sphere's center between the minimum and maximum boundaries of the volume.

[0065] Specifically, let the center of the sphere be... , radius is The boundary range of the node volume is The point that is closest to the center of the sphere in terms of volume. The calculation formula is as follows: ; The Clamp function performs the following steps on each component of the vector: ; The final judgment criteria are: ; This means that the Euclidean distance between the nearest point and the center of the sphere is less than the radius of the sphere.

[0066] In one implementation of this embodiment, in addition to the three preset intersection test algorithms, other types / forms of intersection test algorithms can also be used. For example, for the inclusion relationship test between a point and a volume, in addition to the cubic interval judgment, the ray casting method can also be used for determination; for the intersection test between an AABB and a nodal volume, the complete implementation of the separating axis theorem can be used as an alternative to the simplified test; for the intersection test between a sphere and a volume, the core is to find the point on the volume that is closest to the center of the sphere. In addition to the "clamping" algorithm, the determination can also be made by calculating the distance from the center of the sphere to each surface, edge, and even vertex of the volume and taking the minimum value.

[0067] like Figure 3The diagram shows a flowchart of a method for obtaining leaf nodes that meet preset query conditions based on an intersection test algorithm in an embodiment. After receiving a spatial query request, the method first analyzes the query type corresponding to the query request, selects the corresponding intersection test algorithm based on the query type, and then performs an intersection test on all child nodes of the root node according to the selected intersection test algorithm to determine the results. Figure 3 Taking one of the root node's child nodes as an example, if the child node fails the intersection test, it is skipped. If the child node passes the intersection test, its node type is determined. If the child node is not a leaf node, its eight child nodes are recursively traversed, and an intersection test is performed on each child node. If the child node is a leaf node, the pedestrian data within that child node is collected, and the pedestrian data from all leaf nodes that meet the conditions are merged. Finally, the query results corresponding to the query conditions are output, which is the potential interaction object set. This set contains the pedestrian data from all leaf nodes that meet the conditions.

[0068] Specifically, in one implementation of this embodiment, step S300 includes the following steps: Step S301: Determine the intersection test algorithm corresponding to the spatial query request.

[0069] Specifically, the query type of the spatial query request is determined; wherein the query type includes point query, region query, and range query; the intersection test algorithm corresponding to the spatial query request is determined, including: When the query type is a point query, the intersection test algorithm between the point and the volume is executed; When the query type is a region query, the intersection test algorithm between the axis-aligned bounding box and the volume is executed; When the query type is a range query, the intersection test algorithm between the sphere and the volume is executed.

[0070] Step S302: Recursively traverse all nodes of the octree and perform an intersection test on the current node of each traversal based on a determined intersection test algorithm.

[0071] In this embodiment, all nodes of the octree are traversed recursively. Specifically, the root node is used as the initial node and the leaf nodes are used as the final nodes. All nodes in the octree are traversed until all leaf nodes of the octree have undergone at least one intersection test.

[0072] Step S303: If the current node being traversed fails the intersection test, skip the current node.

[0073] Specifically, if the current node being traversed fails the intersection test, the current node is skipped. For the current node skipped during the traversal, all child nodes corresponding to the skipped node are also skipped.

[0074] Step S304: If the current node being traversed passes the intersection test, determine the node type of the current node; if the node type of the current node is a non-leaf node, continue traversing the current node; if the node type of the current node is a leaf node, stop traversing the current node.

[0075] In this embodiment, when the current node passes the intersection test, it is necessary to further determine whether the node type of the current node is a leaf node. Specifically: If the current node is a non-leaf node, continue traversing the current node, that is, perform intersection tests and node type judgments on the child nodes of the current node until the result of the node type judgment is a leaf node. If the current node is a leaf node, stop traversing the current node and retrieve the pedestrian interaction data within that leaf node.

[0076] In one implementation of this embodiment, the traversal method is not limited to the depth-first recursive mode of this embodiment. For example, an iterative depth-first search scheme based on an explicit stack structure can be adopted. This scheme is functionally equivalent to recursive traversal, but can avoid the potential stack overflow risk of recursive calls.

[0077] In addition, the query strategy can also be extended to breadth-first search, that is, using a queue data structure to manage the nodes to be visited. Although this approach may affect the locality of memory access, it can still complete the given spatial query task.

[0078] like Figure 1 As shown, this embodiment of the invention provides a method for indexing the interaction space of a digital twin scene based on an octree, comprising the following steps: Step S400: Merge the pedestrian data stored in the acquired leaf nodes and output a set of potential interaction objects based on the merging result.

[0079] In this embodiment, the pedestrian data stored in all the acquired leaf nodes, i.e. pedestrian interaction data, are merged to form the corresponding set of potential interaction objects. This set of potential interaction objects is then used as the final output of the octree-based digital twin scene crowd interaction space indexing method.

[0080] For example, suppose the target space in a digital twin environment is a multi-level transportation hub with a spatial size of It comprises two floors above ground and one floor below ground. In the current simulation frame, there are 5000 pedestrians distributed within this space; through the method in step S200, based on the preset termination condition (the minimum spatial volume of the child node is 200m²),... 3(If the pedestrian number threshold is 10 people, or the maximum depth is 6 layers), the three-dimensional space is divided into multiple octagonal leaf nodes, and the coordinate data of 5000 pedestrians are stored in the corresponding leaf nodes respectively; based on the method of step S300, assuming that pedestrian A on the second floor needs to perform local obstacle avoidance calculation, the system responds to the "range query" request initiated by him and sets the radius of the query sphere. The system recursively traverses the octree, using a sphere-volume intersection test algorithm to quickly eliminate most nodes in the basement, first floor, and distant second floor, ultimately locking only those nodes related to the sphere. The system extracts and merges the pedestrian data stored in the four leaf nodes where the radius spheres intersect, based on the method in step S400, to obtain a "potential interaction object set" containing 12 pedestrians. Ultimately, pedestrian A only needs to perform precise physical collision and repulsion force calculations with these 12 potential objects, without needing to traverse and calculate with all 5000 pedestrians globally, thus greatly improving the computational efficiency of single-step simulation.

[0081] This embodiment achieves the following technical effects through the above technical solution: To address the computational efficiency bottlenecks and insufficient adaptability to complex 3D scenes in existing pedestrian interaction models when handling large crowds, this embodiment proposes an octree-based 3D spatial indexing structure. Compared with commonly used spatial optimization techniques (such as quadtrees suitable for 2D planes or KD trees that require frequent balancing in high-dimensional spaces), this structure exhibits the following significant advantages: In terms of computational efficiency, unlike two-dimensional quadtrees which can only optimize planar searches, octrees, through their three-dimensional recursive subdivision capabilities, achieve natural expression and efficient management of three-dimensional space. Their fast neighborhood query mechanism can accurately locate potential interactive objects in O(logn) time complexity, compared to traditional global traversal methods (O(n...). 2 The computational efficiency has been improved by orders of magnitude, which reduces the overhead of dynamic updates of some high-dimensional index structures and provides a solid foundation for real-time simulation of populations of tens of thousands.

[0082] In terms of 3D spatial representation and adaptability, the fundamental advantage of this embodiment lies in the natural fit between its spatial partitioning method and 3D topological relationships. Compared to KD trees, which treat 3D points as an unordered set and construct them by recursively partitioning hyperplanes, octrees, through their regular node encoding, can more intuitively and efficiently represent the relative positional relationships of objects in 3D space (such as up / down, left / right, front / back). This characteristic not only enables it to accurately filter invalid interactions in the vertical direction, solving the inherent defect of 2D methods in multi-layered scenes that cannot distinguish pedestrians on different floors, but also makes its regular cubic nodes easier to combine with techniques such as bounding boxes in 3D graphics. This provides better underlying support for refined 3D interaction judgments such as line-of-sight occlusion and complex terrain, thereby significantly improving the realism of simulations in complex 3D scenes such as stairs, slopes, and hollow plazas.

[0083] Furthermore, this embodiment integrates intersection testing algorithms for three basic geometric shapes: points, axis-aligned bounding boxes, and spheres, providing a unified and efficient filtering mechanism for diverse interaction rules such as line-of-sight interaction, region influence, and distance triggering. This significantly improves the realism and computational efficiency of crowd interaction in complex 3D scenes, offering more reliable technical support for public safety management and architectural design optimization.

[0084] Exemplary device Based on the above embodiments, the present invention also provides a digital twin scene crowd interaction space indexing system based on an octree, comprising: The spatial determination module is used to determine the target three-dimensional space containing pedestrian data; The spatial segmentation module is used to construct an octree corresponding to the target three-dimensional space based on the octree spatial partitioning algorithm; wherein the root node of the octree is the target three-dimensional space, and the leaf nodes are the smallest three-dimensional spaces segmented in the octree; The node query module is used to respond to spatial query requests. Based on the intersection test algorithm, it recursively traverses all nodes of the octree to obtain leaf nodes that meet the preset query conditions. The results output module is used to merge the pedestrian data stored in the acquired leaf nodes and output a set of potential interactive objects based on the merged results.

[0085] Based on the above embodiments, the present invention also provides a terminal, the principle block diagram of which can be as follows: Figure 4 As shown.

[0086] The terminal includes: a processor, a memory, an interface, a display screen, and a communication module connected via a system bus; wherein, the processor of the terminal provides computing and control capabilities; the memory of the terminal includes a computer-readable storage medium and internal memory; the computer-readable storage medium stores an operating system and computer programs; the internal memory provides an environment for the operation of the operating system and computer programs in the computer-readable storage medium; the interface is used to connect to external devices; the display screen is used to display relevant information; and the communication module is used to communicate with a cloud server or other devices.

[0087] When executed by a processor, this computer program is used to implement the operation of an octree-based digital twin scene crowd interaction space indexing method.

[0088] It will be understood by those skilled in the art that Figure 4 The schematic diagram shown is merely a partial structural diagram related to the present invention and does not constitute a limitation on the terminal to which the present invention is applied. A specific terminal may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0089] In one embodiment, a terminal is provided, comprising: a processor and a memory, the memory storing an octree-based digital twin scene crowd interaction space indexing program, which, when executed by the processor, is used to implement the operation of the octree-based digital twin scene crowd interaction space indexing method described above.

[0090] In one embodiment, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores an octree-based digital twin scene crowd interaction space indexing program, which, when executed by a processor, is used to implement the operation of the octree-based digital twin scene crowd interaction space indexing method described above.

[0091] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, database, or other media used in the embodiments provided by this invention can include both non-volatile and volatile memory.

[0092] In summary, this invention provides a digital twin scene crowd interaction space indexing method and system based on octrees, comprising: determining a target three-dimensional space containing pedestrian data; constructing an octree corresponding to the target three-dimensional space based on an octree space partitioning algorithm; wherein the root node of the octree is the target three-dimensional space, and the leaf nodes are the smallest three-dimensional spaces partitioned in the octree; responding to a space query request, recursively traversing all nodes of the octree based on an intersection test algorithm to obtain leaf nodes that meet preset query conditions; merging the pedestrian data stored in the obtained leaf nodes, and outputting a set of potential interactive objects based on the merging result; this invention can utilize the recursive subdivision capability of octrees in three-dimensional space, as well as the intersection test algorithm integrating three basic geometric shapes: points, axis-aligned bounding boxes, and spheres, to achieve natural expression and efficient management of three-dimensional space crowd interaction data.

[0093] It should be understood that the application of the present invention is not limited to the examples above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.

Claims

1. A method for indexing the spatial interaction of people in a digital twin scene based on an octree, characterized in that, include: Determine the target three-dimensional space and acquire pedestrian data in the target three-dimensional space; An octree corresponding to the target three-dimensional space is constructed based on an octree space partitioning algorithm; wherein, the root node of the octree is the target three-dimensional space, and the leaf nodes are the smallest three-dimensional spaces partitioned in the octree; In response to a spatial query request, the system recursively traverses all nodes of the octree based on an intersection test algorithm to obtain leaf nodes that meet the preset query conditions. The pedestrian data stored in the leaf nodes are merged, and the result is output as a set of potential interactive objects.

2. The digital twin scene crowd interaction space indexing method based on octree according to claim 1, characterized in that, The construction of the octree corresponding to the target three-dimensional space based on the octree space partitioning algorithm includes: The target three-dimensional space is segmented based on the octree space partitioning algorithm, and the root node and the child nodes generated in each segmentation are used as the parent node. All the parent nodes are divided, and each division generates eight child nodes of the parent nodes; When the generated child node meets the preset termination condition, the splitting of the current child node is terminated, and the current child node is taken as a leaf node. When all generated child nodes meet the preset termination condition, the segmentation of the target three-dimensional space is terminated, and an octree of the target three-dimensional space is obtained.

3. The digital twin scene crowd interaction space indexing method based on octree according to claim 2, characterized in that, The preset termination conditions include: The number of pedestrian data in the generated child nodes meets the preset pedestrian data threshold. Or the depth of the generated child nodes reaches a preset depth threshold.

4. The digital twin scene crowd interaction space indexing method based on octree according to claim 2, characterized in that, The step of splitting all the parent nodes, generating eight child nodes for each parent node in each split, includes: Determine the X-axis, Y-axis, and Z-axis of the three-dimensional space; The three-dimensional space corresponding to the parent node is uniformly divided into eight child nodes along the X-axis, Y-axis, and Z-axis.

5. The digital twin scene crowd interaction space indexing method based on octree according to claim 1, characterized in that, The intersection test algorithm includes: The intersection test algorithm between points and volumes is used to determine whether a target 3D coordinate point is located within the volume of a target octree node; An intersection test algorithm between axis-aligned bounding boxes and volumes is used to determine and filter out all octree nodes that overlap with the axis-aligned bounding boxes. The intersection test algorithm between the sphere and the volume is used to find all octree nodes within a preset radius from the target point.

6. The digital twin scene crowd interaction space indexing method based on octree according to claim 5, characterized in that, The response space query request recursively traverses all nodes of the octree based on the intersection test algorithm to obtain leaf nodes that satisfy preset query conditions, including: Determine the intersection test algorithm corresponding to the spatial query request; All nodes of the octree are traversed recursively, and an intersection test is performed on the current node of each traversal based on a determined intersection test algorithm. If the current node being traversed fails the intersection test, skip the current node. If the current node passes the intersection test, determine the node type of the current node; if the node type of the current node is a non-leaf node, continue traversing the current node; if the node type of the current node is a leaf node, stop traversing the current node.

7. The digital twin scene crowd interaction space indexing method based on octree according to claim 6, characterized in that, The algorithm for determining the intersection test corresponding to the spatial query request includes: Determine the query type of the spatial query request; wherein the query type includes point query, region query, and range query; When the query type is a point query, the intersection test algorithm between the point and the volume is executed; When the query type is a region query, the intersection test algorithm between the axis-aligned bounding box and the volume is executed; When the query type is a range query, the intersection test algorithm between the sphere and the volume is executed.

8. A digital twin scene crowd interaction spatial indexing system based on an octree, characterized in that, include: The spatial determination module is used to determine the target three-dimensional space containing pedestrian data; The spatial segmentation module is used to construct an octree corresponding to the target three-dimensional space based on the octree spatial partitioning algorithm; wherein the root node of the octree is the target three-dimensional space, and the leaf nodes are the smallest three-dimensional spaces segmented in the octree; The node query module is used to respond to spatial query requests. Based on the intersection test algorithm, it recursively traverses all nodes of the octree to obtain leaf nodes that meet the preset query conditions. The results output module is used to merge the pedestrian data stored in the acquired leaf nodes and output a set of potential interactive objects based on the merged results.

9. A terminal, characterized in that, include: The processor and memory, wherein the memory stores an octree-based digital twin scene crowd interaction space indexing program, which, when executed by the processor, is used to implement the operation of the octree-based digital twin scene crowd interaction space indexing method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores an octree-based digital twin scene crowd interaction space indexing program, which, when executed by a processor, is used to implement the operation of the octree-based digital twin scene crowd interaction space indexing method as described in any one of claims 1-7.