Apollo 11.0
自动驾驶开放平台
rect2d.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include "Eigen/Core"
20
21namespace apollo {
22namespace localization {
23namespace msf {
24
25template <typename T>
26class Rect2D {
27 public:
31 Rect2D(T min_x, T min_y, T max_x, T max_y);
33 Rect2D(const Rect2D<T>& ref);
37 T GetMinX() const;
39 T GetMinY() const;
41 T GetMaxX() const;
43 T GetMaxY() const;
45 Eigen::Matrix<T, 2, 1> GetLeftTopCorner() const;
47 Eigen::Matrix<T, 2, 1> GetRightBottomCorner() const;
48
49 private:
51 Eigen::Matrix<T, 4, 1, Eigen::DontAlign> _data;
52};
53
54template <typename T>
56
57template <typename T>
58Rect2D<T>::Rect2D(T min_x, T min_y, T max_x, T max_y)
59 : _data(min_x, min_y, max_x, max_y) {}
60
61template <typename T>
63 _data = ref._data;
64}
65
66template <typename T>
68 _data = ref._data;
69 return *this;
70}
71
72template <typename T>
74 return _data(0);
75}
76
77template <typename T>
79 return _data(1);
80}
81
82template <typename T>
84 return _data(2);
85}
86
87template <typename T>
89 return _data(3);
90}
91
92template <typename T>
93Eigen::Matrix<T, 2, 1> Rect2D<T>::GetLeftTopCorner() const {
94 Eigen::Matrix<T, 2, 1> corner;
95 corner(0) = _data(0);
96 corner(1) = _data(1);
97 return corner;
98}
99
100template <typename T>
101Eigen::Matrix<T, 2, 1> Rect2D<T>::GetRightBottomCorner() const {
102 Eigen::Matrix<T, 2, 1> corner;
103 corner(0) = _data(2);
104 corner(1) = _data(3);
105 return corner;
106}
107
108} // namespace msf
109} // namespace localization
110} // namespace apollo
Rect2D(T min_x, T min_y, T max_x, T max_y)
The constructor.
Definition rect2d.h:58
Rect2D()
@brieft The constructor.
Definition rect2d.h:55
Eigen::Matrix< T, 2, 1 > GetLeftTopCorner() const
Get the left top corner of the rectangle.
Definition rect2d.h:93
T GetMaxY() const
Get the max y of the rectangle.
Definition rect2d.h:88
Rect2D(const Rect2D< T > &ref)
Copy constructor.
Definition rect2d.h:62
Rect2D< T > & operator=(const Rect2D< T > &ref)
Overloading the operator =.
Definition rect2d.h:67
Eigen::Matrix< T, 2, 1 > GetRightBottomCorner() const
Get the right bottom corner of the rectangle.
Definition rect2d.h:101
T GetMaxX() const
Get the max x of the rectangle.
Definition rect2d.h:83
T GetMinX() const
Get the min x of the rectangle.
Definition rect2d.h:73
T GetMinY() const
Get the min y of the rectangle.
Definition rect2d.h:78
class register implement
Definition arena_queue.h:37