Apollo 10.0
自动驾驶开放平台
apollo::common::math::AABoxKDTree2dNode< ObjectType > 模板类 参考

The class of KD-tree node of axis-aligned bounding box. 更多...

#include <aaboxkdtree2d.h>

apollo::common::math::AABoxKDTree2dNode< ObjectType > 的协作图:

Public 类型

using ObjectPtr = const ObjectType *
 

Public 成员函数

 AABoxKDTree2dNode (const std::vector< ObjectPtr > &objects, const AABoxKDTreeParams &params, int depth)
 Constructor which takes a vector of objects, parameters and depth of the node.
 
ObjectPtr GetNearestObject (const Vec2d &point) const
 Get the nearest object to a target point by the KD-tree rooted at this node.
 
std::vector< ObjectPtrGetObjects (const Vec2d &point, const double distance) const
 Get objects within a distance to a point by the KD-tree rooted at this node.
 
AABox2d GetBoundingBox () const
 Get the axis-aligned bounding box of the objects.
 

详细描述

template<class ObjectType>
class apollo::common::math::AABoxKDTree2dNode< ObjectType >

The class of KD-tree node of axis-aligned bounding box.

在文件 aaboxkdtree2d.h60 行定义.

成员类型定义说明

◆ ObjectPtr

template<class ObjectType >
using apollo::common::math::AABoxKDTree2dNode< ObjectType >::ObjectPtr = const ObjectType *

在文件 aaboxkdtree2d.h62 行定义.

构造及析构函数说明

◆ AABoxKDTree2dNode()

template<class ObjectType >
apollo::common::math::AABoxKDTree2dNode< ObjectType >::AABoxKDTree2dNode ( const std::vector< ObjectPtr > &  objects,
const AABoxKDTreeParams params,
int  depth 
)
inline

Constructor which takes a vector of objects, parameters and depth of the node.

参数
objectsObjects to build the KD-tree node.
paramsParameters to build the KD-tree.
depthDepth of the KD-tree node.

在文件 aaboxkdtree2d.h70 行定义.

72 : depth_(depth) {
73 ACHECK(!objects.empty());
74
75 ComputeBoundary(objects);
76 ComputePartition();
77
78 if (SplitToSubNodes(objects, params)) {
79 std::vector<ObjectPtr> left_subnode_objects;
80 std::vector<ObjectPtr> right_subnode_objects;
81 PartitionObjects(objects, &left_subnode_objects, &right_subnode_objects);
82
83 // Split to sub-nodes.
84 if (!left_subnode_objects.empty()) {
85 left_subnode_.reset(new AABoxKDTree2dNode<ObjectType>(
86 left_subnode_objects, params, depth + 1));
87 }
88 if (!right_subnode_objects.empty()) {
89 right_subnode_.reset(new AABoxKDTree2dNode<ObjectType>(
90 right_subnode_objects, params, depth + 1));
91 }
92 } else {
93 InitObjects(objects);
94 }
95 }
#define ACHECK(cond)
Definition log.h:80

成员函数说明

◆ GetBoundingBox()

template<class ObjectType >
AABox2d apollo::common::math::AABoxKDTree2dNode< ObjectType >::GetBoundingBox ( ) const
inline

Get the axis-aligned bounding box of the objects.

返回
The axis-aligned bounding box of the objects.

在文件 aaboxkdtree2d.h128 行定义.

128 {
129 return AABox2d({min_x_, min_y_}, {max_x_, max_y_});
130 }

◆ GetNearestObject()

template<class ObjectType >
ObjectPtr apollo::common::math::AABoxKDTree2dNode< ObjectType >::GetNearestObject ( const Vec2d point) const
inline

Get the nearest object to a target point by the KD-tree rooted at this node.

参数
pointThe target point. Search it's nearest object.
返回
The nearest object to the target point.

在文件 aaboxkdtree2d.h103 行定义.

103 {
104 ObjectPtr nearest_object = nullptr;
105 double min_distance_sqr = std::numeric_limits<double>::infinity();
106 GetNearestObjectInternal(point, &min_distance_sqr, &nearest_object);
107 return nearest_object;
108 }

◆ GetObjects()

template<class ObjectType >
std::vector< ObjectPtr > apollo::common::math::AABoxKDTree2dNode< ObjectType >::GetObjects ( const Vec2d point,
const double  distance 
) const
inline

Get objects within a distance to a point by the KD-tree rooted at this node.

参数
pointThe center point of the range to search objects.
distanceThe radius of the range to search objects.
返回
All objects within the specified distance to the specified point.

在文件 aaboxkdtree2d.h117 行定义.

118 {
119 std::vector<ObjectPtr> result_objects;
120 GetObjectsInternal(point, distance, Square(distance), &result_objects);
121 return result_objects;
122 }
T Square(const T value)
Compute squared value.
Definition math_utils.h:141

该类的文档由以下文件生成: