/
polytech_kolomna
/
aipackaging_math
Обзор
Документация
Войти
/
polytech_kolomna
/
aipackaging_math
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
1
CI/CD
Аналитика
intersections
src/geometry/line2d.cpp
72 строки
1 KB
Olegh
lower case
28 окт 2025, 21:08
28 окт 2025, 21:08
037a99f
Код
Авторство
О чём код?
#include <matrix3.h> #include <line2d.h> // Line2D::Line2D(const Point2D& point, const Vector2D& direction): point_(point), direction_(direction.normalized()) { } // Point2D Line2D::getPoint(double t) const { double x = point_.x + t * direction_.x; double y = point_.y + t * direction_.y; return Point2D{ x, y }; } // void Line2D::move(const Vector2D& offset) { transform(Matrix3::translate(offset)); } // void Line2D::scale(double scaleX, double scaleY) { Point2D point = point_; transform(Matrix3::translate({ -point.x,-point.y })); transform(Matrix3::scale(scaleX, scaleY)); transform(Matrix3::translate({ point.x, point.y })); } // void Line2D::rotate(double radian) { // Образующая точка Point2D point = point_; transform(Matrix3::translate({ -point.x,-point.y })); transform(Matrix3::rotate(radian)); transform(Matrix3::translate({ point.x, point.y })); } // void Line2D::transform(const Matrix3& transform) { point_ = point_ * transform; direction_ = (direction_ * transform).normalized(); } // bool Line2D::operator==(const Line2D& other) { return point_ == other.point_ && direction_ == other.direction_; } // bool Line2D::operator!=(const Line2D& other) { return !(*this == other); }