1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- //
- // Created by huli on 2020/9/1.
- //
- #ifndef POINT2D_TOOL_H
- #define POINT2D_TOOL_H
- //#define OPEN_PCL_FLAG
- #ifdef OPEN_PCL_FLAG
- #include <pcl/point_types.h>
- #include <pcl/PCLPointCloud2.h>
- #include <pcl/conversions.h>
- #include <pcl/common/common.h>
- #endif
- #include <stddef.h>
- #include <math.h>
- class Point2D_tool
- {
- public:
- //极坐标
- struct Polar_coordinates
- {
- float angle=0; //弧度
- float distance=0; //距离
- };
- //极坐标的限定范围
- struct Polar_coordinates_box
- {
- float angle_min=0; //角度最小值
- float angle_max=0; //角度最大值
- float distance_min=0; //距离最小值
- float distance_max=0; //距离最大值
- };
- //平面坐标
- struct Point2D
- {
- float x=0; //x轴
- float y=0; //y轴
- };
- //平面坐标的限定范围
- struct Point2D_box
- {
- float x_min=0; //x轴最小值
- float x_max=0; //x轴最大值
- float y_min=0; //y轴最小值
- float y_max=0; //y轴最大值
- };
- //平面坐标的转换矩阵, 可以进行旋转和平移, 不能缩放
- struct Point2D_transform
- {
- float m00=1;
- float m01=0;
- float m02=0;
- float m10=0;
- float m11=1;
- float m12=0;
- };
- //极坐标 -> 平面坐标
- static bool Polar_coordinates_to_point2D(Point2D_tool::Polar_coordinates* p_polar_coordinates, Point2D_tool::Point2D* p_point2D);
- //平面坐标 -> 极坐标
- static bool Point2D_to_polar_coordinates(Point2D_tool::Point2D* p_point2D, Point2D_tool::Polar_coordinates* p_polar_coordinates);
- //判断极坐标点是否在限制范围
- static bool limit_with_polar_coordinates_box(float distance, float angle, Point2D_tool::Polar_coordinates_box* p_polar_coordinates_box);
- //判断平面坐标点是否在限制范围
- static bool limit_with_point2D_box(float x, float y, Point2D_tool::Point2D_box* p_point2D_box);
- #ifdef OPEN_PCL_FLAG
- //平面坐标的转换, 可以进行旋转和平移, 不能缩放
- static bool transform_with_translation_rotation(float* p_x_in, float* p_y_in, float* p_x_out, float* p_y_out,
- Point2D_tool::Point2D_transform* p_point2D_transform);
- static bool transform_with_translation_rotation(pcl::PointXYZ* p_point3D_in, pcl::PointXYZ* p_point3D_out,
- Point2D_tool::Point2D_transform* p_point2D_transform);
- static bool transform_with_translation_rotation(pcl::PointCloud<pcl::PointXYZ>::Ptr p_cloud_in,
- pcl::PointCloud<pcl::PointXYZ>::Ptr p_cloud_out,
- Point2D_tool::Point2D_transform* p_point2D_transform);
- #endif
- };
- #endif //POINT2D_TOOL_H
|