// Copyright 2024 Bytedance Inc. All Rights Reserved. // Author: tianlei.richard@qq.com (tianlei.richard) #pragma once #include #include #include #include class Triangle { public: using AffineTransformType = Eigen::Transform; using ProjectiveTransformType = Eigen::Transform; using PointType = Eigen::Vector3d; using BBoxType = cv::Rect2i; private: using HomoPointType = Eigen::Vector4d; public: Triangle(const PointType &a, const PointType &b, const PointType &c); Triangle(const HomoPointType &a, const HomoPointType &b, const HomoPointType &c); public: BBoxType axis_align_bbox() const; void affine_transform(const AffineTransformType &m); void projective_transform(const ProjectiveTransformType &m); private: static BBoxType calculate_aabb(const HomoPointType &a, const HomoPointType &b, const HomoPointType &c); private: std::array points_; BBoxType aabb_; };