Lines Matching refs:Geom

20 namespace Geom {  namespace
51 Geom::Point normal = unitTangentAt(curve, t).cw(); in touching_circle()
53 Geom::Point center = curve(t) + radius*normal; in touching_circle()
54 return Geom::Circle(center, fabs(radius)); in touching_circle()
59 static double area( Geom::Point a, Geom::Point b, Geom::Point c ) { in area()
61 using Geom::X; in area()
62 using Geom::Y; in area()
70 Geom::Point p; in touching_circle()
71 Geom::Point normal; in touching_circle()
73 double distance = Geom::distance( curve[1], curve[0] ); in touching_circle()
76 if( Geom::cross(curve[0]-curve[1], curve[1]-curve[2]) < 0 ) { in touching_circle()
80 normal = Geom::Point(curve[1] - curve[0]).cw(); in touching_circle()
84 double distance = Geom::distance( curve[3], curve[2] ); in touching_circle()
87 if( Geom::cross(curve[1]-curve[2], curve[2]-curve[3]) < 0 ) { in touching_circle()
91 normal = Geom::Point(curve[3] - curve[2]).cw(); in touching_circle()
96 return Geom::Circle( Geom::Point(0,std::numeric_limits<float>::infinity()), in touching_circle()
100 Geom::Point center = p + normal * radius; in touching_circle()
101 return Geom::Circle( center, fabs(radius) ); in touching_circle()
111 …join_data(Geom::Path &_res, Geom::Path const&_outgoing, Geom::Point _in_tang, Geom::Point _out_tan… in join_data()
115 Geom::Path &res;
118 Geom::Path const& outgoing;
121 Geom::Point in_tang;
122 Geom::Point out_tang;
135 jd.res.appendNew<Geom::LineSegment>(jd.outgoing.initialPoint()); in bevel_join()
141 …jd.res.appendNew<Geom::EllipticalArc>(jd.width, jd.width, 0, false, jd.width <= 0, jd.outgoing.ini… in round_join()
147 using namespace Geom; in miter_join_internal()
212 Geom::Point pick_solution(std::vector<Geom::ShapeIntersection> points, Geom::Point tang2, Geom::Poi… in pick_solution()
215 Geom::Point sol; in pick_solution()
231 Geom::Point expand_circle( Geom::Circle &inner_circle, Geom::Circle const &outer_circle, Geom::Poin… in expand_circle()
238 return Geom::Point(0,0); in expand_circle()
241 Geom::Line secant1(start_pt, start_pt + start_tangent); in expand_circle()
242 std::vector<Geom::ShapeIntersection> chord1_pts = outer_circle.intersect(secant1); in expand_circle()
244 Geom::LineSegment chord1(chord1_pts[0].point(), chord1_pts[1].point()); in expand_circle()
246 Geom::Line bisector = make_bisector_line( chord1 ); in expand_circle()
247 std::vector<Geom::ShapeIntersection> chord2_pts = outer_circle.intersect(bisector); in expand_circle()
249 Geom::LineSegment chord2(chord2_pts[0].point(), chord2_pts[1].point()); in expand_circle()
252 Geom::Coord d0 = Geom::distance(chord2_pts[0].point(),start_pt); in expand_circle()
253 Geom::Coord d1 = Geom::distance(chord2_pts[1].point(),start_pt); in expand_circle()
255 Geom::Point d = (d0 < d1) ? chord2_pts[0].point() : chord2_pts[1].point(); in expand_circle()
256 Geom::Line da(d,start_pt); in expand_circle()
259 std::vector<Geom::ShapeIntersection> chord3_pts = outer_circle.intersect(da); in expand_circle()
263 Geom::Coord d2 = Geom::distance(chord3_pts[0].point(),d); in expand_circle()
264 Geom::Coord d3 = Geom::distance(chord3_pts[1].point(),d); in expand_circle()
268 Geom::Point p = (d2 > d3) ? chord3_pts[0].point() : chord3_pts[1].point(); in expand_circle()
273 Geom::LineSegment chord4(start_pt,p); in expand_circle()
274 Geom::Line bisector2 = make_bisector_line( chord4 ); in expand_circle()
275 Geom::Line diameter = make_parallel_line( start_pt, bisector ); in expand_circle()
276 std::vector<Geom::ShapeIntersection> center_new = bisector2.intersect( diameter ); in expand_circle()
278 Geom::Coord r_new = Geom::distance( center_new[0].point(), start_pt ); in expand_circle()
288 Geom::Point adjust_circles( Geom::Circle &circle1, Geom::Circle &circle2, Geom::Point const &point1… in adjust_circles()
290 Geom::Point n1 = (circle1.center() - point1).normalized(); // Always points towards center in adjust_circles()
291 Geom::Point n2 = (circle2.center() - point2).normalized(); in adjust_circles()
292 Geom::Point sum_n = n1 + n2; in adjust_circles()
297 Geom::Point c1 = circle1.center(); in adjust_circles()
298 Geom::Point c2 = circle2.center(); in adjust_circles()
299 Geom::Point delta_c = c2 - c1; in adjust_circles()
309 double B = 4.0 * delta_r - 2.0 * Geom::dot( delta_c, sum_n ); in adjust_circles()
333 circle1 = Geom::Circle( c1 - dr*n1, r1-dr ); in adjust_circles()
334 circle2 = Geom::Circle( c2 + dr*n2, r2+dr ); in adjust_circles()
340 Geom::Line bisector( circle1.center(), circle2.center() ); in adjust_circles()
341 std::vector<Geom::ShapeIntersection> points = circle1.intersect( bisector ); in adjust_circles()
342 Geom::Point p0 = points[0].point(); in adjust_circles()
343 Geom::Point p1 = points[1].point(); in adjust_circles()
345 if( std::abs( Geom::distance( p0, circle2.center() ) - circle2.radius() ) < in adjust_circles()
346 std::abs( Geom::distance( p1, circle2.center() ) - circle2.radius() ) ) { in adjust_circles()
356 using namespace Geom; in extrapolate_join_internal()
358 Geom::Path &res = jd.res; in extrapolate_join_internal()
359 Geom::Curve const& incoming = res.back(); in extrapolate_join_internal()
360 Geom::Curve const& outgoing = jd.outgoing.front(); in extrapolate_join_internal()
361 Geom::Point startPt = incoming.finalPoint(); in extrapolate_join_internal()
362 Geom::Point endPt = outgoing.initialPoint(); in extrapolate_join_internal()
363 Geom::Point tang1 = jd.in_tang; in extrapolate_join_internal()
364 Geom::Point tang2 = jd.out_tang; in extrapolate_join_internal()
374 Geom::Circle circle1 = touching_circle(Geom::reverse(incoming.toSBasis()), 0.); in extrapolate_join_internal()
375 Geom::Circle circle2 = touching_circle(outgoing.toSBasis(), 0); in extrapolate_join_internal()
378 if( Geom::CubicBezier const * in_bezier = dynamic_cast<Geom::CubicBezier const*>(&incoming) ) { in extrapolate_join_internal()
379 Geom::Circle circle_test1 = touching_circle(*in_bezier, false); in extrapolate_join_internal()
380 if( !Geom::are_near( circle1, circle_test1, 0.01 ) ) { in extrapolate_join_internal()
385 if( Geom::CubicBezier const * out_bezier = dynamic_cast<Geom::CubicBezier const*>(&outgoing) ) { in extrapolate_join_internal()
386 Geom::Circle circle_test2 = touching_circle(*out_bezier, true); in extrapolate_join_internal()
387 if( !Geom::are_near( circle2, circle_test2, 0.01 ) ) { in extrapolate_join_internal()
394 Geom::Point center1 = circle1.center(); in extrapolate_join_internal()
395 …double side1 = tang1[Geom::X]*(startPt[Geom::Y]-center1[Geom::Y]) - tang1[Geom::Y]*(startPt[Geom::… in extrapolate_join_internal()
401 std::vector<Geom::ShapeIntersection> points; in extrapolate_join_internal()
403 Geom::EllipticalArc *arc1 = nullptr; in extrapolate_join_internal()
404 Geom::EllipticalArc *arc2 = nullptr; in extrapolate_join_internal()
405 Geom::LineSegment *seg1 = nullptr; in extrapolate_join_internal()
406 Geom::LineSegment *seg2 = nullptr; in extrapolate_join_internal()
407 Geom::Point sol; in extrapolate_join_internal()
408 Geom::Point p1; in extrapolate_join_internal()
409 Geom::Point p2; in extrapolate_join_internal()
415 Geom::Point node_on_path = startPt + Geom::rot90(tang1)*width; in extrapolate_join_internal()
471Geom::Point apex = adjust_circles( circle1, circle2, startPt, endPt, tang1, tang2 ); in extrapolate_join_internal()
483 Geom::Line secant(startPt, startPt + tang1); in extrapolate_join_internal()
486 circle1.setCenter(Geom::Point(0,std::numeric_limits<float>::infinity())); in extrapolate_join_internal()
488 Geom::Line secant(endPt, endPt + tang2); in extrapolate_join_internal()
491 circle2.setCenter(Geom::Point(0,std::numeric_limits<float>::infinity())); in extrapolate_join_internal()
508 seg1 = new Geom::LineSegment(startPt, sol); in extrapolate_join_internal()
513 seg2 = new Geom::LineSegment(sol, endPt); in extrapolate_join_internal()
548 Geom::Point point_on_path = startPt + Geom::rot90(tang1)*width; in extrapolate_join_internal()
549 Geom::Line bisector = make_angle_bisector_line(startPt, point_on_path, endPt); in extrapolate_join_internal()
550 Geom::Line ortho = make_orthogonal_line(point_on_path, bisector); in extrapolate_join_internal()
552 Geom::LineSegment chord(point_on_path, sol); in extrapolate_join_internal()
553 Geom::Line bisector_chord = make_bisector_line(chord); in extrapolate_join_internal()
555 Geom::Line limit_line; in extrapolate_join_internal()
561 if (Geom::distance(point_on_path, sol) > miter_limit) { in extrapolate_join_internal()
563 Geom::Point temp = bisector.versor(); in extrapolate_join_internal()
564 Geom::Point limit_point = point_on_path + miter_limit * temp; in extrapolate_join_internal()
568 Geom::Point center = in extrapolate_join_internal()
569 Geom::intersection_point( bisector_chord.pointAt(0), bisector_chord.versor(), in extrapolate_join_internal()
571 Geom::Coord radius = distance(center, point_on_path); in extrapolate_join_internal()
572 Geom::Circle circle_center(center, radius); in extrapolate_join_internal()
576 Geom::Ray start_ray(center, point_on_path); in extrapolate_join_internal()
577 Geom::Ray end_ray(center, sol); in extrapolate_join_internal()
578 Geom::Line limit_line(center, 0); // Angle set below in extrapolate_join_internal()
580 if (Geom::cross(start_ray.versor(), end_ray.versor()) < 0) { in extrapolate_join_internal()
586Geom::EllipticalArc *arc_center = circle_center.arc(point_on_path, 0.5*(point_on_path + sol), sol); in extrapolate_join_internal()
600 … p1 = Geom::intersection_point(startPt, tang1, limit_line.pointAt(0), limit_line.versor()); in extrapolate_join_internal()
612 … p2 = Geom::intersection_point(endPt, tang2, limit_line.pointAt(0), limit_line.versor()); in extrapolate_join_internal()
628 res.appendNew<Geom::LineSegment>(p2); in extrapolate_join_internal()
640 res.appendNew<Geom::LineSegment>(outgoing.finalPoint()); in extrapolate_join_internal()
658 void tangents(Geom::Point tang[2], Geom::Curve const& incoming, Geom::Curve const& outgoing) in tangents()
660 Geom::Point tang1 = Geom::unitTangentAt(reverse(incoming.toSBasis()), 0.); in tangents()
661 Geom::Point tang2 = outgoing.unitTangentAt(0.); in tangents()
666 Geom::LineSegment offset_line(Geom::LineSegment const& l, double width) in offset_line()
668 Geom::Point tang1 = Geom::rot90(l.unitTangentAt(0)); in offset_line()
669 Geom::Point tang2 = Geom::rot90(unitTangentAt(reverse(l.toSBasis()), 0.)); in offset_line()
671 Geom::Point start = l.initialPoint() + tang1 * width; in offset_line()
672 Geom::Point end = l.finalPoint() - tang2 * width; in offset_line()
674 return Geom::LineSegment(start, end); in offset_line()
677 void get_cubic_data(Geom::CubicBezier const& bez, double time, double& len, double& rad) in get_cubic_data()
680 std::vector<Geom::Point> derivs = bez.pointAndDerivatives(time, 3); in get_cubic_data()
682 Geom::Point der1 = derivs[1]; // first deriv (tangent vector) in get_cubic_data()
683 Geom::Point der2 = derivs[2]; // second deriv (tangent's tangent) in get_cubic_data()
684 double l = Geom::L2(der1); // length in get_cubic_data()
691 if (Geom::are_near(l, 0, 1e-4)) { in get_cubic_data()
692 l = Geom::L2(der2); in get_cubic_data()
693 Geom::Point der3 = derivs.at(3); // try second time in get_cubic_data()
694 if (Geom::are_near(l, 0, 1e-4)) { in get_cubic_data()
695 l = Geom::L2(der3); in get_cubic_data()
696 if (Geom::are_near(l, 0)) { in get_cubic_data()
701 rad = -l * (Geom::dot(der2, der2) / Geom::cross(der2, der3)); in get_cubic_data()
704 rad = -l * (Geom::dot(der1, der1) / Geom::cross(der1, der2)); in get_cubic_data()
710 Geom::CubicBezier const& bez, in _offset_cubic_stable_sub()
711 Geom::CubicBezier& c, in _offset_cubic_stable_sub()
712 const Geom::Point& start_normal, in _offset_cubic_stable_sub()
713 const Geom::Point& end_normal, in _offset_cubic_stable_sub()
714 const Geom::Point& start_new, in _offset_cubic_stable_sub()
715 const Geom::Point& end_new, in _offset_cubic_stable_sub()
722 using Geom::X; in _offset_cubic_stable_sub()
723 using Geom::Y; in _offset_cubic_stable_sub()
727 if (!Geom::are_near(start_rad, 0)) in _offset_cubic_stable_sub()
729 if (!Geom::are_near(end_rad, 0)) in _offset_cubic_stable_sub()
743 Geom::Point mid1_new = start_normal.ccw()*start_off; in _offset_cubic_stable_sub()
744 mid1_new = Geom::Point(start_new[X] + mid1_new[X]/3., start_new[Y] + mid1_new[Y]/3.); in _offset_cubic_stable_sub()
745 Geom::Point mid2_new = end_normal.ccw()*end_off; in _offset_cubic_stable_sub()
746 mid2_new = Geom::Point(end_new[X] - mid2_new[X]/3., end_new[Y] - mid2_new[Y]/3.); in _offset_cubic_stable_sub()
749 c = Geom::CubicBezier(start_new, mid1_new, mid2_new, end_new); in _offset_cubic_stable_sub()
756 const Geom::Point req = bez.pointAt(t); in _offset_cubic_stable_sub()
757 const Geom::Point chk = c.pointAt(c.nearestTime(req)); in _offset_cubic_stable_sub()
766 void offset_cubic(Geom::Path& p, Geom::CubicBezier const& bez, double width, double tol, size_t lev… in offset_cubic()
768 using Geom::X; in offset_cubic()
769 using Geom::Y; in offset_cubic()
771 const Geom::Point start_pos = bez.initialPoint(); in offset_cubic()
772 const Geom::Point end_pos = bez.finalPoint(); in offset_cubic()
774 const Geom::Point start_normal = Geom::rot90(bez.unitTangentAt(0)); in offset_cubic()
775 …const Geom::Point end_normal = -Geom::rot90(Geom::unitTangentAt(Geom::reverse(bez.toSBasis()), 0.)… in offset_cubic()
778 const Geom::Point start_new = start_pos + start_normal*width; in offset_cubic()
779 const Geom::Point end_new = end_pos + end_normal*width; in offset_cubic()
788 Geom::CubicBezier c; in offset_cubic()
806 Geom::CubicBezier current_curve; in offset_cubic()
850 auto line = Geom::LineSegment(p.finalPoint(), c.initialPoint()); in offset_cubic()
865 const Geom::Point req = bez.pointAt(t); in offset_cubic()
869 const Geom::Point chk = c.pointAt(c.nearestTime(req)); in offset_cubic()
871 Geom::Point const diff = req - chk; in offset_cubic()
880 if (Geom::are_near(start_new, p.finalPoint())) { in offset_cubic()
889 std::pair<Geom::CubicBezier, Geom::CubicBezier> s = bez.subdivide(worst_time); in offset_cubic()
895 void offset_quadratic(Geom::Path& p, Geom::QuadraticBezier const& bez, double width, double tol, si… in offset_quadratic()
900 std::vector<Geom::Point> points = bez.controlPoints(); in offset_quadratic()
901 Geom::Point b1 = points[0] + (2./3) * (points[1] - points[0]); in offset_quadratic()
902 Geom::Point b2 = b1 + (1./3) * (points[2] - points[0]); in offset_quadratic()
903 Geom::CubicBezier cub = Geom::CubicBezier(points[0], b1, b2, points[2]); in offset_quadratic()
907 void offset_curve(Geom::Path& res, Geom::Curve const* current, double width, double tolerance) in offset_curve()
915 if (Geom::BezierCurve const *b = dynamic_cast<Geom::BezierCurve const*>(current)) { in offset_curve()
919 res.append(offset_line(static_cast<Geom::LineSegment const&>(*current), width)); in offset_curve()
922Geom::QuadraticBezier const& q = static_cast<Geom::QuadraticBezier const&>(*current); in offset_curve()
927 Geom::CubicBezier const& cb = static_cast<Geom::CubicBezier const&>(*current); in offset_curve()
932Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(current->toSBasis(), tolerance); in offset_curve()
939 Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(current->toSBasis(), 0.1); in offset_curve()
945 typedef void cap_func(Geom::PathBuilder& res, Geom::Path const& with_dir, Geom::Path const& against…
947 void flat_cap(Geom::PathBuilder& res, Geom::Path const&, Geom::Path const& against_dir, double) in flat_cap()
952 void round_cap(Geom::PathBuilder& res, Geom::Path const&, Geom::Path const& against_dir, double wid… in round_cap()
957 void square_cap(Geom::PathBuilder& res, Geom::Path const& with_dir, Geom::Path const& against_dir, … in square_cap()
960 Geom::Point normal_1 = -Geom::unitTangentAt(Geom::reverse(with_dir.back().toSBasis()), 0.); in square_cap()
961 Geom::Point normal_2 = -against_dir[0].unitTangentAt(0.); in square_cap()
967 void peak_cap(Geom::PathBuilder& res, Geom::Path const& with_dir, Geom::Path const& against_dir, do… in peak_cap()
970 Geom::Point normal_1 = -Geom::unitTangentAt(Geom::reverse(with_dir.back().toSBasis()), 0.); in peak_cap()
971 Geom::Point normal_2 = -against_dir[0].unitTangentAt(0.); in peak_cap()
972Geom::Point midpoint = ((with_dir.finalPoint() + normal_1*width) + (against_dir.initialPoint() + n… in peak_cap()
981 Geom::PathVector outline( in outline()
982 Geom::Path const& input, in outline()
989 if (input.size() == 0) return Geom::PathVector(); // nope, don't even try in outline()
991 Geom::PathBuilder res; in outline()
992 Geom::Path with_dir = half_outline(input, width/2., miter, join, tolerance); in outline()
993 Geom::Path against_dir = half_outline(input.reversed(), width/2., miter, join, tolerance); in outline()
1031 Geom::Path half_outline( in half_outline()
1032 Geom::Path const& input, in half_outline()
1046 Geom::Path res; in half_outline()
1049 Geom::Point tang1 = input[0].unitTangentAt(0); in half_outline()
1050 Geom::Point start = input.initialPoint() + tang1 * width; in half_outline()
1051 Geom::Path temp; in half_outline()
1052 Geom::Point tang[2]; in half_outline()
1060 const Geom::Curve &closingline = input.back_closed(); in half_outline()
1086 Geom::Curve const &c1 = res.back(); in half_outline()
1087 Geom::Curve const &c2 = res.front(); in half_outline()
1090 Geom::Path temp2; in half_outline()
1102 void outline_join(Geom::Path &res, Geom::Path const& temp, Geom::Point in_tang, Geom::Point out_tan… in outline_join()
1106 Geom::Curve const& outgoing = temp.front(); in outline_join()
1107 if (Geom::are_near(res.finalPoint(), outgoing.initialPoint(), 0.01)) { in outline_join()
1115 if (!(Geom::cross(in_tang, out_tang) > 0)) { in outline_join()