bool Segment::intersect(Plane& plane, Eigen::Vector3f& point) const { double x = - (plane.getNormal().dot(origin_) + plane.getD()) / (plane.getNormal().dot(direction_)); point = direction_ * x + origin_; double r = dividingRatio(point); return 0 <= r && r <= 1.0; }
void Segment::foot(const Eigen::Vector3d& from, Eigen::Vector3d& output) { Eigen::Vector3d foot_point; Line::foot(from, foot_point); double r = dividingRatio(foot_point); if (r < 0.0) { output = from_; } else if (r > 1.0) { output = to_; } else { output = foot_point; } }