placo 0.8.5__tar.gz → 0.8.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of placo might be problematic. Click here for more details.
- {placo-0.8.5 → placo-0.8.7}/PKG-INFO +1 -1
- {placo-0.8.5 → placo-0.8.7}/pyproject.toml +1 -1
- placo-0.8.7/src/placo/tools/segment.cpp +91 -0
- placo-0.8.5/src/placo/tools/segment.cpp +0 -92
- {placo-0.8.5 → placo-0.8.7}/.clang-format +0 -0
- {placo-0.8.5 → placo-0.8.7}/.gitattributes +0 -0
- {placo-0.8.5 → placo-0.8.7}/.github/workflows/wheels.yml +0 -0
- {placo-0.8.5 → placo-0.8.7}/.gitignore +0 -0
- {placo-0.8.5 → placo-0.8.7}/.readthedocs.yaml +0 -0
- {placo-0.8.5 → placo-0.8.7}/CMakeLists.txt +0 -0
- {placo-0.8.5 → placo-0.8.7}/Doxyfile +0 -0
- {placo-0.8.5 → placo-0.8.7}/LICENSE +0 -0
- {placo-0.8.5 → placo-0.8.7}/Makefile +0 -0
- {placo-0.8.5 → placo-0.8.7}/README.md +0 -0
- {placo-0.8.5 → placo-0.8.7}/bindings/doxystub.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/bindings/expose-dynamics.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/bindings/expose-eigen.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/bindings/expose-footsteps.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/bindings/expose-kinematics.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/bindings/expose-parameters.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/bindings/expose-problem.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/bindings/expose-robot-wrapper.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/bindings/expose-tools.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/bindings/expose-utils.hpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/bindings/expose-walk-pattern-generator.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/bindings/module.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/bindings/module.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/build_wheel.sh +0 -0
- {placo-0.8.5 → placo-0.8.7}/python/.vscode/settings.json +0 -0
- {placo-0.8.5 → placo-0.8.7}/python/Makefile +0 -0
- {placo-0.8.5 → placo-0.8.7}/python/placo_utils/__init__.py +0 -0
- {placo-0.8.5 → placo-0.8.7}/python/placo_utils/tf.py +0 -0
- {placo-0.8.5 → placo-0.8.7}/python/placo_utils/view.py +0 -0
- {placo-0.8.5 → placo-0.8.7}/python/placo_utils/visualization.py +0 -0
- {placo-0.8.5 → placo-0.8.7}/python/run_tests.sh +0 -0
- {placo-0.8.5 → placo-0.8.7}/scripts/requirements.sh +0 -0
- {placo-0.8.5 → placo-0.8.7}/scripts/robotpkg.sh +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/avoid_self_collisions_constraint.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/avoid_self_collisions_constraint.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/com_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/com_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/constraint.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/constraint.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/contacts.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/contacts.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/dynamics_solver.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/dynamics_solver.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/frame_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/frame_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/gear_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/gear_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/joints_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/joints_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/orientation_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/orientation_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/position_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/position_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/relative_frame_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/relative_frame_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/relative_orientation_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/relative_orientation_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/relative_position_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/relative_position_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/torque_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/dynamics/torque_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/foot_trajectory.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/foot_trajectory.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/footsteps_planner.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/footsteps_planner.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/footsteps_planner_naive.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/footsteps_planner_naive.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/footsteps_planner_repetitive.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/footsteps_planner_repetitive.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/humanoid_parameters.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/humanoid_parameters.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/humanoid_robot.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/humanoid_robot.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/kick.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/kick.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/lipm.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/lipm.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/swing_foot.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/swing_foot.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/swing_foot_cubic.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/swing_foot_cubic.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/swing_foot_quintic.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/swing_foot_quintic.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/walk_pattern_generator.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/walk_pattern_generator.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/walk_tasks.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/humanoid/walk_tasks.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/avoid_self_collisions_constraint.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/avoid_self_collisions_constraint.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/axis_align_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/axis_align_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/centroidal_momentum_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/centroidal_momentum_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/com_polygon_constraint.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/com_polygon_constraint.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/com_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/com_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/cone_constraint.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/cone_constraint.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/constraint.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/constraint.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/distance_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/distance_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/frame_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/frame_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/gear_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/gear_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/joint_space_half_spaces_constraint.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/joint_space_half_spaces_constraint.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/joints_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/joints_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/kinematics_solver.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/kinematics_solver.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/kinetic_energy_regularization_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/kinetic_energy_regularization_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/manipulability_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/manipulability_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/orientation_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/orientation_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/position_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/position_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/regularization_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/regularization_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/relative_frame_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/relative_frame_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/relative_orientation_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/relative_orientation_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/relative_position_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/relative_position_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/wheel_task.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/kinematics/wheel_task.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/model/robot_wrapper.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/model/robot_wrapper.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/constraint.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/constraint.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/expression.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/expression.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/integrator.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/integrator.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/polygon_constraint.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/polygon_constraint.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/problem.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/problem.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/problem_polynom.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/problem_polynom.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/qp_error.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/qp_error.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/sparsity.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/sparsity.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/variable.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/problem/variable.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/axises_mask.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/axises_mask.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/cubic_spline.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/cubic_spline.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/cubic_spline_3d.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/cubic_spline_3d.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/directions.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/directions.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/polynom.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/polynom.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/prioritized.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/prioritized.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/segment.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/utils.cpp +0 -0
- {placo-0.8.5 → placo-0.8.7}/src/placo/tools/utils.h +0 -0
- {placo-0.8.5 → placo-0.8.7}/tweak_sdist.sh +0 -0
- {placo-0.8.5 → placo-0.8.7}/wks.yml +0 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#include <iostream>
|
|
2
|
+
#include "placo/tools/segment.h"
|
|
3
|
+
|
|
4
|
+
namespace placo::tools
|
|
5
|
+
{
|
|
6
|
+
Segment::Segment()
|
|
7
|
+
{
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
Segment::Segment(const Eigen::Vector2d& start, const Eigen::Vector2d& end) : start(start), end(end)
|
|
11
|
+
{
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
double Segment::norm()
|
|
15
|
+
{
|
|
16
|
+
return (end - start).norm();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
bool Segment::is_parallel(const Segment& s, double epsilon)
|
|
20
|
+
{
|
|
21
|
+
Eigen::Vector2d v1 = end - start;
|
|
22
|
+
Eigen::Vector2d v2 = s.end - s.start;
|
|
23
|
+
return fabs(v1.x() * v2.y() - v1.y() * v2.x()) / (v1.norm() * v2.norm()) < epsilon;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
bool Segment::is_point_aligned(const Eigen::Vector2d& point, double epsilon)
|
|
27
|
+
{
|
|
28
|
+
if (fabs((start - point).norm()) < epsilon)
|
|
29
|
+
{
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return is_parallel(Segment(start, point), epsilon);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
bool Segment::is_segment_aligned(const Segment& s, double epsilon)
|
|
36
|
+
{
|
|
37
|
+
return is_point_aligned(s.start, epsilon) && is_point_aligned(s.end, epsilon);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
bool Segment::is_point_in_segment(const Eigen::Vector2d& point, double epsilon)
|
|
41
|
+
{
|
|
42
|
+
Eigen::Vector2d v1 = end - start;
|
|
43
|
+
Eigen::Vector2d v2 = point - start;
|
|
44
|
+
return is_segment_aligned(Segment(start, point), epsilon) && v1.dot(v2) >= 0 && v1.dot(v2) <= v1.dot(v1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
bool Segment::intersects(Segment& s)
|
|
48
|
+
{
|
|
49
|
+
if (is_parallel(s))
|
|
50
|
+
{
|
|
51
|
+
throw std::runtime_error("Can't compute intersection of parallels");
|
|
52
|
+
}
|
|
53
|
+
return line_pass_through(s) && s.line_pass_through(*this);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
std::pair<double, double> Segment::get_lambdas(const Segment& s)
|
|
57
|
+
{
|
|
58
|
+
if (is_parallel(s))
|
|
59
|
+
{
|
|
60
|
+
throw std::runtime_error("Can't compute intersection of parallels");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Eigen::Vector2d v1 = end - start;
|
|
64
|
+
Eigen::Vector2d v2 = s.end - s.start;
|
|
65
|
+
Eigen::Vector2d p1 = start;
|
|
66
|
+
Eigen::Vector2d p2 = s.start;
|
|
67
|
+
double det = v1.x() * v2.y() - v1.y() * v2.x();
|
|
68
|
+
double l1 = (v2.y() * (p2.x() - p1.x()) + v2.x() * (p1.y() - p2.y())) / det;
|
|
69
|
+
double l2 = (v1.y() * (p2.x() - p1.x()) + v1.x() * (p1.y() - p2.y())) / det;
|
|
70
|
+
return std::make_pair(l1, l2);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
bool Segment::line_pass_through(const Segment& s)
|
|
74
|
+
{
|
|
75
|
+
auto lambdas = get_lambdas(s);
|
|
76
|
+
return lambdas.first >= 0 && lambdas.first <= 1;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
bool Segment::half_line_pass_through(const Segment& s)
|
|
80
|
+
{
|
|
81
|
+
auto lambdas = get_lambdas(s);
|
|
82
|
+
return lambdas.first >= 0 && lambdas.first <= 1 && lambdas.second >= 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
Eigen::Vector2d Segment::lines_intersection(const Segment& s)
|
|
86
|
+
{
|
|
87
|
+
auto lambdas = get_lambdas(s);
|
|
88
|
+
Eigen::Vector2d v = end - start;
|
|
89
|
+
return start + lambdas.first * v;
|
|
90
|
+
}
|
|
91
|
+
} // namespace placo::tools
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
#include <iostream>
|
|
2
|
-
#include "placo/tools/segment.h"
|
|
3
|
-
|
|
4
|
-
namespace placo::tools
|
|
5
|
-
{
|
|
6
|
-
Segment::Segment()
|
|
7
|
-
{
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
Segment::Segment(const Eigen::Vector2d& start, const Eigen::Vector2d& end)
|
|
11
|
-
: start(start), end(end)
|
|
12
|
-
{
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
double Segment::norm()
|
|
16
|
-
{
|
|
17
|
-
return (end - start).norm();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
bool Segment::is_parallel(const Segment& s, double epsilon)
|
|
21
|
-
{
|
|
22
|
-
Eigen::Vector2d v1 = end - start;
|
|
23
|
-
Eigen::Vector2d v2 = s.end - s.start;
|
|
24
|
-
return abs(v1.x() * v2.y() - v1.y() * v2.x()) / (v1.norm() * v2.norm()) < epsilon;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
bool Segment::is_point_aligned(const Eigen::Vector2d& point, double epsilon)
|
|
28
|
-
{
|
|
29
|
-
if (abs((start - point).norm()) < epsilon)
|
|
30
|
-
{
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
return is_parallel(Segment(start, point), epsilon);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
bool Segment::is_segment_aligned(const Segment& s, double epsilon)
|
|
37
|
-
{
|
|
38
|
-
return is_point_aligned(s.start, epsilon) && is_point_aligned(s.end, epsilon);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
bool Segment::is_point_in_segment(const Eigen::Vector2d& point, double epsilon)
|
|
42
|
-
{
|
|
43
|
-
Eigen::Vector2d v1 = end - start;
|
|
44
|
-
Eigen::Vector2d v2 = point - start;
|
|
45
|
-
return is_segment_aligned(Segment(start, point), epsilon) && v1.dot(v2) >= 0 && v1.dot(v2) <= v1.dot(v1);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
bool Segment::intersects(Segment& s)
|
|
49
|
-
{
|
|
50
|
-
if (is_parallel(s))
|
|
51
|
-
{
|
|
52
|
-
throw std::runtime_error("Can't compute intersection of parallels");
|
|
53
|
-
}
|
|
54
|
-
return line_pass_through(s) && s.line_pass_through(*this);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
std::pair<double, double> Segment::get_lambdas(const Segment& s)
|
|
58
|
-
{
|
|
59
|
-
if (is_parallel(s))
|
|
60
|
-
{
|
|
61
|
-
throw std::runtime_error("Can't compute intersection of parallels");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
Eigen::Vector2d v1 = end - start;
|
|
65
|
-
Eigen::Vector2d v2 = s.end - s.start;
|
|
66
|
-
Eigen::Vector2d p1 = start;
|
|
67
|
-
Eigen::Vector2d p2 = s.start;
|
|
68
|
-
double det = v1.x() * v2.y() - v1.y() * v2.x();
|
|
69
|
-
double l1 = (v2.y() * (p2.x() - p1.x()) + v2.x() * (p1.y() - p2.y())) / det;
|
|
70
|
-
double l2 = (v1.y() * (p2.x() - p1.x()) + v1.x() * (p1.y() - p2.y())) / det;
|
|
71
|
-
return std::make_pair(l1, l2);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
bool Segment::line_pass_through(const Segment& s)
|
|
75
|
-
{
|
|
76
|
-
auto lambdas = get_lambdas(s);
|
|
77
|
-
return lambdas.first >= 0 && lambdas.first <= 1;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
bool Segment::half_line_pass_through(const Segment& s)
|
|
81
|
-
{
|
|
82
|
-
auto lambdas = get_lambdas(s);
|
|
83
|
-
return lambdas.first >= 0 && lambdas.first <= 1 && lambdas.second >= 0;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
Eigen::Vector2d Segment::lines_intersection(const Segment& s)
|
|
87
|
-
{
|
|
88
|
-
auto lambdas = get_lambdas(s);
|
|
89
|
-
Eigen::Vector2d v = end - start;
|
|
90
|
-
return start + lambdas.first * v;
|
|
91
|
-
}
|
|
92
|
-
} // namespace placo::tools
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|