43 #ifndef ILQGAMES_GEOMETRY_LINE_SEGMENT2_H 44 #define ILQGAMES_GEOMETRY_LINE_SEGMENT2_H 46 #include <ilqgames/utils/types.h> 48 #include <glog/logging.h> 58 length_((point1 - point2).norm()),
59 unit_direction_((point2 - point1) / length_) {
60 CHECK_GT(length_, constants::kSmallNumber);
64 float Length()
const {
return length_; }
65 const Point2& FirstPoint()
const {
return p1_; }
66 const Point2& SecondPoint()
const {
return p2_; }
67 const Point2& UnitDirection()
const {
return unit_direction_; }
68 float Heading()
const {
69 return std::atan2(UnitDirection().y(), UnitDirection().x());
74 bool Side(
const Point2& query)
const;
79 Point2 ClosestPoint(
const Point2& query,
bool* is_endpoint =
nullptr,
80 float* signed_squared_distance =
nullptr)
const;
82 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
88 Point2 unit_direction_;