Geom Namespace Reference
A convex cover is a sequence of convex polygons that completely cover the path. More...
Namespaces | |
| namespace | detail |
| namespace | NL |
| namespace | PathInternal |
Classes | |
| union | dbl_64 |
| class | BezierCurve |
| class | BezierCurve< 0 > |
| class | Bezier |
| struct | wrap |
| class | Circle |
| class | Circulator |
| struct | ResultTraits< double > |
| struct | ResultTraits< Point > |
| struct | FragmentConcept |
| struct | NearConcept |
| struct | OffsetableConcept |
| struct | ScalableConcept |
| struct | AddableConcept |
| struct | MultiplicableConcept |
| class | angle_cmp |
| class | ConvexHull |
| ConvexHull A convexhull is a convex region - every point between two points in the convex hull is also in the convex hull. More... | |
| struct | Crossing |
| struct | CrossingOrder |
| struct | Crosser |
| struct | CurveHelpers |
| class | Curve |
| class | D2 |
| The D2 class takes two instances of a scalar data type and treats them like a point. More... | |
| class | Ellipse |
| class | EllipticalArc |
| class | Exception |
| class | LogicalError |
| class | RangeError |
| class | NotImplemented |
| class | InvariantsViolation |
| class | NotInvertible |
| class | InfiniteSolutions |
| class | ContinuityError |
| struct | SVGPathParseError |
| class | HLineSegment |
| class | VLineSegment |
| class | Interval |
| This class represents a range of numbers that is never empty. More... | |
| class | OptInterval |
| OptInterval is an Interval that can be empty. More... | |
| class | Line |
| class | Linear |
| class | Matrix |
| The Matrix class. More... | |
| class | Eigen |
| Given a matrix (ignoring the translation) this returns the eigen values and vectors. More... | |
| struct | SimpleCrosser |
| struct | MonoCrosser |
| class | Path |
| struct | PathVectorPosition |
| class | Piecewise |
| Piecewise function class. More... | |
| class | IPoint |
| class | Point |
| Cartesian 2D point. More... | |
| class | Poly |
| class | Quad |
| class | QuadTree |
| class | Ray |
| class | D2< Interval > |
| Rect class. More... | |
| class | OptRect |
| The OptRect class can represent and empty Rect and non-empty Rects. More... | |
| class | OldBezier |
| struct | rparams |
| class | Region |
| class | Linear2d |
| class | SBasis2d |
| class | SBasisCurve |
| class | SBasis |
| struct | ContainmentOrder |
| class | Shape |
| class | Bernsteins |
| This function is called _a lot_. More... | |
| class | sturm |
| class | SVGEllipticalArc |
| class | make_elliptical_arc |
| class | SVGPathSink |
| class | SVGPathGenerator |
| class | PathBuilder |
| struct | Event |
| struct | TransformConcept |
| class | Translate |
| class | Scale |
| class | Rotate |
| Notionally an Geom::Matrix corresponding to rotation about the origin. More... | |
| class | RectHull |
Typedefs | |
| typedef BezierCurve< 1 > | LineSegment |
| typedef BezierCurve< 2 > | QuadraticBezier |
| typedef BezierCurve< 3 > | CubicBezier |
| typedef Point | BezierCurve [] |
| typedef double | Coord |
| A "real" type with sufficient precision for coordinates. | |
| typedef boost::optional< Crossing > | OptCrossing |
| typedef std::vector< Crossing > | Crossings |
| typedef std::vector< Crossings > | CrossingSet |
| typedef std::vector< Path > | PathVector |
| typedef D2< Interval > | Rect |
| D2<Interval> specialization to Rect. | |
| typedef SimpleCrosser | DefaultCrosser |
| typedef long | ICoord |
| typedef std::vector< Region > | Regions |
| typedef std::back_insert_iterator < std::vector< Path > > | iter |
Enumerations | |
| enum | IntersectorKind { intersects = 0, parallel, coincident, no_intersection } |
| enum | Dim2 { X = 0, Y = 1 } |
| enum | { BOOLOP_JUST_A = 1, BOOLOP_JUST_B = 2, BOOLOP_BOTH = 4, BOOLOP_NEITHER = 8 } |
| enum | { BOOLOP_NULL = 0, BOOLOP_INTERSECT = BOOLOP_BOTH, BOOLOP_SUBTRACT_A_B = BOOLOP_JUST_B, BOOLOP_IDENTITY_A = BOOLOP_JUST_A | BOOLOP_BOTH, BOOLOP_SUBTRACT_B_A = BOOLOP_JUST_A, BOOLOP_IDENTITY_B = BOOLOP_JUST_B | BOOLOP_BOTH, BOOLOP_EXCLUSION = BOOLOP_JUST_A | BOOLOP_JUST_B, BOOLOP_UNION = BOOLOP_JUST_A | BOOLOP_JUST_B | BOOLOP_BOTH } |
| enum | NodeType { NODE_NONE, NODE_CUSP, NODE_SMOOTH, NODE_SYMM } |
What kind of node is this? This is the value for the node->type field. More... | |
Functions | |
| double | deg_to_rad (double deg) |
| double | rad_to_deg (double rad) |
| double | map_circular_arc_on_unit_interval (double angle, double start_angle, double end_angle, bool cw=true) |
| Coord | map_unit_interval_on_circular_arc (Coord t, double start_angle, double end_angle, bool cw=true) |
| void | find_intersections (std::vector< std::pair< double, double > > &xs, D2< SBasis > const &A, D2< SBasis > const &B) |
| void | find_intersections (std::vector< std::pair< double, double > > &xs, std::vector< Point > const &A, std::vector< Point > const &B, double precision) |
| void | split (vector< Point > const &p, double t, vector< Point > &left, vector< Point > &right) |
| void | find_self_intersections (std::vector< std::pair< double, double > > &xs, D2< SBasis > const &A) |
| static double | EpsilonBy (double value, int eps) |
| static void | intersect_polish_root (D2< SBasis > const &A, double &s, D2< SBasis > const &B, double &t) |
| void | polish_intersections (std::vector< std::pair< double, double > > &xs, D2< SBasis > const &A, D2< SBasis > const &B) |
| double | hausdorfl (D2< SBasis > &A, D2< SBasis > const &B, double m_precision, double *a_t=0, double *b_t=0) |
| double | hausdorf (D2< SBasis > &A, D2< SBasis > const &B, double m_precision, double *a_t, double *b_t) |
| Compute the symmetric Hausdorf distance. | |
| void | find_intersections_bezier_clipping (std::vector< std::pair< double, double > > &xs, std::vector< Point > const &A, std::vector< Point > const &B, double precision=1e-5) |
| void | find_collinear_normal (std::vector< std::pair< double, double > > &xs, std::vector< Point > const &A, std::vector< Point > const &B, double precision=1e-5) |
| Point | middle_point (LineSegment const &_segment) |
| double | length (LineSegment const &_segment) |
| template<typename T > | |
| D2< SBasis > | handles_to_sbasis (T const &handles, unsigned order) |
| static void | generate_bezier (Point bezier[], Point const data[], double const u[], unsigned const len, Point const &tHat1, Point const &tHat2, double const tolerance_sq) |
| Fill in bezier[] based on the given data and tangent requirements, using a least-squares fit. | |
| static void | estimate_lengths (Point bezier[], Point const data[], double const u[], unsigned len, Point const &tHat1, Point const &tHat2) |
| static void | estimate_bi (Point b[4], unsigned ei, Point const data[], double const u[], unsigned len) |
| static void | reparameterize (Point const d[], unsigned const len, double u[], BezierCurve const bezCurve) |
| Given set of points and their parameterization, try to find a better assignment of parameter values for the points. | |
| static double | NewtonRaphsonRootFind (BezierCurve const Q, Point const &P, double const u) |
| Use Newton-Raphson iteration to find better root. | |
| static Point | darray_center_tangent (Point const d[], unsigned const center, unsigned const len) |
| Estimates the (backward) tangent at d[center], by averaging the two segments connected to d[center] (and then normalizing the result). | |
| static Point | darray_right_tangent (Point const d[], unsigned const len) |
| Estimates the (backward) tangent at d[last - 0.5]. | |
| static unsigned | copy_without_nans_or_adjacent_duplicates (Point const src[], unsigned src_len, Point dest[]) |
| Copy points from src to dest, filter out points containing NaN and adjacent points with equal x and y. | |
| static void | chord_length_parameterize (Point const d[], double u[], unsigned const len) |
| Assign parameter values to digitized points using relative distances between points. | |
| static double | compute_max_error_ratio (Point const d[], double const u[], unsigned const len, BezierCurve const bezCurve, double const tolerance, unsigned *const splitPoint) |
| Find the maximum squared distance of digitized points to fitted curve, and (if this maximum error is non-zero) set *splitPoint to the corresponding index. | |
| static double | compute_hook (Point const &a, Point const &b, double const u, BezierCurve const bezCurve, double const tolerance) |
| Whereas compute_max_error_ratio() checks for itself that each data point is near some point on the curve, this function checks that each point on the curve is near some data point (or near some point on the polyline defined by the data points, or something like that: we allow for a "reasonable curviness" from such a polyline). | |
| int | bezier_fit_cubic (Point *bezier, Point const *data, int len, double error) |
| Fit a single-segment Bezier curve to a set of digitized points. | |
| int | bezier_fit_cubic_r (Point bezier[], Point const data[], int const len, double const error, unsigned const max_beziers) |
| Fit a multi-segment Bezier curve to a set of digitized points, with possible weedout of identical points and NaNs. | |
| int | bezier_fit_cubic_full (Point bezier[], int split_points[], Point const data[], int const len, Point const &tHat1, Point const &tHat2, double const error, unsigned const max_beziers) |
| Fit a multi-segment Bezier curve to a set of digitized points, without possible weedout of identical points and NaNs. | |
| static double | lensq (Point const p) |
| Point | bezier_pt (unsigned const degree, Point const V[], double const t) |
| Evaluate a Bezier curve at parameter value t. | |
| Point | darray_left_tangent (Point const d[], unsigned const len) |
| Estimate the (forward) tangent at point d[first + 0.5]. | |
| Point | darray_left_tangent (Point const d[], unsigned const len, double const tolerance_sq) |
| Estimate the (forward) tangent at point d[0]. | |
| Point | darray_right_tangent (Point const d[], unsigned const len, double const tolerance_sq) |
| Estimates the (backward) tangent at d[last]. | |
| int | bezier_fit_cubic (Point bezier[], Point const data[], int len, double error) |
| template<typename iterator > | |
| static void | cubic_bezier_poly_coeff (iterator b, Point *pc) |
| Coord | subdivideArr (Coord t, Coord const *v, Coord *left, Coord *right, unsigned order) |
| template<typename T > | |
| T | bernsteinValueAt (double t, T const *c_, unsigned n) |
| void | bezier_to_sbasis (SBasis &sb, Bezier const &bz) |
| Changes the basis of p to be sbasis. | |
| Bezier | operator+ (const Bezier &a, double v) |
| Bezier | operator- (const Bezier &a, double v) |
| Bezier | operator* (const Bezier &a, double v) |
| Bezier | operator/ (const Bezier &a, double v) |
| Bezier | reverse (const Bezier &a) |
| Bezier | portion (const Bezier &a, double from, double to) |
| std::vector< Point > | bezier_points (const D2< Bezier > &a) |
| Bezier | derivative (const Bezier &a) |
| Bezier | integral (const Bezier &a) |
| OptInterval | bounds_fast (Bezier const &b) |
| OptInterval | bounds_exact (Bezier const &b) |
| OptInterval | bounds_local (Bezier const &b, OptInterval i) |
| std::ostream & | operator<< (std::ostream &out_file, const Bezier &b) |
| SBasis | cheb (unsigned n) |
| SBasis | cheb_series (unsigned n, double *cheb_coeff) |
| SBasis | clenshaw_series (unsigned m, double *cheb_coeff) |
| SBasis | chebyshev_approximant (double(*f)(double, void *), int order, Interval in, void *p) |
| double | f_interp (double x, void *p) |
| SBasis | chebyshev_approximant_interpolating (double(*f)(double, void *), int order, Interval in, void *p) |
| SBasis | chebyshev (unsigned n) |
| int | circle_circle_intersection (Point X0, double r0, Point X1, double r1, Point &p0, Point &p1) |
| template<typename T > | |
| T | portion (const T &t, const Interval &i) |
| double | SignedTriangleArea (Point p0, Point p1, Point p2) |
| int | mod (int i, int l) |
| pair< map< int, int >, map < int, int > > | bridges (ConvexHull a, ConvexHull b) |
| std::vector< Point > | bridge_points (ConvexHull a, ConvexHull b) |
| unsigned | find_bottom_right (ConvexHull const &a) |
| ConvexHull | sweepline_intersection (ConvexHull const &a, ConvexHull const &b) |
| ConvexHull | intersection (ConvexHull, ConvexHull) |
| ConvexHull | merge (ConvexHull a, ConvexHull b) |
| ConvexHull | graham_merge (ConvexHull a, ConvexHull b) |
| bool | intersectp (ConvexHull a, ConvexHull b) |
| template<class T > | |
| ConvexHull | operator* (ConvexHull const &p, T const &m) |
| ConvexHull | clip (ConvexHull const &ch, Point n, double d) |
| Coord | infinity () |
| bool | are_near (Coord a, Coord b, double eps=EPSILON) |
| double | wrap_dist (double from, double to, double size, bool rev) |
| void | merge_crossings (Crossings &a, Crossings &b, unsigned i) |
| void | offset_crossings (Crossings &cr, double a, double b) |
| Crossings | reverse_ta (Crossings const &cr, std::vector< double > max) |
| Crossings | reverse_tb (Crossings const &cr, unsigned split, std::vector< double > max) |
| CrossingSet | reverse_ta (CrossingSet const &cr, unsigned split, std::vector< double > max) |
| CrossingSet | reverse_tb (CrossingSet const &cr, unsigned split, std::vector< double > max) |
| void | clean (Crossings &, Crossings &) |
| template<typename C > | |
| std::vector< Rect > | bounds (C const &a) |
| void | sort_crossings (Crossings &cr, unsigned ix) |
| Coord | nearest_point (Point const &p, Curve const &c) |
| SBasis | L2 (D2< SBasis > const &a, unsigned k) |
| D2< SBasis > | multiply (Linear const &a, D2< SBasis > const &b) |
| D2< SBasis > | multiply (SBasis const &a, D2< SBasis > const &b) |
| D2< SBasis > | truncate (D2< SBasis > const &a, unsigned terms) |
| unsigned | sbasis_size (D2< SBasis > const &a) |
| double | tail_error (D2< SBasis > const &a, unsigned tail) |
| Piecewise< D2< SBasis > > | sectionize (D2< Piecewise< SBasis > > const &a) |
| D2< Piecewise< SBasis > > | make_cuts_independent (Piecewise< D2< SBasis > > const &a) |
| Piecewise< D2< SBasis > > | rot90 (Piecewise< D2< SBasis > > const &M) |
| Piecewise< SBasis > | cross (Piecewise< D2< SBasis > > const &a, Piecewise< D2< SBasis > > const &b) |
| Piecewise< D2< SBasis > > | operator* (Piecewise< D2< SBasis > > const &a, Matrix const &m) |
| Piecewise< D2< SBasis > > | force_continuity (Piecewise< D2< SBasis > > const &f, double tol, bool closed) |
| std::vector< Geom::Piecewise < Geom::D2< Geom::SBasis > > > | split_at_discontinuities (Geom::Piecewise< Geom::D2< Geom::SBasis > > const &pwsbin, double tol) |
| static void | set_first_point (Piecewise< D2< SBasis > > &f, Point a) |
| static void | set_last_point (Piecewise< D2< SBasis > > &f, Point a) |
| std::vector< Piecewise< D2 < SBasis > > > | fuse_nearby_ends (std::vector< Piecewise< D2< SBasis > > > const &f, double tol) |
| template<typename T > | |
| D2< T > | reverse (const D2< T > &a) |
| template<typename T > | |
| D2< T > | portion (const D2< T > &a, Coord f, Coord t) |
| template<typename T > | |
| D2< T > | portion (const D2< T > &a, Interval i) |
| template<typename T > | |
| bool | operator== (D2< T > const &a, D2< T > const &b) |
| template<typename T > | |
| bool | operator!= (D2< T > const &a, D2< T > const &b) |
| template<typename T > | |
| bool | are_near (D2< T > const &a, D2< T > const &b, double tol) |
| template<typename T > | |
| D2< T > | operator+ (D2< T > const &a, D2< T > const &b) |
| template<typename T > | |
| D2< T > | operator- (D2< T > const &a, D2< T > const &b) |
| template<typename T > | |
| D2< T > | operator+= (D2< T > &a, D2< T > const &b) |
| template<typename T > | |
| D2< T > | operator-= (D2< T > &a, D2< T > const &b) |
| template<typename T > | |
| D2< T > | operator- (D2< T > const &a) |
| template<typename T > | |
| D2< T > | operator* (D2< T > const &a, Point const &b) |
| template<typename T > | |
| D2< T > | operator/ (D2< T > const &a, Point const &b) |
| template<typename T > | |
| D2< T > | operator*= (D2< T > &a, Point const &b) |
| template<typename T > | |
| D2< T > | operator/= (D2< T > &a, Point const &b) |
| template<typename T > | |
| D2< T > | operator* (D2< T > const &a, double b) |
| template<typename T > | |
| D2< T > | operator*= (D2< T > &a, double b) |
| template<typename T > | |
| D2< T > | operator/ (D2< T > const &a, double b) |
| template<typename T > | |
| D2< T > | operator/= (D2< T > &a, double b) |
| template<typename T > | |
| D2< T > | operator* (D2< T > const &v, Matrix const &m) |
| template<typename T > | |
| D2< T > | operator* (D2< T > const &a, T const &b) |
| template<typename T > | |
| D2< T > | operator+ (D2< T > const &a, Point b) |
| template<typename T > | |
| D2< T > | operator- (D2< T > const &a, Point b) |
| template<typename T > | |
| D2< T > | operator+= (D2< T > &a, Point b) |
| template<typename T > | |
| D2< T > | operator-= (D2< T > &a, Point b) |
| template<typename T > | |
| T | dot (D2< T > const &a, D2< T > const &b) |
| template<typename T > | |
| D2< T > | rot90 (D2< T > const &a) |
| template<typename T > | |
| D2< T > | compose (D2< T > const &a, T const &b) |
| template<typename T > | |
| D2< T > | compose_each (D2< T > const &a, D2< T > const &b) |
| template<typename T > | |
| D2< T > | compose_each (T const &a, D2< T > const &b) |
| template<typename T > | |
| D2< T > | derivative (D2< T > const &a) |
| template<typename T > | |
| D2< T > | integral (D2< T > const &a) |
| template<typename T > | |
| std::ostream & | operator<< (std::ostream &out_file, const Geom::D2< T > &in_d2) |
| A function to print out the Point. | |
| template<typename T > | |
| OptRect | bounds_fast (const D2< T > &a) |
| template<typename T > | |
| OptRect | bounds_exact (const D2< T > &a) |
| template<typename T > | |
| OptRect | bounds_local (const D2< T > &a, const OptInterval &t) |
| IntersectorKind | line_intersection (Geom::Point const &n0, double const d0, Geom::Point const &n1, double const d1, Geom::Point &result) |
| Finds the intersection of the two (infinite) lines defined by the points p such that dot(n0, p) == d0 and dot(n1, p) == d1. | |
| int | intersector_ccw (const Geom::Point &p0, const Geom::Point &p1, const Geom::Point &p2) |
| bool | line_segment_intersectp (Geom::Point const &p00, Geom::Point const &p01, Geom::Point const &p10, Geom::Point const &p11) |
| Determine whether the line segment from p00 to p01 intersects the infinite line passing through p10 and p11. | |
| bool | segment_intersectp (Geom::Point const &p00, Geom::Point const &p01, Geom::Point const &p10, Geom::Point const &p11) |
| Determine whether two line segments intersect. | |
| IntersectorKind | line_segment_intersect (Geom::Point const &p00, Geom::Point const &p01, Geom::Point const &p10, Geom::Point const &p11, Geom::Point &result) |
| Determine whether & where a line segments intersects an (infinite) line. | |
| IntersectorKind | segment_intersect (Geom::Point const &p00, Geom::Point const &p01, Geom::Point const &p10, Geom::Point const &p11, Geom::Point &result) |
| Determine whether & where two line segments intersect. | |
| IntersectorKind | line_twopoint_intersect (Geom::Point const &p00, Geom::Point const &p01, Geom::Point const &p10, Geom::Point const &p11, Geom::Point &result) |
| Determine whether & where two line segments intersect. | |
| static bool | is_less (Point const &A, Point const &B) |
| static void | eliminate_duplicates_p (std::vector< Point > &pts) |
| std::vector< Geom::Point > | rect_line_intersect (Geom::Point const &c0, Geom::Point const &c1, Geom::Point const &p0, Geom::Point const &p1) |
| Determine whether & where an (infinite) line intersects a rectangle. | |
| boost::optional< LineSegment > | rect_line_intersect (Geom::Rect &r, Geom::LineSegment ls) |
| Determine whether & where an (infinite) line intersects a rectangle. | |
| boost::optional< LineSegment > | rect_line_intersect (Geom::Rect &r, Geom::Line l) |
| int | centroid (std::vector< Geom::Point > const &p, Geom::Point ¢roid, double &area) |
| polyCentroid: Calculates the centroid (xCentroid, yCentroid) and area of a polygon, given its vertices (x[0], y[0]) ... | |
| Interval | operator+ (const Interval &a, const Interval &b) |
| Interval | operator- (const Interval &a, const Interval &b) |
| Interval | operator+= (Interval &a, const Interval &b) |
| Interval | operator-= (Interval &a, const Interval &b) |
| Interval | operator* (const Interval &a, const Interval &b) |
| Interval | operator*= (Interval &a, const Interval &b) |
| Interval | unify (const Interval &a, const Interval &b) |
| OptInterval | intersect (const Interval &a, const Interval &b) |
| OptCrossing | intersection (Line const &l1, Line const &l2) |
| OptCrossing | intersection (Ray const &r1, Ray const &r2) |
| OptCrossing | intersection (LineSegment const &ls1, LineSegment const &ls2) |
| Line | make_angle_bisector_line (Line const &l1, Line const &l2) |
| double | distance (Point const &_point, Line const &_line) |
| bool | are_near (Point const &_point, Line const &_line, double eps=EPSILON) |
| bool | are_parallel (Line const &l1, Line const &l2, double eps=EPSILON) |
| bool | are_same (Line const &l1, Line const &l2, double eps=EPSILON) |
| bool | are_orthogonal (Line const &l1, Line const &l2, double eps=EPSILON) |
| bool | are_collinear (Point const &p1, Point const &p2, Point const &p3, double eps=EPSILON) |
| double | angle_between (Line const &l1, Line const &l2) |
| double | distance (Point const &_point, LineSegment const &_segment) |
| bool | are_near (Point const &_point, LineSegment const &_segment, double eps=EPSILON) |
| Line | make_orthogonal_line (Point const &_point, Line const &_line) |
| Line | make_parallel_line (Point const &_point, Line const &_line) |
| Line | make_bisector_line (LineSegment const &_segment) |
| Line | make_angle_bisector_line (Point const &A, Point const &O, Point const &B) |
| Point | projection (Point const &_point, Line const &_line) |
| LineSegment | projection (LineSegment const &_segment, Line const &_line) |
| OptCrossing | intersection (Ray const &r1, Line const &l2) |
| OptCrossing | intersection (Line const &l1, Ray const &r2) |
| OptCrossing | intersection (LineSegment const &ls1, Line const &l2) |
| OptCrossing | intersection (Line const &l1, LineSegment const &ls2) |
| OptCrossing | intersection (LineSegment const &ls1, Ray const &r2) |
| OptCrossing | intersection (Ray const &r1, LineSegment const &ls2) |
| double | lerp (double t, double a, double b) |
| Linear | reverse (Linear const &a) |
| Linear | operator+ (Linear const &a, Linear const &b) |
| Linear | operator- (Linear const &a, Linear const &b) |
| Linear & | operator+= (Linear &a, Linear const &b) |
| Linear & | operator-= (Linear &a, Linear const &b) |
| Linear | operator+ (Linear const &a, double b) |
| Linear | operator- (Linear const &a, double b) |
| Linear & | operator+= (Linear &a, double b) |
| Linear & | operator-= (Linear &a, double b) |
| bool | operator== (Linear const &a, Linear const &b) |
| bool | operator!= (Linear const &a, Linear const &b) |
| Linear | operator- (Linear const &a) |
| Linear | operator* (Linear const &a, double b) |
| Linear | operator/ (Linear const &a, double b) |
| Linear | operator*= (Linear &a, double b) |
| Linear | operator/= (Linear &a, double b) |
| Matrix | from_basis (Point const x_basis, Point const y_basis, Point const offset) |
| Creates a Matrix given an axis and origin point. | |
| Matrix | operator* (Matrix const &m0, Matrix const &m1) |
| Matrix | elliptic_quadratic_form (Matrix const &m) |
| Given a matrix m such that unit_circle = m*x, this returns the quadratic form x*A*x = 1. | |
| Matrix & | operator*= (Matrix &a, Matrix const &b) |
| std::ostream & | operator<< (std::ostream &out_file, const Geom::Matrix &m) |
| A function to print out the Matrix (for debugging). | |
| Matrix | identity () |
| Returns the Identity Matrix. | |
| bool | operator== (Matrix const &a, Matrix const &b) |
| bool | operator!= (Matrix const &a, Matrix const &b) |
| double | nearest_point (Point const &p, D2< SBasis > const &c, D2< SBasis > const &dc, double from, double to) |
| std::vector< double > | all_nearest_points (Point const &p, D2< SBasis > const &c, D2< SBasis > const &dc, double from, double to) |
| double | nearest_point (Point const &p, Piecewise< D2< SBasis > > const &c, double from, double to) |
| std::vector< double > | all_nearest_points (Point const &p, Piecewise< D2< SBasis > > const &c, double from, double to) |
| double | nearest_point (Point const &p, Point const &A, Point const &v) |
| double | nearest_point (Point const &p, D2< SBasis > const &c, double from=0, double to=1) |
| std::vector< double > | all_nearest_points (Point const &p, D2< SBasis > const &c, double from=0, double to=1) |
| double | nearest_point (Point const &p, Piecewise< D2< SBasis > > const &c) |
| std::vector< double > | all_nearest_points (Point const &p, Piecewise< D2< SBasis > > const &c) |
| int | winding (Path const &path, Point p) |
| This function computes the winding of the path, given a reference point. | |
| bool | path_direction (Path const &p) |
| This function should only be applied to simple paths (regions), as otherwise a boolean winding direction is undefined. | |
| template<typename T > | |
| void | append (T &a, T const &b) |
| A little sugar for appending a list to another. | |
| bool | linear_intersect (Point A0, Point A1, Point B0, Point B1, double &tA, double &tB, double &det) |
| Finds the intersection between the lines defined by A0 & A1, and B0 & B1. | |
| static void | intersect_polish_root (Curve const &A, double &s, Curve const &B, double &t) |
| void | pair_intersect (Curve const &A, double Al, double Ah, Curve const &B, double Bl, double Bh, Crossings &ret, unsigned depth=0) |
| This uses the local bounds functions of curves to generically intersect two. | |
| Crossings | pair_intersect (Curve const &A, Interval const &Ad, Curve const &B, Interval const &Bd) |
| void | mono_intersect (Curve const &A, double Al, double Ah, Curve const &B, double Bl, double Bh, Crossings &ret, double tol=0.1, unsigned depth=0) |
| Crossings | mono_intersect (Curve const &A, Interval const &Ad, Curve const &B, Interval const &Bd) |
| void | mono_pair (Path const &A, double Al, double Ah, Path const &B, double Bl, double Bh, Crossings &ret, double, unsigned depth=0) |
| Takes two paths and time ranges on them, with the invariant that the paths are monotonic on the range. | |
| std::vector< double > | curve_mono_splits (Curve const &d) |
| This returns the times when the x or y derivative is 0 in the curve. | |
| std::vector< double > | offset_doubles (std::vector< double > const &x, double offs) |
| Convenience function to add a value to each entry in a vector of doubles. | |
| std::vector< double > | path_mono_splits (Path const &p) |
| Finds all the monotonic splits for a path. | |
| std::vector< std::vector < double > > | paths_mono_splits (std::vector< Path > const &ps) |
| Applies path_mono_splits to multiple paths, and returns the results such that time-set i corresponds to Path i. | |
| std::vector< std::vector< Rect > > | split_bounds (std::vector< Path > const &p, std::vector< std::vector< double > > splits) |
| Processes the bounds for a list of paths and a list of splits on them, yielding a list of rects for each. | |
| Crossings | curve_self_crossings (Curve const &a) |
| Crossings | self_crossings (Path const &p) |
| void | flip_crossings (Crossings &crs) |
| CrossingSet | crossings_among (std::vector< Path > const &p) |
| bool | contains (Path const &p, Point i, bool evenodd=true) |
| template<typename T > | |
| Crossings | curve_sweep (Path const &a, Path const &b) |
| Crossings | crossings (Curve const &a, Curve const &b) |
| Crossings | crossings (Path const &a, Path const &b) |
| CrossingSet | crossings (std::vector< Path > const &a, std::vector< Path > const &b) |
| template<typename iter > | |
| iter | inc (iter const &x, unsigned n) |
| static Piecewise< D2< SBasis > > | paths_to_pw (std::vector< Path > paths) |
| Coord | nearest_point (Point const &p, Path const &c) |
| PathVector | reverse_paths_and_order (PathVector const &path_in) |
| Reverses all Paths and the order of paths in the vector as well. | |
| OptRect | bounds_fast (PathVector const &pv) |
| OptRect | bounds_exact (PathVector const &pv) |
| boost::optional < PathVectorPosition > | nearestPoint (PathVector const &path_in, Point const &_point, double *distance_squared) |
| std::vector< PathVectorPosition > | allNearestPoints (PathVector const &path_in, Point const &_point, double *distance_squared) |
| void | operator*= (PathVector &path_in, Matrix const &m) |
| PathVector | operator* (PathVector const &path_in, Matrix const &m) |
| void | operator*= (PathVector &path_in, Translate const &m) |
| PathVector | operator* (PathVector const &path_in, Translate const &m) |
| void | operator+= (PathVector &path_in, Point const &p) |
| PathVector | operator+ (PathVector const &path_in, Point const &p) |
| Geom::Point | initialPoint (PathVector const &path_in) |
| Geom::Point | finalPoint (PathVector const &path_in) |
| Point | pointAt (PathVector const &path_in, PathVectorPosition const pvp) |
| Piecewise< SBasis > | divide (Piecewise< SBasis > const &a, Piecewise< SBasis > const &b, unsigned k) |
| Piecewise< SBasis > | divide (Piecewise< SBasis > const &a, Piecewise< SBasis > const &b, double tol, unsigned k, double zero) |
| Piecewise< SBasis > | divide (Piecewise< SBasis > const &a, SBasis const &b, double tol, unsigned k, double zero) |
| Piecewise< SBasis > | divide (SBasis const &a, Piecewise< SBasis > const &b, double tol, unsigned k, double zero) |
| Piecewise< SBasis > | divide (SBasis const &a, SBasis const &b, double tol, unsigned k, double zero) |
| std::map< double, unsigned > | compose_pullback (std::vector< double > const &values, SBasis const &g) |
| int | compose_findSegIdx (std::map< double, unsigned >::iterator const &cut, std::map< double, unsigned >::iterator const &next, std::vector< double > const &levels, SBasis const &g) |
| std::vector< double > | roots (Piecewise< SBasis > const &f) |
| std::vector< std::vector < double > > | multi_roots (Piecewise< SBasis > const &f, std::vector< double > const &values) |
| template<typename T > | |
| FragmentConcept< T >::BoundsType | bounds_fast (const Piecewise< T > &f) |
| template<typename T > | |
| FragmentConcept< T >::BoundsType | bounds_exact (const Piecewise< T > &f) |
| template<typename T > | |
| FragmentConcept< T >::BoundsType | bounds_local (const Piecewise< T > &f, const OptInterval &_m) |
| template<typename T > | |
| T | elem_portion (const Piecewise< T > &a, unsigned i, double from, double to) |
| template<typename T > | |
| Piecewise< T > | partition (const Piecewise< T > &pw, std::vector< double > const &c) |
| Piecewise<T> partition(const Piecewise<T> &pw, std::vector<double> const &c); Further subdivides the Piecewise<T> such that there is a cut at every value in c. | |
| template<typename T > | |
| Piecewise< T > | portion (const Piecewise< T > &pw, double from, double to) |
| Piecewise<T> portion(const Piecewise<T> &pw, double from, double to); Returns a Piecewise<T> with a defined domain of [min(from, to), max(from, to)]. | |
| template<typename T > | |
| Piecewise< T > | remove_short_cuts (Piecewise< T > const &f, double tol) |
| template<typename T > | |
| Piecewise< T > | remove_short_cuts_extending (Piecewise< T > const &f, double tol) |
| template<typename T > | |
| std::vector< double > | roots (const Piecewise< T > &pw) |
| template<typename T > | |
| Piecewise< T > | operator+ (Piecewise< T > const &a, typename T::output_type b) |
| template<typename T > | |
| Piecewise< T > | operator- (Piecewise< T > const &a, typename T::output_type b) |
| template<typename T > | |
| Piecewise< T > & | operator+= (Piecewise< T > &a, typename T::output_type b) |
| template<typename T > | |
| Piecewise< T > & | operator-= (Piecewise< T > &a, typename T::output_type b) |
| template<typename T > | |
| Piecewise< T > | operator- (Piecewise< T > const &a) |
| template<typename T > | |
| Piecewise< T > | operator* (Piecewise< T > const &a, double b) |
| template<typename T > | |
| Piecewise< T > | operator* (Piecewise< T > const &a, T b) |
| template<typename T > | |
| Piecewise< T > | operator/ (Piecewise< T > const &a, double b) |
| template<typename T > | |
| Piecewise< T > & | operator*= (Piecewise< T > &a, double b) |
| template<typename T > | |
| Piecewise< T > & | operator/= (Piecewise< T > &a, double b) |
| template<typename T > | |
| Piecewise< T > | operator+ (Piecewise< T > const &a, Piecewise< T > const &b) |
| template<typename T > | |
| Piecewise< T > | operator- (Piecewise< T > const &a, Piecewise< T > const &b) |
| template<typename T > | |
| Piecewise< T > & | operator+= (Piecewise< T > &a, Piecewise< T > const &b) |
| template<typename T > | |
| Piecewise< T > & | operator-= (Piecewise< T > &a, Piecewise< T > const &b) |
| template<typename T1 , typename T2 > | |
| Piecewise< T2 > | operator* (Piecewise< T1 > const &a, Piecewise< T2 > const &b) |
| template<typename T > | |
| Piecewise< T > & | operator*= (Piecewise< T > &a, Piecewise< T > const &b) |
| template<typename T > | |
| Piecewise< T > | compose (Piecewise< T > const &f, SBasis const &g) |
| template<typename T > | |
| Piecewise< T > | compose (Piecewise< T > const &f, Piecewise< SBasis > const &g) |
| template<typename T > | |
| Piecewise< T > | integral (Piecewise< T > const &a) |
| template<typename T > | |
| Piecewise< T > | derivative (Piecewise< T > const &a) |
| template<typename T > | |
| Piecewise< T > | reverse (Piecewise< T > const &f) |
| Coord | L1 (Point const &p) |
| Compute the L1 norm, or manhattan distance, of p. | |
| Coord | LInfty (Point const &p) |
| Compute the L infinity, or maximum, norm of p. | |
| bool | is_zero (Point const &p) |
| Returns true iff p is a zero vector, i.e. Point(0, 0). | |
| bool | is_unit_vector (Point const &p) |
| Coord | atan2 (Point const p) |
| Coord | angle_between (Point const a, Point const b) |
| compute the angle turning from a to b. | |
| Point | unit_vector (Point const &a) |
| Returns a version of a scaled to be a unit vector (within rounding error). | |
| Point | abs (Point const &b) |
| Point | operator* (Point const &v, Matrix const &m) |
| Point | operator/ (Point const &p, Matrix const &m) |
| Point | constrain_angle (Point const &A, Point const &B, unsigned int n=4, Geom::Point const &dir=Geom::Point(1, 0)) |
| Constrains the angle (with respect to dir) of the line joining A and B to a multiple of pi/n. | |
| Point | operator* (double const s, Point const &p) |
| std::ostream & | operator<< (std::ostream &out_file, const Geom::Point &in_pnt) |
| A function to print out the Point. | |
| Point | operator^ (Point const &a, Point const &b) |
| This is a rotation (sort of). | |
| bool | operator== (Point const &a, Point const &b) |
| bool | operator!= (Point const &a, Point const &b) |
| bool | operator<= (Point const &a, Point const &b) |
| This is a lexicographical ordering for points. | |
| Coord | L2 (Point const &p) |
| Compute the L2, or euclidean, norm of p. | |
| Coord | L2sq (Point const &p) |
| Compute the square of L2 norm of p. | |
| bool | are_near (Point const &a, Point const &b, double const eps=EPSILON) |
| Point | middle_point (Point const &P1, Point const &P2) |
| Point | rot90 (Point const &p) |
| Returns p * Geom::rotate_degrees(90), but more efficient. | |
| Point | lerp (double const t, Point const a, Point const b) |
| Given two points and a parameter t [0, 1], return a point proportionally from a to b by t. | |
| Coord | dot (Point const &a, Point const &b) |
| compute the dot product (inner product) between the vectors a and b. | |
| Coord | cross (Point const &a, Point const &b) |
| Defined as dot(a, b.cw()). | |
| Coord | distance (Point const &a, Point const &b) |
| compute the euclidean distance between points a and b. | |
| Coord | distanceSq (Point const &a, Point const &b) |
| compute the square of the distance between points a and b. | |
| std::vector< std::complex < double > > | solve (Poly const &pp) |
| std::vector< double > | solve_reals (Poly const &p) |
| double | polish_root (Poly const &p, double guess, double tol) |
| Poly | integral (Poly const &p) |
| Poly | derivative (Poly const &p) |
| Poly | compose (Poly const &a, Poly const &b) |
| Poly | divide (Poly const &a, Poly const &b, Poly &r) |
| Poly | gcd (Poly const &a, Poly const &b, const double) |
| Poly | operator* (double a, Poly const &b) |
| Poly | divide_out_root (Poly const &p, double x) |
| std::ostream & | operator<< (std::ostream &out_file, const Poly &in_poly) |
| double | distance (Point const &_point, Ray const &_ray) |
| bool | are_near (Point const &_point, Ray const &_ray, double eps=EPSILON) |
| bool | are_same (Ray const &r1, Ray const &r2, double eps=EPSILON) |
| double | angle_between (Ray const &r1, Ray const &r2, bool cw=true) |
| Ray | make_angle_bisector_ray (Ray const &r1, Ray const &r2) |
| Rect | unify (const Rect &, const Rect &) |
| Rect | union_list (std::vector< Rect > const &r) |
| double | distanceSq (Point const &p, Rect const &rect) |
| double | distance (Point const &p, Rect const &rect) |
| Returns the smallest distance between p and rect. | |
| OptRect | unify (OptRect const &a, OptRect const &b) |
| Returns the smallest rectangle that encloses both rectangles. | |
| OptRect | intersect (Rect const &a, Rect const &b) |
| static void | find_intersections_bezier_recursive (std::vector< std::pair< double, double > > &xs, OldBezier a, OldBezier b) |
| void | find_intersections_bezier_recursive (std::vector< std::pair< double, double > > &xs, vector< Geom::Point > const &A, vector< Geom::Point > const &B, double precision) |
| bool | intersect_BB (OldBezier a, OldBezier b) |
| void | recursively_intersect (OldBezier a, double t0, double t1, int deptha, OldBezier b, double u0, double u1, int depthb, std::vector< std::pair< double, double > > ¶meters) |
| double | log4 (double x) |
| double | Lmax (Point p) |
| unsigned | wangs_theorem (OldBezier a) |
| static int | intersect_polish_f (const gsl_vector *x, void *params, gsl_vector *f) |
| static void | intersect_polish_root (OldBezier &A, double &s, OldBezier &B, double &t) |
| unsigned | outer_index (Regions const &ps) |
| Regions | regions_from_paths (std::vector< Path > const &ps) |
| std::vector< Path > | paths_from_regions (Regions const &rs) |
| Regions | sanitize_path (Path const &p) |
| Regions | region_boolean (bool rev, Region const &a, Region const &b, Crossings const &cr) |
| Regions | region_boolean (bool rev, Region const &a, Region const &b, Crossings const &cr_a, Crossings const &cr_b) |
| Regions | region_boolean (bool rev, Region const &a, Region const &b) |
| SBasis | extract_u (SBasis2d const &a, double u) |
| SBasis | extract_v (SBasis2d const &a, double v) |
| SBasis | compose (Linear2d const &a, D2< SBasis > const &p) |
| SBasis | compose (SBasis2d const &fg, D2< SBasis > const &p) |
| D2< SBasis > | compose_each (D2< SBasis2d > const &fg, D2< SBasis > const &p) |
| SBasis2d | partial_derivative (SBasis2d const &f, int dim) |
| D2< SBasis > | sb2dsolve (SBasis2d const &f, Geom::Point const &A, Geom::Point const &B, unsigned degmax) |
| Finds a path which traces the 0 contour of f, traversing from A to B as a single d2<sbasis>. | |
| D2< SBasis > | sb2d_cubic_solve (SBasis2d const &f, Geom::Point const &A, Geom::Point const &B) |
| Finds a path which traces the 0 contour of f, traversing from A to B as a single cubic d2<sbasis>. | |
| Linear | extract_u (Linear2d const &a, double u) |
| Linear | extract_v (Linear2d const &a, double v) |
| Linear2d | operator- (Linear2d const &a) |
| Linear2d | operator+ (Linear2d const &a, Linear2d const &b) |
| Linear2d | operator- (Linear2d const &a, Linear2d const &b) |
| Linear2d & | operator+= (Linear2d &a, Linear2d const &b) |
| Linear2d & | operator-= (Linear2d &a, Linear2d const &b) |
| Linear2d & | operator*= (Linear2d &a, double b) |
| bool | operator== (Linear2d const &a, Linear2d const &b) |
| bool | operator!= (Linear2d const &a, Linear2d const &b) |
| Linear2d | operator* (double const a, Linear2d const &b) |
| SBasis2d | operator- (const SBasis2d &p) |
| SBasis2d | operator+ (const SBasis2d &a, const SBasis2d &b) |
| SBasis2d | operator- (const SBasis2d &a, const SBasis2d &b) |
| SBasis2d & | operator+= (SBasis2d &a, const Linear2d &b) |
| SBasis2d & | operator-= (SBasis2d &a, const Linear2d &b) |
| SBasis2d & | operator+= (SBasis2d &a, double b) |
| SBasis2d & | operator-= (SBasis2d &a, double b) |
| SBasis2d & | operator*= (SBasis2d &a, double b) |
| SBasis2d & | operator/= (SBasis2d &a, double b) |
| SBasis2d | operator* (double k, SBasis2d const &a) |
| SBasis2d | operator* (SBasis2d const &a, SBasis2d const &b) |
| SBasis2d | shift (SBasis2d const &a, int sh) |
| SBasis2d | shift (Linear2d const &a, int sh) |
| SBasis2d | truncate (SBasis2d const &a, unsigned terms) |
| SBasis2d | multiply (SBasis2d const &a, SBasis2d const &b) |
| SBasis2d | integral (SBasis2d const &c) |
| SBasis2d | sqrt (SBasis2d const &a, int k) |
| SBasis2d | reciprocal (Linear2d const &a, int k) |
| SBasis2d | divide (SBasis2d const &a, SBasis2d const &b, int k) |
| SBasis2d | compose (SBasis2d const &a, SBasis2d const &b) |
| SBasis2d | compose (SBasis2d const &a, SBasis2d const &b, unsigned k) |
| SBasis2d | inverse (SBasis2d const &a, int k) |
| std::ostream & | operator<< (std::ostream &out_file, const Linear2d &bo) |
| std::ostream & | operator<< (std::ostream &out_file, const SBasis2d &p) |
| Piecewise< D2< SBasis > > | cutAtRoots (Piecewise< D2< SBasis > > const &M, double tol=1e-4) |
| Piecewise< SBasis > | atan2 (D2< SBasis > const &vect, double tol=.01, unsigned order=3) |
| Return a function which gives the angle of vect at each point. | |
| Piecewise< SBasis > | atan2 (Piecewise< D2< SBasis > >const &vect, double tol=.01, unsigned order=3) |
| Return a function which gives the angle of vect at each point. | |
| D2< Piecewise< SBasis > > | tan2 (SBasis const &angle, double tol=.01, unsigned order=3) |
| tan2 is the pseudo-inverse of atan2. | |
| D2< Piecewise< SBasis > > | tan2 (Piecewise< SBasis > const &angle, double tol=.01, unsigned order=3) |
| tan2 is the pseudo-inverse of atan2. | |
| Piecewise< D2< SBasis > > | unitVector (D2< SBasis > const &vect, double tol=.01, unsigned order=3) |
| Return a Piecewise<D2<SBasis> > which points in the same direction as V_in, but has unit_length. | |
| Piecewise< D2< SBasis > > | unitVector (Piecewise< D2< SBasis > > const &vect, double tol=.01, unsigned order=3) |
| Return a Piecewise<D2<SBasis> > which points in the same direction as V_in, but has unit_length. | |
| Piecewise< SBasis > | curvature (D2< SBasis > const &M, double tol=.01) |
| returns a function giving the curvature at each point in M. | |
| Piecewise< SBasis > | curvature (Piecewise< D2< SBasis > > const &M, double tol=.01) |
| returns a function giving the curvature at each point in M. | |
| Piecewise< SBasis > | arcLengthSb (D2< SBasis > const &M, double tol=.01) |
| returns a function giving the arclength at each point in M. | |
| Piecewise< SBasis > | arcLengthSb (Piecewise< D2< SBasis > > const &M, double tol=.01) |
| returns a function giving the arclength at each point in M. | |
| double | length (D2< SBasis > const &M, double tol=.01) |
| Calculates the length of a D2<SBasis> through gsl integration. | |
| double | length (Piecewise< D2< SBasis > > const &M, double tol=.01) |
| Calculates the length of a Piecewise<D2<SBasis> > through gsl integration. | |
| void | length_integrating (D2< SBasis > const &B, double &result, double &abs_error, double tol) |
| Calculates the length of a D2<SBasis> through gsl integration. | |
| Piecewise< D2< SBasis > > | arc_length_parametrization (D2< SBasis > const &M, unsigned order=3, double tol=.01) |
| Reparameterise M to have unit speed. | |
| Piecewise< D2< SBasis > > | arc_length_parametrization (Piecewise< D2< SBasis > > const &M, unsigned order=3, double tol=.01) |
| Reparameterise M to have unit speed. | |
| unsigned | centroid (Piecewise< D2< SBasis > > const &p, Point ¢roid, double &area) |
| Centroid using sbasis integration. | |
| std::vector< D2< SBasis > > | cubics_fitting_curvature (Point const &M0, Point const &M1, Point const &dM0, Point const &dM1, double d2M0xdM0, double d2M1xdM1, int insist_on_speed_signs=1, double epsilon=1e-5) |
| returns the cubics fitting direction and curvature of a given input curve at two points. | |
| std::vector< D2< SBasis > > | cubics_fitting_curvature (Point const &M0, Point const &M1, Point const &dM0, Point const &dM1, Point const &d2M0, Point const &d2M1, int insist_on_speed_signs=1, double epsilon=1e-5) |
| std::vector< D2< SBasis > > | cubics_with_prescribed_curvature (Point const &M0, Point const &M1, Point const &dM0, Point const &dM1, double k0, double k1, int insist_on_speed_signs=1, double error=1e-5) |
| std::vector< double > | find_tangents (Point P, D2< SBasis > const &A) |
| returns all the parameter values of A whose tangent passes through P. | |
| Piecewise< SBasis > | abs (SBasis const &f) |
| Return the absolute value of a function pointwise. | |
| Piecewise< SBasis > | abs (Piecewise< SBasis > const &f) |
| Return the absolute value of a function pointwise. | |
| Piecewise< SBasis > | max (SBasis const &f, SBasis const &g) |
| Return the greater of the two functions pointwise. | |
| Piecewise< SBasis > | max (Piecewise< SBasis > const &f, SBasis const &g) |
| Return the greater of the two functions pointwise. | |
| Piecewise< SBasis > | max (SBasis const &f, Piecewise< SBasis > const &g) |
| Return the greater of the two functions pointwise. | |
| Piecewise< SBasis > | max (Piecewise< SBasis > const &f, Piecewise< SBasis > const &g) |
| Return the greater of the two functions pointwise. | |
| Piecewise< SBasis > | min (SBasis const &f, SBasis const &g) |
| Return the more negative of the two functions pointwise. | |
| Piecewise< SBasis > | min (Piecewise< SBasis > const &f, SBasis const &g) |
| Return the more negative of the two functions pointwise. | |
| Piecewise< SBasis > | min (SBasis const &f, Piecewise< SBasis > const &g) |
| Return the more negative of the two functions pointwise. | |
| Piecewise< SBasis > | min (Piecewise< SBasis > const &f, Piecewise< SBasis > const &g) |
| Return the more negative of the two functions pointwise. | |
| Piecewise< SBasis > | signSb (SBasis const &f) |
| Return the sign of the two functions pointwise. | |
| Piecewise< SBasis > | signSb (Piecewise< SBasis > const &f) |
| Return the sign of the two functions pointwise. | |
| static Piecewise< SBasis > | sqrt_internal (SBasis const &f, double tol, int order) |
| Piecewise< SBasis > | sqrt (SBasis const &f, double tol, int order) |
| Compute the sqrt of a function. | |
| Piecewise< SBasis > | sqrt (Piecewise< SBasis > const &f, double tol, int order) |
| Compute the sqrt of a function. | |
| Piecewise< SBasis > | sin (SBasis const &f, double tol, int order) |
| Compute the sine of a function. | |
| Piecewise< SBasis > | sin (Piecewise< SBasis > const &f, double tol, int order) |
| Compute the sine of a function. | |
| Piecewise< SBasis > | cos (Piecewise< SBasis > const &f, double tol, int order) |
| Compute the cosine of a function. | |
| Piecewise< SBasis > | cos (SBasis const &f, double tol, int order) |
| Compute the cosine of a function. | |
| void | truncateResult (Piecewise< SBasis > &f, int order) |
| Piecewise< SBasis > | reciprocalOnDomain (Interval range, double tol) |
| Piecewise< SBasis > | reciprocal (SBasis const &f, double tol, int order) |
| Piecewise< SBasis > | reciprocal (Piecewise< SBasis > const &f, double tol, int order) |
| Piecewise< SBasis > | interpolate (std::vector< double > times, std::vector< double > values, unsigned smoothness) |
| Retruns a Piecewise SBasis with prescribed values at prescribed times. | |
| Piecewise< SBasis > | log (SBasis const &f, double tol=1e-3, int order=3) |
| Piecewise< SBasis > | log (Piecewise< SBasis >const &f, double tol=1e-3, int order=3) |
| SBasis | poly_to_sbasis (Poly const &p) |
| Changes the basis of p to be sbasis. | |
| Poly | sbasis_to_poly (SBasis const &sb) |
| Changes the basis of p to be monomial. | |
| OptInterval | bounds_exact (SBasis const &a) |
| Find the smallest interval that bounds a. | |
| OptInterval | bounds_fast (const SBasis &sb, int order) |
| Find a small interval that bounds a. | |
| OptInterval | bounds_local (const SBasis &sb, const OptInterval &i, int order) |
| Find a small interval that bounds a(t) for t in i to order order. | |
| static int | upper_level (vector< double > const &levels, double x, double tol=0.) |
| static void | multi_roots_internal (SBasis const &f, SBasis const &df, std::vector< double > const &levels, std::vector< std::vector< double > > &roots, double htol, double vtol, double a, double fa, double b, double fb) |
| std::vector< std::vector < double > > | multi_roots (SBasis const &f, std::vector< double > const &levels, double htol, double vtol, double a, double b) |
| Solve f(t)=c for several c at once. | |
| void | subdiv_sbasis (SBasis const &s, std::vector< double > &roots, double left, double right) |
| std::vector< double > | roots1 (SBasis const &s) |
| std::vector< double > | roots (SBasis const &s) |
| Find all t s.t s(t) = 0. | |
| double | binomial (unsigned int n, unsigned int k) |
| int | sgn (unsigned int j, unsigned int k) |
| void | sbasis_to_bezier (Bezier &bz, SBasis const &sb, size_t sz) |
| Changes the basis of p to be bernstein. | |
| void | sbasis_to_bezier (std::vector< Point > &bz, D2< SBasis > const &sb, size_t sz) |
| Changes the basis of p to be Bernstein. | |
| void | bezier_to_sbasis (D2< SBasis > &sb, std::vector< Point > const &bz) |
| Changes the basis of d2 p to be sbasis. | |
| void | build_from_sbasis (Geom::PathBuilder &pb, D2< SBasis > const &B, double tol, bool only_cubicbeziers) |
| Make a path from a d2 sbasis. | |
| Path | path_from_sbasis (D2< SBasis > const &B, double tol, bool only_cubicbeziers) |
| Make a path from a d2 sbasis. | |
| std::vector< Geom::Path > | path_from_piecewise (Geom::Piecewise< Geom::D2< Geom::SBasis > > const &B, double tol, bool only_cubicbeziers) |
| Make a path from a d2 sbasis. | |
| Path | cubicbezierpath_from_sbasis (D2< SBasis > const &B, double tol) |
| SBasis | operator+ (const SBasis &a, const SBasis &b) |
| Compute the pointwise sum of a and b (Exact). | |
| SBasis | operator- (const SBasis &a, const SBasis &b) |
| Compute the pointwise difference of a and b (Exact). | |
| SBasis & | operator+= (SBasis &a, const SBasis &b) |
| Compute the pointwise sum of a and b and store in a (Exact). | |
| SBasis & | operator-= (SBasis &a, const SBasis &b) |
| Compute the pointwise difference of a and b and store in a (Exact). | |
| SBasis | operator* (SBasis const &a, double k) |
| Compute the pointwise product of a and b (Exact). | |
| SBasis & | operator*= (SBasis &a, double b) |
| Compute the pointwise product of a and b and store the value in a (Exact). | |
| SBasis | shift (SBasis const &a, int sh) |
| multiply a by x^sh in place (Exact) | |
| SBasis | shift (Linear const &a, int sh) |
| multiply a by x^sh (Exact) | |
| SBasis | multiply_add (SBasis const &a, SBasis const &b, SBasis c) |
| Compute the pointwise product of a and b adding c (Exact). | |
| SBasis | multiply (SBasis const &a, SBasis const &b) |
| Compute the pointwise product of a and b (Exact). | |
| SBasis | integral (SBasis const &c) |
| Compute the integral of a (Exact). | |
| SBasis | derivative (SBasis const &a) |
| Compute the derivative of a (Exact). | |
| SBasis | sqrt (SBasis const &a, int k) |
| Compute the sqrt of a. | |
| SBasis | reciprocal (Linear const &a, int k) |
| Compute the recpirocal of a. | |
| SBasis | divide (SBasis const &a, SBasis const &b, int k) |
| Compute a / b to k terms. | |
| SBasis | compose (SBasis const &a, SBasis const &b) |
| Compute a composed with b. | |
| SBasis | compose (SBasis const &a, SBasis const &b, unsigned k) |
| Compute a composed with b to k terms. | |
| SBasis | inverse (SBasis a, int k) |
| find the function a^-1 such that a^-1 composed with a to k terms is the identity function | |
| SBasis | sin (Linear b, int k) |
| Compute the sine of a to k terms. | |
| SBasis | cos (Linear bo, int k) |
| Compute the cosine of a. | |
| SBasis | compose_inverse (SBasis const &f, SBasis const &g, unsigned order, double zero) |
| compute fog^-1. | |
| SBasis | reverse (SBasis const &a) |
| Returns a function which reverses the domain of a. | |
| SBasis | operator- (const SBasis &p) |
| SBasis | operator* (double k, SBasis const &a) |
| SBasis | operator/ (SBasis const &a, double k) |
| SBasis & | operator/= (SBasis &a, double b) |
| SBasis | operator+ (const SBasis &a, double b) |
| SBasis | operator- (const SBasis &a, double b) |
| SBasis & | operator+= (SBasis &a, double b) |
| SBasis & | operator-= (SBasis &a, double b) |
| SBasis | truncate (SBasis const &a, unsigned terms) |
| SBasis | operator* (SBasis const &a, SBasis const &b) |
| SBasis & | operator*= (SBasis &a, SBasis const &b) |
| unsigned | valuation (SBasis const &a, double tol=0) |
| Returns the degree of the first non zero coefficient. | |
| SBasis | portion (const SBasis &t, double from, double to) |
| Returns the sbasis on domain [0,1] that was t on [from, to]. | |
| SBasis | portion (const SBasis &t, Interval ivl) |
| std::ostream & | operator<< (std::ostream &out_file, const Linear &bo) |
| std::ostream & | operator<< (std::ostream &out_file, const SBasis &p) |
| void | first_false (std::vector< std::vector< bool > > visited, unsigned &i, unsigned &j) |
| unsigned | find_crossing (Crossings const &cr, Crossing x, unsigned i) |
| Shape | shape_boolean (bool rev, Shape const &a, Shape const &b, CrossingSet const &crs) |
| Shape | shape_boolean (bool rev, Shape const &a, Shape const &b) |
| std::vector< double > | region_sizes (Shape const &a) |
| Shape | shape_boolean_ra (bool rev, Shape const &a, Shape const &b, CrossingSet const &crs) |
| Shape | shape_boolean_rb (bool rev, Shape const &a, Shape const &b, CrossingSet const &crs) |
| Shape | boolop (Shape const &a, Shape const &b, unsigned flags, CrossingSet const &crs) |
| Shape | boolop (Shape const &a, Shape const &b, unsigned flags) |
| int | paths_winding (std::vector< Path > const &ps, Point p) |
| void | add_to_shape (Shape &s, Path const &p, bool fill) |
| int | inner_winding (Path const &p, std::vector< Path > const &ps) |
| double | fudgerize (double d, bool rev) |
| unsigned | pick_coincident (unsigned ix, unsigned jx, bool &rev, std::vector< Path > const &ps, CrossingSet const &crs) |
| unsigned | crossing_along (double t, unsigned ix, unsigned jx, bool dir, Crossings const &crs) |
| void | crossing_dual (unsigned &i, unsigned &j, CrossingSet const &crs) |
| void | outer_crossing (unsigned &ix, unsigned &jx, bool &dir, std::vector< Path > const &ps, CrossingSet const &crs) |
| std::vector< Path > | inner_sanitize (std::vector< Path > const &ps) |
| Shape | sanitize (std::vector< Path > const &ps) |
| Shape | stopgap_cleaner (std::vector< Path > const &ps) |
| CrossingSet | crossings_between (Shape const &a, Shape const &b) |
| Shape | boolop (Shape const &, Shape const &, unsigned flags, CrossingSet &) |
| std::vector< Path > | desanitize (Shape const &s) |
| template<class t > | |
| static int | SGN (t x) |
| void | find_bernstein_roots (double const *w, unsigned degree, std::vector< double > &solutions, unsigned depth, double left_t, double right_t, bool use_secant) |
| static Geom::Point | Bezier (Geom::Point const *V, unsigned degree, double t, Geom::Point *Left, Geom::Point *Right) |
| unsigned | crossing_count (Geom::Point const *V, unsigned degree) |
| static unsigned | control_poly_flat_enough (Geom::Point const *V, unsigned degree) |
| static double | compute_x_intercept (Geom::Point const *V, unsigned degree) |
| void | find_parametric_bezier_roots (Geom::Point const *w, unsigned degree, std::vector< double > &solutions, unsigned depth) |
| unsigned | crossing_count (double const *V, unsigned degree, double left_t, double right_t) |
| template<class charT > | |
| std::basic_ostream< charT > & | operator<< (std::basic_ostream< charT > &os, const SVGEllipticalArc &ea) |
| void | parse_svg_path (char const *str, SVGPathSink &sink) throw (SVGPathParseError) |
| std::vector< Path > | parse_svg_path (char const *str) throw (SVGPathParseError) |
| std::vector< Path > | read_svgd (char const *name) throw (SVGPathParseError) |
| void | output (Curve const &curve, SVGPathSink &sink) |
| void | output (HLineSegment const &curve, SVGPathSink &sink) |
| void | output (VLineSegment const &curve, SVGPathSink &sink) |
| void | output (LineSegment const &curve, SVGPathSink &sink) |
| void | output (SVGEllipticalArc const &curve, SVGPathSink &sink) |
| template<typename T > | |
| bool | output_as (Curve const &curve, SVGPathSink &sink) |
| void | output_svg_path (Path &path, SVGPathSink &sink) |
| std::vector< std::vector < unsigned > > | sweep_bounds (std::vector< Rect > rs, Dim2 d) |
| Make a list of pairs of self intersections in a list of Rects. | |
| std::vector< std::vector < unsigned > > | sweep_bounds (std::vector< Rect > a, std::vector< Rect > b, Dim2 d) |
| Make a list of pairs of red-blue intersections between two lists of Rects. | |
| std::vector< std::vector < unsigned > > | fake_cull (unsigned a, unsigned b) |
| Matrix | operator* (Translate const &t, Scale const &s) |
| Matrix | operator* (Translate const &t, Rotate const &r) |
| Matrix | operator* (Scale const &s, Translate const &t) |
| Matrix | operator* (Scale const &s, Matrix const &m) |
| Matrix | operator* (Matrix const &m, Translate const &t) |
| Matrix | operator* (Matrix const &m, Scale const &s) |
| Matrix | operator* (Matrix const &m, Rotate const &r) |
| Translate | pow (Translate const &t, int n) |
| Coord | pow (Coord x, long n) |
| Scale | pow (Scale const &s, int n) |
| Rotate | pow (Rotate x, long n) |
| Matrix | pow (Matrix x, long n) |
| Point | operator* (Point const &v, Translate const &t) |
| Point | operator* (Point const &p, Scale const &s) |
| Point | operator* (Point const &v, Rotate const &r) |
| Rotate | pow (Rotate t, int n) |
| Matrix | pow (Matrix t, int n) |
| void | binomial_coefficients (std::vector< size_t > &bc, size_t n) |
| bool | logical_xor (bool a, bool b) |
| template<class T > | |
| int | sgn (const T &x) |
| Sign function - indicates the sign of a numeric type. | |
| template<class T > | |
| T | sqr (const T &x) |
| template<class T > | |
| T | cube (const T &x) |
| template<class T > | |
| const T & | between (const T &min, const T &max, const T &x) |
| Between function - returns true if a number x is within a range. | |
| double | round (double const x) |
| Returns x rounded to the nearest integer. | |
| double | decimal_round (double const x, int const places) |
| Returns x rounded to the nearest places decimal places. | |
| NodeType | get_nodetype (Curve const &c_incoming, Curve const &c_outgoing) |
| bool | transform_equalp (Geom::Matrix const &m0, Geom::Matrix const &m1, Geom::Coord const epsilon) |
| bool | translate_equalp (Geom::Matrix const &m0, Geom::Matrix const &m1, Geom::Coord const epsilon) |
| bool | matrix_equalp (Geom::Matrix const &m0, Geom::Matrix const &m1, Geom::Coord const epsilon) |
Variables | |
| static Point const | unconstrained_tangent (0, 0) |
| const Coord | EPSILON = 1e-5 |
| const double | INV_EPS = (1L<<14) |
| const unsigned | MAXDEPTH = 23 |
| const double | BEPSILON = ldexp(1.0,(-MAXDEPTH-1)) |
| const double | SECANT_EPSILON = 1e-13 |
| unsigned | total_steps |
| unsigned | total_subs |
Detailed Description
A convex cover is a sequence of convex polygons that completely cover the path.
Specific nodetype geometry functions for Inkscape, not provided my lib2geom.
Various utility functions.
Shapes are special paths on which boolops can be performed.
Various geometrical calculations.
For now a convex hull class is included here (the convex-hull header is wrong)
Authors: Michael G. Sloan <mgsloan@gmail.com> Nathan Hurst <njh@mail.csse.monash.edu.au> MenTaLguY <mental@rydia.net>
Copyright 2007-2009 Authors
This library is free software; you can redistribute it and/or modify it either under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation (the "LGPL") or, at your option, under the terms of the Mozilla Public License Version 1.1 (the "MPL"). If you do not alter this notice, a recipient may use your version of this file under either the MPL or the LGPL.
You should have received a copy of the LGPL along with this library in the file COPYING-LGPL-2.1; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You should have received a copy of the MPL along with this library in the file COPYING-MPL-1.1
The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the LGPL or the MPL for the specific language governing rights and limitations.
Copyright 2008 Marco Cecchetti <mrcekets at gmail.com> Copyright 2007 Johan Engelen <goejendaagh@zonnet.nl> Copyright 2006 Michael G. Sloan <mgsloan@gmail.com>
This library is free software; you can redistribute it and/or modify it either under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation (the "LGPL") or, at your option, under the terms of the Mozilla Public License Version 1.1 (the "MPL"). If you do not alter this notice, a recipient may use your version of this file under either the MPL or the LGPL.
You should have received a copy of the LGPL along with this library in the file COPYING-LGPL-2.1; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You should have received a copy of the MPL along with this library in the file COPYING-MPL-1.1
The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the LGPL or the MPL for the specific language governing rights and limitations.
Author: Johan Engelen <goejendaagh@zonnet.nl>
Copyright (C) 2008 Johan Engelen
Released under GNU GPL
Typedef Documentation
| typedef Point Geom::BezierCurve[] |
Definition at line 61 of file bezier-utils.cpp.
| typedef double Geom::Coord |
A "real" type with sufficient precision for coordinates.
You may safely assume that double (or even float) provides enough precision for storing on-canvas points, and hence that double provides enough precision for dot products of differences of on-canvas points.
| typedef std::vector<Crossing> Geom::Crossings |
Definition at line 125 of file crossing.h.
| typedef std::vector<Crossings> Geom::CrossingSet |
Definition at line 127 of file crossing.h.
| typedef BezierCurve< 3 > Geom::CubicBezier |
Definition at line 193 of file bezier-curve.h.
| typedef SimpleCrosser Geom::DefaultCrosser |
Definition at line 85 of file path-intersection.h.
| typedef long Geom::ICoord |
| typedef std::back_insert_iterator<std::vector<Path> > Geom::iter |
Definition at line 144 of file svg-path.h.
| typedef BezierCurve< 1 > Geom::LineSegment |
Definition at line 191 of file bezier-curve.h.
| typedef boost::optional<Crossing> Geom::OptCrossing |
Definition at line 63 of file crossing.h.
| typedef std::vector< Geom::Path > Geom::PathVector |
Definition at line 76 of file 2geom/forward.h.
| typedef BezierCurve< 2 > Geom::QuadraticBezier |
Definition at line 192 of file bezier-curve.h.
| typedef D2< Interval > Geom::Rect |
D2<Interval> specialization to Rect.
Definition at line 82 of file 2geom/forward.h.
| typedef std::vector<Region> Geom::Regions |
Enumeration Type Documentation
| anonymous enum |
Definition at line 48 of file 2geom/shape.h.
{
BOOLOP_JUST_A = 1,
BOOLOP_JUST_B = 2,
BOOLOP_BOTH = 4,
BOOLOP_NEITHER = 8
};
| anonymous enum |
- Enumerator:
BOOLOP_NULL BOOLOP_INTERSECT BOOLOP_SUBTRACT_A_B BOOLOP_IDENTITY_A BOOLOP_SUBTRACT_B_A BOOLOP_IDENTITY_B BOOLOP_EXCLUSION BOOLOP_UNION
Definition at line 55 of file 2geom/shape.h.
{
BOOLOP_NULL = 0,
BOOLOP_INTERSECT = BOOLOP_BOTH,
BOOLOP_SUBTRACT_A_B = BOOLOP_JUST_B,
BOOLOP_IDENTITY_A = BOOLOP_JUST_A | BOOLOP_BOTH,
BOOLOP_SUBTRACT_B_A = BOOLOP_JUST_A,
BOOLOP_IDENTITY_B = BOOLOP_JUST_B | BOOLOP_BOTH,
BOOLOP_EXCLUSION = BOOLOP_JUST_A | BOOLOP_JUST_B,
BOOLOP_UNION = BOOLOP_JUST_A | BOOLOP_JUST_B | BOOLOP_BOTH
};
| enum Geom::Dim2 |
Definition at line 47 of file 2geom/geom.h.
{
intersects = 0,
parallel,
coincident,
no_intersection
};
| enum Geom::NodeType |
What kind of node is this? This is the value for the node->type field.
NodeType indicates the degree of continuity required for the node. I think that the corresponding integer indicates which derivate is connected. (Thus 2 means that the node is continuous to the second derivative, i.e. has matching endpoints and tangents)
- Enumerator:
Definition at line 26 of file geom-nodetype.h.
{
NODE_NONE,
NODE_CUSP,
NODE_SMOOTH,
NODE_SYMM
} NodeType;
Function Documentation
Return the absolute value of a function pointwise.
- Parameters:
-
f function
Return the absolute value of a function pointwise.
- Parameters:
-
f function
Definition at line 308 of file 2geom/shape.cpp.
References Geom::Shape::content.
| std::vector< double > Geom::all_nearest_points | ( | Point const & | p, | |
| D2< SBasis > const & | c, | |||
| D2< SBasis > const & | dc, | |||
| double | from, | |||
| double | to | |||
| ) |
Referenced by all_nearest_points(), Geom::SBasisCurve::allNearestPoints(), and Geom::Curve::allNearestPoints().
| std::vector< double > Geom::all_nearest_points | ( | Point const & | p, | |
| Piecewise< D2< SBasis > > const & | c, | |||
| double | from, | |||
| double | to | |||
| ) |
| std::vector<double> Geom::all_nearest_points | ( | Point const & | p, | |
| Piecewise< D2< SBasis > > const & | c | |||
| ) | [inline] |
Definition at line 124 of file nearest-point.h.
References all_nearest_points(), and c.
| std::vector<double> Geom::all_nearest_points | ( | Point const & | p, | |
| D2< SBasis > const & | c, | |||
| double | from = 0, |
|||
| double | to = 1 | |||
| ) | [inline] |
Definition at line 95 of file nearest-point.h.
References all_nearest_points(), and derivative().
{
return all_nearest_points(p, c, Geom::derivative(c), from, to);
}
| std::vector< PathVectorPosition > Geom::allNearestPoints | ( | PathVector const & | path_in, | |
| Point const & | _point, | |||
| double * | distance_squared | |||
| ) |
compute the angle turning from a to b.
compute the angle turning from a to b (signed).
This should give
for angle_between(a, rot90(a)); This works by projecting b onto the basis defined by a, rot90(a)
| double Geom::angle_between | ( | Ray const & | r1, | |
| Ray const & | r2, | |||
| bool | cw = true | |||
| ) | [inline] |
Definition at line 220 of file ray.h.
References Geom::detail::bezier_clipping::angle(), angle_between(), M_PI, and Geom::Ray::versor().
{
double angle = angle_between(r1.versor(), r2.versor());
if (angle < 0) angle += 2*M_PI;
if (!cw) angle = 2*M_PI - angle;
return angle;
}
| double Geom::angle_between | ( | Line const & | l1, | |
| Line const & | l2 | |||
| ) | [inline] |
Definition at line 303 of file line.h.
References Geom::detail::bezier_clipping::angle(), M_PI, and Geom::Line::versor().
Referenced by Inkscape::UI::Handle::_getDragTip(), angle_between(), Inkscape::LivePathEffect::append_half_circle(), Geom::Ellipse::arc(), Geom::SVGEllipticalArc::calculate_center_and_extreme_angles(), Inkscape::UI::SkewHandle::computeTransform(), Inkscape::UI::RotateHandle::computeTransform(), Inkscape::LivePathEffect::LPEAngleBisector::doEffect_path(), Inkscape::LivePathEffect::LPETextLabel::doEffect_pwd2(), Inkscape::UI::Handle::dragged(), Inkscape::UI::Node::grabbed(), Inkscape::LivePathEffect::CR::KnotHolderEntityRotationAngle::knot_set(), Inkscape::LivePathEffect::CR::KnotHolderEntityStartingAngle::knot_set(), make_angle_bisector_line(), make_angle_bisector_ray(), set_pos_and_anchor(), and Inkscape::LivePathEffect::TextParam::setPosAndAnchor().
{
double angle = angle_between(l1.versor(), l2.versor());
if (angle < 0) angle += M_PI;
if (angle == M_PI) angle = 0;
return angle;
}
| void Geom::append | ( | T & | a, | |
| T const & | b | |||
| ) |
A little sugar for appending a list to another.
Definition at line 52 of file 2geom/shape.cpp.
Referenced by boolop(), curve_mono_splits(), and curve_self_crossings().
| Piecewise< D2< SBasis > > Geom::arc_length_parametrization | ( | D2< SBasis > const & | M, | |
| unsigned | order = 3, |
|||
| double | tol = .01 | |||
| ) |
Reparameterise M to have unit speed.
- Parameters:
-
M the Element. tol the maximum error allowed. order the maximum degree to use for approximation
Definition at line 401 of file sbasis-geometric.cpp.
References arcLengthSb(), Geom::SBasis::at0(), Geom::SBasis::at1(), compose(), compose_inverse(), Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, Geom::Piecewise< T >::push(), Geom::Piecewise< T >::push_cut(), Geom::Piecewise< T >::segs, and Geom::Piecewise< T >::size().
Referenced by arc_length_parametrization(), Inkscape::LivePathEffect::LPECurveStitch::doEffect_path(), Inkscape::LivePathEffect::LPERecursiveSkeleton::doEffect_pwd2(), Inkscape::LivePathEffect::LPEPatternAlongPath::doEffect_pwd2(), Inkscape::LivePathEffect::LPEEnvelope::doEffect_pwd2(), Inkscape::LivePathEffect::LPEBendPath::doEffect_pwd2(), set_pos_and_anchor(), and Inkscape::LivePathEffect::TextParam::setPosAndAnchor().
{
Piecewise<D2<SBasis> > u;
u.push_cut(0);
Piecewise<SBasis> s = arcLengthSb(Piecewise<D2<SBasis> >(M),tol);
for (unsigned i=0; i < s.size();i++){
double t0=s.cuts[i],t1=s.cuts[i+1];
D2<SBasis> sub_M = compose(M,Linear(t0,t1));
D2<SBasis> sub_u;
for (unsigned dim=0;dim<2;dim++){
SBasis sub_s = s.segs[i];
sub_s-=sub_s.at0();
sub_s/=sub_s.at1();
sub_u[dim]=compose_inverse(sub_M[dim],sub_s, order, tol);
}
u.push(sub_u,s(t1));
}
return u;
}
| Piecewise< D2< SBasis > > Geom::arc_length_parametrization | ( | Piecewise< D2< SBasis > > const & | M, | |
| unsigned | order = 3, |
|||
| double | tol = .01 | |||
| ) |
Reparameterise M to have unit speed.
- Parameters:
-
M the Element. tol the maximum error allowed. order the maximum degree to use for approximation
Definition at line 430 of file sbasis-geometric.cpp.
References arc_length_parametrization(), Geom::Piecewise< T >::concat(), Barcode::Code39Ext::i, and org::w3c::dom::svg::result.
{
Piecewise<D2<SBasis> > result;
for (unsigned i=0; i<M.size(); i++ ){
Piecewise<D2<SBasis> > uniform_seg=arc_length_parametrization(M[i],order,tol);
result.concat(uniform_seg);
}
return(result);
}
returns a function giving the arclength at each point in M.
- Parameters:
-
M the Element. tol the maximum error allowed.
Definition at line 320 of file sbasis-geometric.cpp.
References derivative(), dot(), integral(), length(), M, Geom::Piecewise< T >::segs, and sqrt().
{
Piecewise<D2<SBasis> > dM = derivative(M);
Piecewise<SBasis> dMlength = sqrt(dot(dM,dM),tol,3);
Piecewise<SBasis> length = integral(dMlength);
length-=length.segs.front().at0();
return length;
}
returns a function giving the arclength at each point in M.
- Parameters:
-
M the Element. tol the maximum error allowed.
Definition at line 334 of file sbasis-geometric.cpp.
Referenced by arc_length_parametrization(), Inkscape::LivePathEffect::LPESketch::doEffect_pwd2(), Inkscape::LivePathEffect::LPERuler::doEffect_pwd2(), Inkscape::LivePathEffect::LPEDynastroke::doEffect_pwd2(), and SPCurve::stretch_endpoints().
{
return arcLengthSb(Piecewise<D2<SBasis> >(M), tol);
}
| bool Geom::are_near | ( | Coord | a, | |
| Coord | b, | |||
| double | eps = EPSILON | |||
| ) | [inline] |
Definition at line 54 of file coord.h.
Referenced by Inkscape::UI::PathManipulator::_createControlPointsFromGeometry(), Inkscape::UI::ControlPointSelection::_keyboardScale(), Inkscape::UI::TransformHandleSet::_updateVisibility(), Geom::SVGEllipticalArc::allNearestPoints(), Geom::EllipticalArc::allNearestPoints(), Inkscape::LivePathEffect::are_colinear(), are_collinear(), are_near(), are_orthogonal(), are_parallel(), are_same(), SvgPathGeomTest::bpathEqual(), Geom::SVGEllipticalArc::calculate_center_and_extreme_angles(), Geom::EllipticalArc::calculate_center_and_extreme_angles(), Inkscape::UI::SkewHandle::computeTransform(), Inkscape::UI::ScaleSideHandle::computeTransform(), Inkscape::UI::ScaleCornerHandle::computeTransform(), Geom::NearConcept< T >::constraints(), Inkscape::LivePathEffect::LPESpiro::doEffect(), Inkscape::LivePathEffect::LPECurveStitch::doEffect_path(), Inkscape::LivePathEffect::LPEExtrude::doEffect_pwd2(), Geom::detail::intersection_impl(), Geom::detail::bezier_clipping::is_constant(), is_straight_curve(), Geom::SVGEllipticalArc::isDegenerate(), Geom::EllipticalArc::isDegenerate(), Geom::Matrix::isIdentity(), Geom::Matrix::isTranslation(), make_angle_bisector_ray(), Geom::make_elliptical_arc::make_elliptiarc(), Inkscape::UI::Handle::move(), Geom::SVGEllipticalArc::nearestPoint(), Geom::EllipticalArc::nearestPoint(), SPCurve::nodes_in_path(), pick_coincident(), Geom::detail::bezier_clipping::pick_orientation_line(), Inkscape::UI::Node::pickBestType(), Geom::SVGEllipticalArc::portion(), Geom::EllipticalArc::portion(), Inkscape::LivePathEffect::LPECurveStitch::resetDefaults(), Inkscape::LivePathEffect::LPEBendPath::resetDefaults(), Geom::SVGEllipticalArc::roots(), Geom::EllipticalArc::roots(), Geom::Ellipse::set(), Geom::Ray::setBy2Points(), Geom::Line::setBy2Points(), Geom::Matrix::setExpansionX(), Geom::Matrix::setExpansionY(), Inkscape::UI::Handle::setPosition(), Inkscape::Extension::Internal::LaTeXTextRenderer::sp_flowtext_render(), sp_guide_description(), sp_svg_transform_write(), Inkscape::Extension::Internal::LaTeXTextRenderer::sp_text_render(), Geom::Ellipse::transformed(), Geom::Curve::unitTangentAt(), and SPDesktop::zoom_quick().
Definition at line 267 of file line.h.
References are_near(), and distance().
| bool Geom::are_near | ( | Point const & | _point, | |
| LineSegment const & | _segment, | |||
| double | eps = EPSILON | |||
| ) | [inline] |
Definition at line 319 of file line.h.
References are_near(), and distance().
Definition at line 205 of file ray.h.
References are_near(), and distance().
| bool Geom::are_near | ( | D2< T > const & | a, | |
| D2< T > const & | b, | |||
| double | tol | |||
| ) | [inline] |
| bool Geom::are_orthogonal | ( | Line const & | l1, | |
| Line const & | l2, | |||
| double | eps = EPSILON | |||
| ) | [inline] |
Definition at line 286 of file line.h.
References are_near(), Geom::Point::ccw(), Geom::Point::cw(), and Geom::Line::versor().
| bool Geom::are_parallel | ( | Line const & | l1, | |
| Line const & | l2, | |||
| double | eps = EPSILON | |||
| ) | [inline] |
Definition at line 273 of file line.h.
References are_near(), and Geom::Line::versor().
Referenced by are_same().
| bool Geom::are_same | ( | Ray const & | r1, | |
| Ray const & | r2, | |||
| double | eps = EPSILON | |||
| ) | [inline] |
Definition at line 211 of file ray.h.
References are_near(), Geom::Ray::origin(), and Geom::Ray::versor().
| bool Geom::are_same | ( | Line const & | l1, | |
| Line const & | l2, | |||
| double | eps = EPSILON | |||
| ) | [inline] |
Definition at line 280 of file line.h.
References are_near(), are_parallel(), and Geom::Line::origin().
{
return are_parallel(l1, l2, eps) && are_near(l1.origin(), l2, eps);
}
Referenced by Inkscape::Text::Layout::_calculateCursorShapeForEmpty(), Inkscape::UI::ControlPointSelection::_keyboardRotate(), Inkscape::UI::Dialogs::GuidelinePropertiesDialog::_setup(), Inkscape::ObjectSnapper::_snapPathsConstrained(), SPGuide::angle(), Geom::Ray::angle(), Geom::Line::angle(), Geom::detail::bezier_clipping::angle(), atan2(), Geom::SVGEllipticalArc::boundsExact(), Geom::EllipticalArc::boundsExact(), Geom::SVGEllipticalArc::calculate_center_and_extreme_angles(), Geom::EllipticalArc::calculate_center_and_extreme_angles(), Inkscape::Text::Layout::characterBoundingBox(), compute_ends(), SnapManager::constrainedSnap(), Inkscape::LineSnapper::constrainedSnap(), Inkscape::LivePathEffect::LPEGears::doEffect_path(), Inkscape::Text::Layout::fitToPathAlign(), Proj::TransfMat3x4::get_infinite_angle(), get_snap_vector(), gr_knot_moved_handler(), grayMapSobel(), SpiralKnotHolderEntityOuter::knot_set(), SpiralKnotHolderEntityInner::knot_set(), StarKnotHolderEntity2::knot_set(), StarKnotHolderEntity1::knot_set(), ArcKnotHolderEntityEnd::knot_set(), ArcKnotHolderEntityStart::knot_set(), PatternKnotHolderEntityAngle::knot_set(), Avoid::Router::markConnectors(), Inkscape::UI::Widget::Rotateable::on_motion(), Inkscape::UI::Widget::Rotateable::on_release(), persp3d_rotate_VP(), Box3D::pos_angle(), Inkscape::Text::Layout::queryCursorShape(), Inkscape::UI::PathManipulator::rotateHandle(), Inkscape::SelTrans::rotateRequest(), Geom::Ellipse::set(), setup_path(), Inkscape::UI::Widget::RegisteredVector::setValue(), sp_color_wheel_button_press(), sp_color_wheel_motion_notify(), sp_color_wheel_render_hue_wheel(), sp_dt_guide_event(), sp_dyna_draw_apply(), sp_eraser_apply(), Inkscape::Extension::Internal::LaTeXTextRenderer::sp_flowtext_render(), sp_item_gradient_set_coords(), sp_pattern_extract_theta(), sp_selection_rotate_screen(), sp_shape_marker_get_transform(), sp_shape_marker_get_transform_at_end(), sp_shape_marker_get_transform_at_start(), sp_spiral_drag(), sp_star_drag(), sp_te_adjust_rotation_screen(), Inkscape::Extension::Internal::LaTeXTextRenderer::sp_text_render(), Gear::spawn(), spdc_pen_set_angle_distance_status_message(), spiro_seg_to_bpath(), NrPointFnsTest::testAtan2(), Geom::Ellipse::transformed(), tweak_colors_in_gradient(), and unclump_dist().
Return a function which gives the angle of vect at each point.
- Parameters:
-
vect a piecewise parameteric curve. tol the maximum error allowed. order the maximum degree to use for approximation
Definition at line 188 of file sbasis-geometric.cpp.
References atan2().
{
return atan2(Piecewise<D2<SBasis> >(vect),tol,order);
}
| Piecewise< SBasis > Geom::atan2 | ( | Piecewise< D2< SBasis > >const & | vect, | |
| double | tol = .01, |
|||
| unsigned | order = 3 | |||
| ) |
Return a function which gives the angle of vect at each point.
- Parameters:
-
vect a piecewise parameteric curve. tol the maximum error allowed. order the maximum degree to use for approximation
Definition at line 157 of file sbasis-geometric.cpp.
References Geom::D2< T >::at0(), atan2(), Geom::Piecewise< T >::concat(), cutAtRoots(), Geom::Piecewise< T >::cuts, derivative(), divide(), Barcode::Code39Ext::i, integral(), RescaleForNonVanishingEnds(), org::w3c::dom::svg::result, Geom::Piecewise< T >::segs, Geom::Piecewise< T >::setDomain(), Geom::Piecewise< T >::size(), voronoi::x, and voronoi::y.
{
Piecewise<SBasis> result;
Piecewise<D2<SBasis> > v = cutAtRoots(vect,tol);
result.cuts.push_back(v.cuts.front());
for (unsigned i=0; i<v.size(); i++){
D2<SBasis> vi = RescaleForNonVanishingEnds(v.segs[i]);
SBasis x=vi[0], y=vi[1];
Piecewise<SBasis> angle;
angle = divide (x*derivative(y)-y*derivative(x), x*x+y*y, tol, order);
//TODO: I don't understand this - sign.
angle = integral(-angle);
Point vi0 = vi.at0();
angle += -std::atan2(vi0[1],vi0[0]) - angle[0].at0();
//TODO: deal with 2*pi jumps form one seg to the other...
//TODO: not exact at t=1 because of the integral.
//TODO: force continuity?
angle.setDomain(Interval(v.cuts[i],v.cuts[i+1]));
result.concat(angle);
}
return result;
}
| T Geom::bernsteinValueAt | ( | double | t, | |
| T const * | c_, | |||
| unsigned | n | |||
| ) | [inline] |
Definition at line 98 of file bezier.h.
References Barcode::Code39Ext::i.
Referenced by Geom::Bezier::valueAndDerivatives().
| const T& Geom::between | ( | const T & | min, | |
| const T & | max, | |||
| const T & | x | |||
| ) | [inline] |
| static Geom::Point Geom::Bezier | ( | Geom::Point const * | V, | |
| unsigned | degree, | |||
| double | t, | |||
| Geom::Point * | Left, | |||
| Geom::Point * | Right | |||
| ) | [static] |
Definition at line 188 of file solve-bezier-parametric.cpp.
References Barcode::Code39Ext::i, and lerp().
Referenced by Geom::BezierCurve< 1 >::BezierCurve(), derivative(), operator*(), operator+(), operator-(), operator/(), portion(), and reverse().
{
Geom::Point Vtemp[degree+1][degree+1];
/* Copy control points */
std::copy(V, V+degree+1, Vtemp[0]);
/* Triangle computation */
for (unsigned i = 1; i <= degree; i++) {
for (unsigned j = 0; j <= degree - i; j++) {
Vtemp[i][j] = lerp(t, Vtemp[i-1][j], Vtemp[i-1][j+1]);
}
}
for (unsigned j = 0; j <= degree; j++)
Left[j] = Vtemp[j][0];
for (unsigned j = 0; j <= degree; j++)
Right[j] = Vtemp[degree-j][j];
return (Vtemp[degree][0]);
}
Fit a single-segment Bezier curve to a set of digitized points.
- Returns:
- Number of segments generated, or -1 on error.
Definition at line 116 of file bezier-utils.cpp.
References bezier_fit_cubic_r().
Referenced by Inkscape::UI::PathManipulator::_deleteStretch().
{
return bezier_fit_cubic_r(bezier, data, len, error, 1);
}
| int Geom::bezier_fit_cubic_full | ( | Point | bezier[], | |
| int | split_points[], | |||
| Point const | data[], | |||
| int const | len, | |||
| Point const & | tHat1, | |||
| Point const & | tHat2, | |||
| double const | error, | |||
| unsigned const | max_beziers | |||
| ) |
Fit a multi-segment Bezier curve to a set of digitized points, without possible weedout of identical points and NaNs.
- Precondition:
- data is uniqued, i.e. not exist i: data[i] == data[i + 1].
- Parameters:
-
max_beziers Maximum number of generated segments Result array, must be large enough for n. segments * 4 elements.
Referenced by fit_and_split(), and sp_spiral_fit_and_draw().
| int Geom::bezier_fit_cubic_r | ( | Point | bezier[], | |
| Point const | data[], | |||
| int const | len, | |||
| double const | error, | |||
| unsigned const | max_beziers | |||
| ) |
Fit a multi-segment Bezier curve to a set of digitized points, with possible weedout of identical points and NaNs.
- Parameters:
-
max_beziers Maximum number of generated segments Result array, must be large enough for n. segments * 4 elements.
- Returns:
- Number of segments generated, or -1 on error.
Referenced by bezier_fit_cubic(), fit_and_split(), interpolate(), and sketch_interpolate().
| std::vector<Point> Geom::bezier_points | ( | const D2< Bezier > & | a | ) | [inline] |
Definition at line 352 of file bezier.h.
References NR::d, Barcode::Code39Ext::i, uniconv-ext::p, and org::w3c::dom::svg::result.
Referenced by Geom::BezierCurve< 1 >::points().
Evaluate a Bezier curve at parameter value t.
- Parameters:
-
degree The degree of the Bezier curve: 3 for cubic, 2 for quadratic etc. Must be less than 4. V The control points for the Bezier curve. Must have (degree+1) elements. t The "parameter" value, specifying whereabouts along the curve to evaluate. Typically in the range [0.0, 1.0].
Let s = 1 - t. BezierII(1, V) gives (s, t) * V, i.e. t of the way from V[0] to V[1]. BezierII(2, V) gives (s**2, 2*s*t, t**2) * V. BezierII(3, V) gives (s**3, 3 s**2 t, 3s t**2, t**3) * V.
The derivative of BezierII(i, V) with respect to t is i * BezierII(i-1, V'), where for all j, V'[j] = V[j + 1] - V[j].
Pascal's triangle.
Referenced by compute_hook(), compute_max_error_ratio(), and NewtonRaphsonRootFind().
| void Geom::bezier_to_sbasis | ( | SBasis & | sb, | |
| Bezier const & | bz | |||
| ) |
Changes the basis of p to be sbasis.
- Parameters:
-
p the Bernstein basis polynomial
- Returns:
- the Symmetric basis polynomial
if the degree is even q is the order in the symmetrical power basis, if the degree is odd q is the order + 1 n is always the polynomial degree, i. e. the Bezier order
Definition at line 192 of file sbasis-to-bezier.cpp.
References binomial(), Geom::SBasis::clear(), Geom::Bezier::order(), Geom::SBasis::resize(), and sgn().
Referenced by handles_to_sbasis(), and Geom::Bezier::toSBasis().
{
size_t n = bz.order();
size_t q = (n+1) / 2;
size_t even = (n & 1u) ? 0 : 1;
sb.clear();
sb.resize(q + even, Linear(0, 0));
double Tjk;
for (size_t k = 0; k < q; ++k)
{
for (size_t j = k; j < q; ++j)
{
Tjk = sgn(j, k) * binomial(n-j-k, j-k) * binomial(n, k);
sb[j][0] += (Tjk * bz[k]);
sb[j][1] += (Tjk * bz[n-k]); // n-j <-> [j][1]
}
for (size_t j = k+1; j < q; ++j)
{
Tjk = sgn(j, k) * binomial(n-j-k-1, j-k-1) * binomial(n, k);
sb[j][0] += (Tjk * bz[n-k]);
sb[j][1] += (Tjk * bz[k]); // n-j <-> [j][1]
}
}
if (even)
{
for (size_t k = 0; k < q; ++k)
{
Tjk = sgn(q,k) * binomial(n, k);
sb[q][0] += (Tjk * (bz[k] + bz[n-k]));
}
sb[q][0] += (binomial(n, q) * bz[q]);
sb[q][1] = sb[q][0];
}
sb[0][0] = bz[0];
sb[0][1] = bz[n];
}
| void Geom::bezier_to_sbasis | ( | D2< SBasis > & | sb, | |
| std::vector< Point > const & | bz | |||
| ) |
Changes the basis of d2 p to be sbasis.
- Parameters:
-
p the d2 Bernstein basis polynomial
- Returns:
- the d2 Symmetric basis polynomial
if the degree is even q is the order in the symmetrical power basis, if the degree is odd q is the order + 1 n is always the polynomial degree, i. e. the Bezier order
| double Geom::binomial | ( | unsigned int | n, | |
| unsigned int | k | |||
| ) | [inline] |
Definition at line 77 of file sbasis-to-bezier.cpp.
Referenced by bezier_to_sbasis().
{
return choose<double>(n, k);
}
| void Geom::binomial_coefficients | ( | std::vector< size_t > & | bc, | |
| size_t | n | |||
| ) |
Referenced by Geom::NL::LFMBezier::LFMBezier().
Definition at line 231 of file 2geom/shape.cpp.
References append(), BOOLOP_EXCLUSION, BOOLOP_IDENTITY_A, BOOLOP_IDENTITY_B, BOOLOP_INTERSECT, BOOLOP_NEITHER, BOOLOP_SUBTRACT_A_B, BOOLOP_SUBTRACT_B_A, BOOLOP_UNION, content, Geom::Shape::content, Geom::Shape::inverse(), shape_boolean(), shape_boolean_ra(), shape_boolean_rb(), and THROW_NOTIMPLEMENTED.
{
THROW_NOTIMPLEMENTED();
flags &= 15;
if(flags <= BOOLOP_UNION) {
switch(flags) {
case BOOLOP_INTERSECT: return shape_boolean(true, a, b, crs);
case BOOLOP_SUBTRACT_A_B: return shape_boolean_rb(true, a, b, crs);
case BOOLOP_IDENTITY_A: return a;
case BOOLOP_SUBTRACT_B_A: return shape_boolean_ra(true, a, b, crs);
case BOOLOP_IDENTITY_B: return b;
case BOOLOP_EXCLUSION: {
Shape res = shape_boolean_rb(true, a, b, crs);
append(res.content, shape_boolean_ra(true, a, b, crs).content);
return res;
}
case BOOLOP_UNION: return shape_boolean(false, a, b);
}
} else {
flags = ~flags & 15;
switch(flags - BOOLOP_NEITHER) {
case BOOLOP_SUBTRACT_A_B: return shape_boolean_ra(false, a, b, crs);
case BOOLOP_SUBTRACT_B_A: return shape_boolean_rb(false, a, b, crs);
case BOOLOP_EXCLUSION: {
Shape res = shape_boolean_ra(false, a, b, CrossingSet(crs));
append(res.content, shape_boolean_rb(false, a, b, CrossingSet(crs)).content);
return res;
}
}
return boolop(a, b, flags, crs).inverse();
}
return Shape();
}
| std::vector<Rect> Geom::bounds | ( | C const & | a | ) |
Definition at line 130 of file crossing.h.
References Barcode::Code39Ext::i.
Referenced by Geom::Shape::containment_list(), Geom::Crosser< Path >::crossings(), curve_sweep(), Inkscape::Extension::Internal::Grid::effect(), outer_crossing(), set_to_accumulated(), sp_canvas_group_update(), sp_export_detect_size(), sp_export_selection_modified(), sp_selection_tile(), and sp_selection_to_marker().
| OptRect Geom::bounds_exact | ( | const D2< T > & | a | ) |
Definition at line 441 of file d2.h.
References bounds_exact(), X, and Y.
{
boost::function_requires<FragmentConcept<T> >();
return OptRect(bounds_exact(a[X]), bounds_exact(a[Y]));
}
| FragmentConcept<T>::BoundsType Geom::bounds_exact | ( | const Piecewise< T > & | f | ) | [inline] |
Definition at line 280 of file piecewise.h.
References bounds_exact(), Geom::Piecewise< T >::empty(), Barcode::Code39Ext::i, and Geom::Piecewise< T >::size().
{
boost::function_requires<FragmentConcept<T> >();
if(f.empty()) return typename FragmentConcept<T>::BoundsType();
typename FragmentConcept<T>::BoundsType ret(bounds_exact(f[0]));
for(unsigned i = 1; i < f.size(); i++)
ret.unionWith(bounds_exact(f[i]));
return ret;
}
| OptInterval Geom::bounds_exact | ( | Bezier const & | b | ) | [inline] |
Definition at line 388 of file bezier.h.
References Geom::Bezier::toSBasis().
Referenced by bounds_exact(), bounds_local(), Geom::SBasisCurve::boundsExact(), Geom::BezierCurve< 1 >::boundsExact(), Geom::FragmentConcept< T >::constraints(), Inkscape::LivePathEffect::LPECurveStitch::doEffect_path(), Inkscape::LivePathEffect::LPESketch::doEffect_pwd2(), Inkscape::LivePathEffect::LPERoughHatches::doEffect_pwd2(), Inkscape::LivePathEffect::LPERecursiveSkeleton::doEffect_pwd2(), Inkscape::LivePathEffect::LPEPatternAlongPath::doEffect_pwd2(), Inkscape::LivePathEffect::LPEDynastroke::doEffect_pwd2(), Inkscape::LivePathEffect::LPERoughHatches::linearSnake(), and Inkscape::LivePathEffect::LPECurveStitch::resetDefaults().
{
return bounds_exact(b.toSBasis());
}
| OptInterval Geom::bounds_exact | ( | SBasis const & | a | ) |
Find the smallest interval that bounds a.
- Parameters:
-
a sbasis function
- Returns:
- inteval
| OptRect Geom::bounds_exact | ( | PathVector const & | pv | ) |
| OptRect Geom::bounds_fast | ( | const D2< T > & | a | ) |
Definition at line 436 of file d2.h.
References bounds_fast(), X, and Y.
{
boost::function_requires<FragmentConcept<T> >();
return OptRect(bounds_fast(a[X]), bounds_fast(a[Y]));
}
| FragmentConcept<T>::BoundsType Geom::bounds_fast | ( | const Piecewise< T > & | f | ) | [inline] |
Definition at line 269 of file piecewise.h.
References bounds_fast(), Geom::Piecewise< T >::empty(), Barcode::Code39Ext::i, and Geom::Piecewise< T >::size().
{
boost::function_requires<FragmentConcept<T> >();
if(f.empty()) return typename FragmentConcept<T>::BoundsType();
typename FragmentConcept<T>::BoundsType ret(bounds_fast(f[0]));
for(unsigned i = 1; i < f.size(); i++)
ret.unionWith(bounds_fast(f[i]));
return ret;
}
| OptInterval Geom::bounds_fast | ( | Bezier const & | b | ) | [inline] |
Definition at line 383 of file bezier.h.
References Geom::Interval::fromArray(), and Geom::Bezier::size().
Referenced by bounds_fast(), bounds_local(), Geom::SBasisCurve::boundsFast(), Geom::BezierCurve< 1 >::boundsFast(), compose(), Geom::FragmentConcept< T >::constraints(), subdiv_sbasis(), and Geom::SBasis::tailError().
| OptInterval Geom::bounds_fast | ( | const SBasis & | sb, | |
| int | order | |||
| ) |
Find a small interval that bounds a.
- Parameters:
-
a sbasis function
- Returns:
- inteval
| OptRect Geom::bounds_fast | ( | PathVector const & | pv | ) |
| FragmentConcept<T>::BoundsType Geom::bounds_local | ( | const Piecewise< T > & | f, | |
| const OptInterval & | _m | |||
| ) | [inline] |
Definition at line 291 of file piecewise.h.
References bounds_exact(), bounds_local(), Geom::Piecewise< T >::empty(), org::w3c::dom::svg::f, Barcode::Code39Ext::i, Geom::Interval::isSingular(), Geom::Interval::max(), Geom::Interval::min(), Geom::Piecewise< T >::segN(), and Geom::Piecewise< T >::segT().
{
boost::function_requires<FragmentConcept<T> >();
if(f.empty() || !_m) return typename FragmentConcept<T>::BoundsType();
Interval const &m = *_m;
if(m.isSingular()) return typename FragmentConcept<T>::BoundsType(f(m.min()));
unsigned fi = f.segN(m.min()), ti = f.segN(m.max());
double ft = f.segT(m.min(), fi), tt = f.segT(m.max(), ti);
if(fi == ti) return bounds_local(f[fi], Interval(ft, tt));
typename FragmentConcept<T>::BoundsType ret(bounds_local(f[fi], Interval(ft, 1.)));
for(unsigned i = fi + 1; i < ti; i++)
ret.unionWith(bounds_exact(f[i]));
if(tt != 0.) ret.unionWith(bounds_local(f[ti], Interval(0., tt)));
return ret;
}
| OptRect Geom::bounds_local | ( | const D2< T > & | a, | |
| const OptInterval & | t | |||
| ) |
Definition at line 446 of file d2.h.
References bounds_local(), X, and Y.
{
boost::function_requires<FragmentConcept<T> >();
return OptRect(bounds_local(a[X], t), bounds_local(a[Y], t));
}
| OptInterval Geom::bounds_local | ( | Bezier const & | b, | |
| OptInterval | i | |||
| ) | [inline] |
Definition at line 392 of file bezier.h.
References bounds_fast(), and portion().
Referenced by bounds_local(), Geom::SBasisCurve::boundsLocal(), Geom::BezierCurve< 1 >::boundsLocal(), Geom::FragmentConcept< T >::constraints(), and multi_roots_internal().
| OptInterval Geom::bounds_local | ( | const SBasis & | sb, | |
| const OptInterval & | i, | |||
| int | order | |||
| ) |
Find a small interval that bounds a(t) for t in i to order order.
- Parameters:
-
sb sbasis function i domain interval order number of terms
- Returns:
- interval
| std::vector< Point > Geom::bridge_points | ( | ConvexHull | a, | |
| ConvexHull | b | |||
| ) |
| pair< map<int, int>, map<int, int> > Geom::bridges | ( | ConvexHull | a, | |
| ConvexHull | b | |||
| ) |
Definition at line 348 of file convex-cover.cpp.
References Geom::ConvexHull::boundary, cross(), NR::d, addnodes::e, org::w3c::dom::svg::f, and h.
{
map<int, int> abridges;
map<int, int> bbridges;
for(unsigned ia = 0; ia < a.boundary.size(); ia++) {
for(unsigned ib = 0; ib < b.boundary.size(); ib++) {
Point d = b[ib] - a[ia];
Geom::Coord e = cross(d, a[ia - 1] - a[ia]), f = cross(d, a[ia + 1] - a[ia]);
Geom::Coord g = cross(d, b[ib - 1] - a[ia]), h = cross(d, b[ib + 1] - a[ia]);
if (e > 0 && f > 0 && g > 0 && h > 0) abridges[ia] = ib;
else if(e < 0 && f < 0 && g < 0 && h < 0) bbridges[ib] = ia;
}
}
return make_pair(abridges, bbridges);
}
| void Geom::build_from_sbasis | ( | Geom::PathBuilder & | pb, | |
| D2< SBasis > const & | B, | |||
| double | tol, | |||
| bool | only_cubicbeziers | |||
| ) |
Make a path from a d2 sbasis.
- Parameters:
-
p the d2 Symmetric basis polynomial
- Returns:
- a Path
If only_cubicbeziers is true, the resulting path may only contain CubicBezier curves.
Definition at line 346 of file sbasis-to-bezier.cpp.
References Geom::D2< T >::at1(), compose(), Geom::SVGPathGenerator< OutputIterator >::curveTo(), Geom::D2< T >::isFinite(), Geom::SVGPathGenerator< OutputIterator >::lineTo(), sbasis_size(), sbasis_to_bezier(), tail_error(), and THROW_EXCEPTION.
{
if (!B.isFinite()) {
THROW_EXCEPTION("assertion failed: B.isFinite()");
}
if(tail_error(B, 2) < tol || sbasis_size(B) == 2) { // nearly cubic enough
if( !only_cubicbeziers && (sbasis_size(B) <= 1) ) {
pb.lineTo(B.at1());
} else {
std::vector<Geom::Point> bez;
sbasis_to_bezier(bez, B, 4);
pb.curveTo(bez[1], bez[2], bez[3]);
}
} else {
build_from_sbasis(pb, compose(B, Linear(0, 0.5)), tol, only_cubicbeziers);
build_from_sbasis(pb, compose(B, Linear(0.5, 1)), tol, only_cubicbeziers);
}
}
| int Geom::centroid | ( | std::vector< Geom::Point > const & | p, | |
| Geom::Point & | centroid, | |||
| double & | area | |||
| ) |
polyCentroid: Calculates the centroid (xCentroid, yCentroid) and area of a polygon, given its vertices (x[0], y[0]) ...
(x[n-1], y[n-1]). It is assumed that the contour is closed, i.e., that the vertex following (x[n-1], y[n-1]) is (x[0], y[0]). The algebraic sign of the area is positive for counterclockwise ordering of vertices in x-y plane; otherwise negative.
Returned values: 0 for normal execution; 1 if the polygon is degenerate (number of vertices < 3); 2 if area = 0 (and the centroid is undefined).
for now we require the path to be a polyline and assume it is closed.
Referenced by Inkscape::LivePathEffect::LPEPathLength::doEffect_pwd2().
Centroid using sbasis integration.
- Parameters:
-
p the Element. centroid on return contains the centroid of the shape area on return contains the signed area of the shape.
This approach uses green's theorem to compute the area and centroid using integrals. For curved shapes this is much faster than converting to polyline. Note that without an uncross operation the output is not the absolute area.
Returned values: 0 for normal execution; 2 if area is zero, meaning centroid is meaningless.
Definition at line 518 of file sbasis-geometric.cpp.
References Geom::D2< T >::at0(), Geom::SBasis::at0(), Geom::D2< T >::at1(), Geom::SBasis::at1(), cross(), derivative(), dot(), Barcode::Code39Ext::i, integral(), multiply(), uniconv-ext::p, and rot90().
{
Point centroid_tmp(0,0);
double atmp = 0;
for(unsigned i = 0; i < p.size(); i++) {
SBasis curl = dot(p[i], rot90(derivative(p[i])));
SBasis A = integral(curl);
D2<SBasis> C = integral(multiply(curl, p[i]));
atmp += A.at1() - A.at0();
centroid_tmp += C.at1()- C.at0(); // first moment.
}
// join ends
centroid_tmp *= 2;
Point final = p[p.size()-1].at1(), initial = p[0].at0();
const double ai = cross(final, initial);
atmp += ai;
centroid_tmp += (final + initial)*ai; // first moment.
area = atmp / 2;
if (atmp != 0) {
centroid = centroid_tmp / (3 * atmp);
return 0;
}
return 2;
}
| SBasis Geom::cheb | ( | unsigned | n | ) |
Definition at line 14 of file chebyshev.cpp.
References Barcode::Code39Ext::i, and Geom::SBasis::push_back().
Referenced by cheb_series().
Definition at line 27 of file chebyshev.cpp.
References cheb(), Barcode::Code39Ext::i, and polyhedron_3d::r.
| SBasis Geom::chebyshev | ( | unsigned | n | ) |
| SBasis Geom::chebyshev_approximant | ( | double(*)(double, void *) | f, | |
| int | order, | |||
| Interval | in, | |||
| void * | p | |||
| ) |
| SBasis Geom::chebyshev_approximant_interpolating | ( | double(*)(double, void *) | f, | |
| int | order, | |||
| Interval | in, | |||
| void * | p | |||
| ) |
| static void Geom::chord_length_parameterize | ( | Point const | d[], | |
| double | u[], | |||
| unsigned const | len | |||
| ) | [static] |
Assign parameter values to digitized points using relative distances between points.
- Precondition:
- Parameter array u must have space for len items.
- Todo:
- It's been reported that u[len - 1] can differ from 1.0 on some systems (amd64), despite it having been calculated as x / x where x is isFinite and non-zero.
- Todo:
- It's been reported that u[len - 1] can differ from 1.0 on some systems (amd64), despite it having been calculated as x / x where x is isFinite and non-zero.
Definition at line 841 of file bezier-utils.cpp.
References distance(), double, addnodes::e, Barcode::Code39Ext::i, and IS_FINITE.
{
if(!( 2 <= len ))
return;
/* First let u[i] equal the distance travelled along the path from d[0] to d[i]. */
u[0] = 0.0;
for (unsigned i = 1; i < len; i++) {
double const dist = distance(d[i], d[i-1]);
u[i] = u[i-1] + dist;
}
/* Then scale to [0.0 .. 1.0]. */
double tot_len = u[len - 1];
if(!( tot_len != 0 ))
return;
if (IS_FINITE(tot_len)) {
for (unsigned i = 1; i < len; ++i) {
u[i] /= tot_len;
}
} else {
/* We could do better, but this probably never happens anyway. */
for (unsigned i = 1; i < len; ++i) {
u[i] = i / (double) ( len - 1 );
}
}
if (u[len - 1] != 1) {
double const diff = u[len - 1] - 1;
if (fabs(diff) > 1e-13) {
assert(0); // No warnings in 2geom
//g_warning("u[len - 1] = %19g (= 1 + %19g), expecting exactly 1",
// u[len - 1], diff);
}
u[len - 1] = 1;
}
#ifdef BEZIER_DEBUG
assert( u[0] == 0.0 && u[len - 1] == 1.0 );
for (unsigned i = 1; i < len; i++) {
assert( u[i] >= u[i-1] );
}
#endif
}
| int Geom::circle_circle_intersection | ( | Point | X0, | |
| double | r0, | |||
| Point | X1, | |||
| double | r1, | |||
| Point & | p0, | |||
| Point & | p1 | |||
| ) |
Definition at line 49 of file circle-circle.cpp.
References org::w3c::dom::svg::a, NR::d, h, L2(), polyhedron_3d::r, rot90(), and sqrt().
{
/* dx and dy are the vertical and horizontal distances between
* the circle centers.
*/
Point D = X1 - X0;
/* Determine the straight-line distance between the centers. */
double d = L2(D);
/* Check for solvability. */
if (d > (r0 + r1))
{
/* no solution. circles do not intersect. */
return 0;
}
if (d <= fabs(r0 - r1))
{
/* no solution. one circle is contained in the other */
return 1;
}
/* 'point 2' is the point where the line through the circle
* intersection points crosses the line between the circle
* centers.
*/
/* Determine the distance from point 0 to point 2. */
double a = ((r0*r0) - (r1*r1) + (d*d)) / (2.0 * d) ;
/* Determine the coordinates of point 2. */
Point p2 = X0 + D * (a/d);
/* Determine the distance from point 2 to either of the
* intersection points.
*/
double h = sqrt((r0*r0) - (a*a));
/* Now determine the offsets of the intersection points from
* point 2.
*/
Point r = (h/d)*rot90(D);
/* Determine the absolute intersection points. */
p0 = p2 + r;
p1 = p2 - r;
return 2;
}
| void Geom::clean | ( | Crossings & | , | |
| Crossings & | ||||
| ) |
b_n = a_n b_n-1 = 2*x*b_n + a_n-1 b_n-k = 2*x*b_{n-k+1} + a_{n-k} - b_{n - k + 2} b_0 = x*b_1 + a_0 - b_2
Definition at line 39 of file chebyshev.cpp.
References org::w3c::dom::svg::a, b, NR::d, and voronoi::y.
| ConvexHull Geom::clip | ( | ConvexHull const & | ch, | |
| Point | n, | |||
| double | d | |||
| ) |
| D2<T> Geom::compose | ( | D2< T > const & | a, | |
| T const & | b | |||
| ) | [inline] |
Definition at line 364 of file d2.h.
References Barcode::Code39Ext::i, and polyhedron_3d::r.
Referenced by arc_length_parametrization(), Inkscape::LivePathEffect::bend(), build_from_sbasis(), compose(), compose_each(), Inkscape::InputDeviceImpl::createId(), Inkscape::LivePathEffect::LPESketch::doEffect_pwd2(), Inkscape::LivePathEffect::LPERecursiveSkeleton::doEffect_pwd2(), Inkscape::LivePathEffect::LPEPatternAlongPath::doEffect_pwd2(), Inkscape::LivePathEffect::LPEEnvelope::doEffect_pwd2(), Inkscape::LivePathEffect::LPEDynastroke::doEffect_pwd2(), Inkscape::LivePathEffect::LPEBendPath::doEffect_pwd2(), Inkscape::Whiteboard::XMLNodeTracker::generateKey(), Inkscape::Widgets::LayerSelector::LayerSelector(), Geom::SBasis::operator()(), Geom::Piecewise< T >::operator()(), Gear::path(), portion(), solve_lambda0(), sqrt_internal(), subdiv_sbasis(), and unitVector().
| Piecewise<T> Geom::compose | ( | Piecewise< T > const & | f, | |
| SBasis const & | g | |||
| ) |
Definition at line 666 of file piecewise.h.
References bounds_fast(), compose(), compose_findSegIdx(), compose_pullback(), Geom::Piecewise< T >::cuts, Geom::Piecewise< T >::empty(), org::w3c::dom::svg::f, Geom::SBasis::isZero(), Geom::Interval::max(), Geom::Interval::min(), Geom::Piecewise< T >::push(), org::w3c::dom::svg::result, Geom::Piecewise< T >::segs, and Geom::Piecewise< T >::size().
{
Piecewise<T> result;
if (f.empty()) return result;
if (g.isZero()) return Piecewise<T>(f(0));
if (f.size()==1){
double t0 = f.cuts[0], width = f.cuts[1] - t0;
return (Piecewise<T>) compose(f.segs[0],compose(Linear(-t0 / width, (1-t0) / width), g));
}
//first check bounds...
Interval bs = *bounds_fast(g);
if (f.cuts.front() > bs.max() || bs.min() > f.cuts.back()){
int idx = (bs.max() < f.cuts[1]) ? 0 : f.cuts.size()-2;
double t0 = f.cuts[idx], width = f.cuts[idx+1] - t0;
return (Piecewise<T>) compose(f.segs[idx],compose(Linear(-t0 / width, (1-t0) / width), g));
}
std::vector<double> levels;//we can forget first and last cuts...
levels.insert(levels.begin(),f.cuts.begin()+1,f.cuts.end()-1);
//TODO: use a std::vector<pairs<double,unsigned> > instead of a map<double,unsigned>.
std::map<double,unsigned> cuts_pb = compose_pullback(levels,g);
//-- Compose each piece of g with the relevant seg of f.
result.cuts.push_back(0.);
std::map<double,unsigned>::iterator cut=cuts_pb.begin();
std::map<double,unsigned>::iterator next=cut; next++;
while(next!=cuts_pb.end()){
//assert(std::abs(int((*cut).second-(*next).second))<1);
//TODO: find a way to recover from this error? the root finder missed some root;
// the levels/variations of f might be too close/fast...
int idx = compose_findSegIdx(cut,next,levels,g);
double t0=(*cut).first;
double t1=(*next).first;
SBasis sub_g=compose(g, Linear(t0,t1));
sub_g=compose(Linear(-f.cuts[idx]/(f.cuts[idx+1]-f.cuts[idx]),
(1-f.cuts[idx])/(f.cuts[idx+1]-f.cuts[idx])),sub_g);
result.push(compose(f[idx],sub_g),t1);
cut++;
next++;
}
return(result);
}
| Piecewise<T> Geom::compose | ( | Piecewise< T > const & | f, | |
| Piecewise< SBasis > const & | g | |||
| ) |
Definition at line 712 of file piecewise.h.
References compose(), Geom::Piecewise< T >::concat(), Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, org::w3c::dom::svg::result, Geom::Piecewise< T >::segs, and Geom::Piecewise< T >::setDomain().
| Poly Geom::compose | ( | Poly const & | a, | |
| Poly const & | b | |||
| ) |
| SBasis Geom::compose | ( | Linear2d const & | a, | |
| D2< SBasis > const & | p | |||
| ) |
| SBasis Geom::compose | ( | SBasis2d const & | fg, | |
| D2< SBasis > const & | p | |||
| ) |
| SBasis2d Geom::compose | ( | SBasis2d const & | a, | |
| SBasis2d const & | b | |||
| ) |
| SBasis2d Geom::compose | ( | SBasis2d const & | a, | |
| SBasis2d const & | b, | |||
| unsigned | k | |||
| ) |
| SBasis Geom::compose | ( | SBasis const & | a, | |
| SBasis const & | b | |||
| ) |
Compute a composed with b.
- Parameters:
-
a,b sbasis functions
- Returns:
- sbasis a(b(t))
return a0 + s(a1 + s(a2 +... where s = (1-u)u; ak =(1 - u)a^0_k + ua^1_k
| SBasis Geom::compose | ( | SBasis const & | a, | |
| SBasis const & | b, | |||
| unsigned | k | |||
| ) |
Compute a composed with b to k terms.
- Parameters:
-
a,b sbasis functions
- Returns:
- sbasis a(b(t))
return a0 + s(a1 + s(a2 +... where s = (1-u)u; ak =(1 - u)a^0_k + ua^1_k
| D2<T> Geom::compose_each | ( | T const & | a, | |
| D2< T > const & | b | |||
| ) | [inline] |
| D2<T> Geom::compose_each | ( | D2< T > const & | a, | |
| D2< T > const & | b | |||
| ) | [inline] |
Definition at line 373 of file d2.h.
References compose(), Barcode::Code39Ext::i, and polyhedron_3d::r.
Referenced by Inkscape::LivePathEffect::LPELattice::doEffect_pwd2().
| int Geom::compose_findSegIdx | ( | std::map< double, unsigned >::iterator const & | cut, | |
| std::map< double, unsigned >::iterator const & | next, | |||
| std::vector< double > const & | levels, | |||
| SBasis const & | g | |||
| ) |
Referenced by compose().
compute fog^-1.
- Parameters:
-
f,g sbasis functions
- Returns:
- sbasis f(g^-1(t)).
("zero" = double comparison threshold. *!*we might divide by "zero"*!*) TODO: compute order according to tol? TODO: requires g(0)=0 & g(1)=1 atm... adaptation to other cases should be obvious!
Referenced by arc_length_parametrization().
| std::map< double, unsigned > Geom::compose_pullback | ( | std::vector< double > const & | values, | |
| SBasis const & | g | |||
| ) |
Referenced by compose().
| static double Geom::compute_hook | ( | Point const & | a, | |
| Point const & | b, | |||
| double const | u, | |||
| BezierCurve const | bezCurve, | |||
| double const | tolerance | |||
| ) | [static] |
Whereas compute_max_error_ratio() checks for itself that each data point is near some point on the curve, this function checks that each point on the curve is near some data point (or near some point on the polyline defined by the data points, or something like that: we allow for a "reasonable curviness" from such a polyline).
"Reasonable curviness" means we draw a circle centred at the midpoint of a..b, of radius proportional to the length |a - b|, and require that each point on the segment of bezCurve between the parameters of a and b be within that circle. If any point P on the bezCurve segment is outside of that allowable region (circle), then we return some metric that increases with the distance from P to the circle.
Given that this is a fairly arbitrary criterion for finding appropriate places for sharp corners, we test only one point on bezCurve, namely the point on bezCurve with parameter halfway between our estimated parameters for a and b. (Alternatives are taking the farthest of a few parameters between those of a and b, or even using a variant of NewtonRaphsonFindRoot() for finding the maximum rather than minimum distance.)
- Todo:
- effic: Hooks are very rare. We could start by comparing distsq, only resorting to the more expensive L2 in cases of uncertainty.
- Todo:
- effic: Hooks are very rare. We could start by comparing distsq, only resorting to the more expensive L2 in cases of uncertainty.
Definition at line 977 of file bezier-utils.cpp.
References bezier_pt(), and distance().
Referenced by compute_max_error_ratio().
| static double Geom::compute_max_error_ratio | ( | Point const | d[], | |
| double const | u[], | |||
| unsigned const | len, | |||
| BezierCurve const | bezCurve, | |||
| double const | tolerance, | |||
| unsigned *const | splitPoint | |||
| ) | [static] |
Find the maximum squared distance of digitized points to fitted curve, and (if this maximum error is non-zero) set *splitPoint to the corresponding index.
- Precondition:
- 2 <= len.
- u[0] == 0.
- u[len - 1] == 1.0.
- Postcondition:
- ((ret == 0.0) || ((*splitPoint < len - 1) && (*splitPoint != 0 || ret < 0.0))).
Definition at line 906 of file bezier-utils.cpp.
References bezier_pt(), compute_hook(), Barcode::Code39Ext::i, lensq(), and sqrt().
{
assert( 2 <= len );
unsigned const last = len - 1;
assert( bezCurve[0] == d[0] );
assert( bezCurve[3] == d[last] );
assert( u[0] == 0.0 );
assert( u[last] == 1.0 );
/* I.e. assert that the error for the first & last points is zero.
* Otherwise we should include those points in the below loop.
* The assertion is also necessary to ensure 0 < splitPoint < last.
*/
double maxDistsq = 0.0; /* Maximum error */
double max_hook_ratio = 0.0;
unsigned snap_end = 0;
Point prev = bezCurve[0];
for (unsigned i = 1; i <= last; i++) {
Point const curr = bezier_pt(3, bezCurve, u[i]);
double const distsq = lensq( curr - d[i] );
if ( distsq > maxDistsq ) {
maxDistsq = distsq;
*splitPoint = i;
}
double const hook_ratio = compute_hook(prev, curr, .5 * (u[i - 1] + u[i]), bezCurve, tolerance);
if (max_hook_ratio < hook_ratio) {
max_hook_ratio = hook_ratio;
snap_end = i;
}
prev = curr;
}
double const dist_ratio = sqrt(maxDistsq) / tolerance;
double ret;
if (max_hook_ratio <= dist_ratio) {
ret = dist_ratio;
} else {
assert(0 < snap_end);
ret = -max_hook_ratio;
*splitPoint = snap_end - 1;
}
assert( ret == 0.0
|| ( ( *splitPoint < last )
&& ( *splitPoint != 0 || ret < 0. ) ) );
return ret;
}
| static double Geom::compute_x_intercept | ( | Geom::Point const * | V, | |
| unsigned | degree | |||
| ) | [static] |
Definition at line 172 of file solve-bezier-parametric.cpp.
{
const Geom::Point A = V[degree] - V[0];
return (A[Geom::X]*V[0][Geom::Y] - A[Geom::Y]*V[0][Geom::X]) / -A[Geom::Y];
}
Constrains the angle (with respect to dir) of the line joining A and B to a multiple of pi/n.
Referenced by Inkscape::UI::Handle::dragged().
Definition at line 49 of file path-intersection.h.
References winding().
Referenced by Avoid::EdgeInf::firstBlocker().
| static unsigned Geom::control_poly_flat_enough | ( | Geom::Point const * | V, | |
| unsigned | degree | |||
| ) | [static] |
Definition at line 112 of file solve-bezier-parametric.cpp.
References org::w3c::dom::svg::a, b, BEPSILON, c, NR::d, Avoid::dist(), distance(), error(), Barcode::Code39Ext::i, max(), and min().
{
/* Find the perpendicular distance from each interior control point to line connecting V[0] and
* V[degree] */
/* Derive the implicit equation for line connecting first */
/* and last control points */
const double a = V[0][Geom::Y] - V[degree][Geom::Y];
const double b = V[degree][Geom::X] - V[0][Geom::X];
const double c = V[0][Geom::X] * V[degree][Geom::Y] - V[degree][Geom::X] * V[0][Geom::Y];
const double abSquared = (a * a) + (b * b);
double distance[degree]; /* Distances from pts to line */
for (unsigned i = 1; i < degree; i++) {
/* Compute distance from each of the points to that line */
double & dist(distance[i-1]);
const double d = a * V[i][Geom::X] + b * V[i][Geom::Y] + c;
dist = d*d / abSquared;
if (d < 0.0)
dist = -dist;
}
// Find the largest distance
double max_distance_above = 0.0;
double max_distance_below = 0.0;
for (unsigned i = 0; i < degree-1; i++) {
const double d = distance[i];
if (d < 0.0)
max_distance_below = std::min(max_distance_below, d);
if (d > 0.0)
max_distance_above = std::max(max_distance_above, d);
}
const double intercept_1 = (c + max_distance_above) / -a;
const double intercept_2 = (c + max_distance_below) / -a;
/* Compute bounding interval*/
const double left_intercept = std::min(intercept_1, intercept_2);
const double right_intercept = std::max(intercept_1, intercept_2);
const double error = 0.5 * (right_intercept - left_intercept);
if (error < BEPSILON)
return 1;
return 0;
}
| static unsigned Geom::copy_without_nans_or_adjacent_duplicates | ( | Point const | src[], | |
| unsigned | src_len, | |||
| Point | dest[] | |||
| ) | [static] |
Copy points from src to dest, filter out points containing NaN and adjacent points with equal x and y.
- Returns:
- length of dest
Definition at line 161 of file bezier-utils.cpp.
References IS_NAN, Point, X, and Y.
{
unsigned si = 0;
for (;;) {
if ( si == src_len ) {
return 0;
}
if (!IS_NAN(src[si][X]) &&
!IS_NAN(src[si][Y])) {
dest[0] = Point(src[si]);
++si;
break;
}
si++;
}
unsigned di = 0;
for (; si < src_len; ++si) {
Point const src_pt = Point(src[si]);
if ( src_pt != dest[di]
&& !IS_NAN(src_pt[X])
&& !IS_NAN(src_pt[Y])) {
dest[++di] = src_pt;
}
}
unsigned dest_len = di + 1;
assert( dest_len <= src_len );
return dest_len;
}
Compute the cosine of a function.
- Parameters:
-
f function tol maximum error order maximum degree polynomial to use
Referenced by Gear::_arc(), Inkscape::Text::Layout::_calculateCursorShapeForEmpty(), Inkscape::Text::Layout::_getGlyphTransformMatrix(), Gear::_involute(), Inkscape::UI::ControlPointSelection::_pointDragged(), Geom::SVGEllipticalArc::allNearestPoints(), Geom::EllipticalArc::allNearestPoints(), Geom::Ray::angle(), Geom::Line::angle(), arc2path(), ArcAnglesAndCenter(), Gear::base_diameter(), Geom::SVGEllipticalArc::boundsExact(), Geom::EllipticalArc::boundsExact(), lwpolyline::bulge_end_angle(), polyline::bulge_end_angle(), lwpolyline::bulge_start_angle(), polyline::bulge_start_angle(), Geom::SVGEllipticalArc::calculate_center_and_extreme_angles(), Geom::EllipticalArc::calculate_center_and_extreme_angles(), clonetiler_get_transform(), Inkscape::LivePathEffect::LPETextLabel::doEffect_pwd2(), Inkscape::LivePathEffect::LPEDynastroke::doEffect_pwd2(), get_snap_vector(), Geom::Circle::getPath(), gr_knot_moved_midpoint_handler(), Geom::Ellipse::implicit_form_coefficients(), integrate_spiro(), Inkscape::Filters::DistantLight::light_vector(), Shape::MakeOffset(), Shape::MakeTweak(), Avoid::Router::markConnectors(), NormalDistribution(), Geom::SVGEllipticalArc::pointAtAngle(), Geom::EllipticalArc::pointAtAngle(), Geom::Point::polar(), Inkscape::Text::Layout::queryCursorShape(), Inkscape::Filters::FilterColorMatrix::render(), Geom::SVGEllipticalArc::roots(), Geom::EllipticalArc::roots(), org::w3c::dom::svg::SVGMatrix::rotate(), rotate_degrees(), org::w3c::dom::svg::SVGMatrix::rotateFromVector(), Geom::Ellipse::set(), Proj::TransfMat3x4::set_infinite_direction(), set_pos_and_anchor(), Inkscape::LivePathEffect::TextParam::setPosAndAnchor(), sp_arc_get_xy(), sp_color_wheel_paint(), sp_color_wheel_recalc_triangle(), sp_dyna_draw_apply(), sp_eraser_apply(), sp_genericellipse_set_shape(), sp_genericellipse_snappoints(), sp_spiral_get_tangent(), sp_spiral_get_xy(), sp_spray_recursive(), sp_star_get_xy(), sp_star_position_set(), sp_te_get_cursor_coords(), sp_tweak_dilate_recursive(), spdc_endpoint_snap_rotation(), spiro_seg_to_bpath(), Inkscape::Filters::SpotLight::SpotLight(), tan2(), Path::TangentOnArcAt(), NrRotateTest::testCtorsCompares(), text2text(), Geom::SVGEllipticalArc::toSBasis(), Geom::EllipticalArc::toSBasis(), Geom::Ellipse::transformed(), tweak_profile(), Geom::SVGEllipticalArc::valueAtAngle(), and Geom::EllipticalArc::valueAtAngle().
Compute the cosine of a function.
- Parameters:
-
f function tol maximum error order maximum degree polynomial to use
| SBasis Geom::cos | ( | Linear | bo, | |
| int | k | |||
| ) |
Compute the cosine of a.
- Parameters:
-
b linear function
- Returns:
- sbasis cos(a)
It is recommended to use the piecewise version unless you have good reason.
Defined as dot(a, b.cw()).
Definition at line 218 of file 2geom/point.h.
References Geom::Point::cw(), and dot().
| Piecewise<SBasis> Geom::cross | ( | Piecewise< D2< SBasis > > const & | a, | |
| Piecewise< D2< SBasis > > const & | b | |||
| ) |
Definition at line 110 of file d2-sbasis.cpp.
References org::w3c::dom::svg::a, b, Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, partition(), Geom::Piecewise< T >::push(), Geom::Piecewise< T >::push_cut(), org::w3c::dom::svg::result, and Geom::Piecewise< T >::segs.
Referenced by Inkscape::LivePathEffect::are_colinear(), are_collinear(), bridges(), centroid(), Geom::ConvexHull::centroid_and_area(), Shape::CmpToVert(), cubics_fitting_curvature(), curvature(), Inkscape::LivePathEffect::LPEKnot::doEffect_path(), Inkscape::LivePathEffect::LPESketch::doEffect_pwd2(), Path::DoJoin(), Path::DoLeftJoin(), Path::DoRightJoin(), SweepTree::Find(), Geom::Matrix::flips(), SweepTree::InsertAt(), Geom::detail::bezier_clipping::is_a_right_turn(), linear_intersect(), Geom::detail::bezier_clipping::orientation_line(), Path::OutlineJoin(), pick_coincident(), Shape::PtWinding(), Path::RecBezierTo(), Path::RecCubicTo(), Path::RecRound(), SignedTriangleArea(), Path::Surface(), Path::TangentOnBezAt(), Path::TangentOnCubAt(), Shape::TesteAdjacency(), Shape::TesteIntersection(), and Shape::Winding().
{
Piecewise<SBasis > result;
if (a.empty() || b.empty()) return result;
Piecewise<D2<SBasis> > aa = partition(a,b.cuts);
Piecewise<D2<SBasis> > bb = partition(b,a.cuts);
result.push_cut(aa.cuts.front());
for (unsigned i=0; i<a.size(); i++){
result.push(cross(aa.segs[i],bb.segs[i]),aa.cuts[i+1]);
}
return result;
}
| unsigned Geom::crossing_along | ( | double | t, | |
| unsigned | ix, | |||
| unsigned | jx, | |||
| bool | dir, | |||
| Crossings const & | crs | |||
| ) |
Referenced by inner_sanitize(), and outer_crossing().
| unsigned Geom::crossing_count | ( | Geom::Point const * | V, | |
| unsigned | degree | |||
| ) |
Definition at line 88 of file solve-bezier-parametric.cpp.
References Barcode::Code39Ext::i, SGN(), sign, and Y.
| void Geom::crossing_dual | ( | unsigned & | i, | |
| unsigned & | j, | |||
| CrossingSet const & | crs | |||
| ) |
Referenced by inner_sanitize().
| Crossings Geom::crossings | ( | Curve const & | a, | |
| Curve const & | b | |||
| ) | [inline] |
Definition at line 92 of file path-intersection.h.
References c, and Geom::SimpleCrosser::crossings().
Referenced by Inkscape::ObjectSnapper::_snapPathsConstrained(), Avoid::buildOrthogonalNudgingOrderInfo(), crossings_between(), Inkscape::SnappedCurve::intersect(), region_boolean(), and try_get_intersect_point_with_item_recursive().
{
DefaultCrosser c = DefaultCrosser();
return c.crossings(a, b);
}
| CrossingSet Geom::crossings | ( | std::vector< Path > const & | a, | |
| std::vector< Path > const & | b | |||
| ) | [inline] |
Definition at line 102 of file path-intersection.h.
References c, and Geom::SimpleCrosser::crossings().
{
DefaultCrosser c = DefaultCrosser();
return c.crossings(a, b);
}
Definition at line 97 of file path-intersection.h.
References c, and Geom::SimpleCrosser::crossings().
{
DefaultCrosser c = DefaultCrosser();
return c.crossings(a, b);
}
| CrossingSet Geom::crossings_among | ( | std::vector< Path > const & | p | ) |
Referenced by inner_sanitize().
| CrossingSet Geom::crossings_between | ( | Shape const & | a, | |
| Shape const & | b | |||
| ) | [inline] |
Definition at line 114 of file 2geom/shape.h.
References Geom::Shape::content, crossings(), and paths_from_regions().
{ return crossings(paths_from_regions(a.content), paths_from_regions(b.content)); }
| T Geom::cube | ( | const T & | x | ) | [inline] |
| static void Geom::cubic_bezier_poly_coeff | ( | iterator | b, | |
| Point * | pc | |||
| ) | [static] |
Definition at line 66 of file bezier-utils.h.
References c, Barcode::Code39Ext::i, and Point.
Definition at line 68 of file sbasis-to-bezier.h.
References path_from_sbasis().
Referenced by Path::AddCurve(), feed_curve_to_cairo(), geom_curve_bbox_wind_distance(), pathv_to_linear_and_cubic_beziers(), Inkscape::Extension::Internal::PrintLatex::print_2geomcurve(), and sp_svg_write_curve().
{ return path_from_sbasis(B, tol, true); }
| std::vector< D2< SBasis > > Geom::cubics_fitting_curvature | ( | Point const & | M0, | |
| Point const & | M1, | |||
| Point const & | dM0, | |||
| Point const & | dM1, | |||
| double | d2M0xdM0, | |||
| double | d2M1xdM1, | |||
| int | insist_on_speed_signs = 1, |
|||
| double | epsilon = 1e-5 | |||
| ) |
returns the cubics fitting direction and curvature of a given input curve at two points.
The input can be the value, speed, and acceleration or value, speed, and cross(acceleration,speed) of the original curve at the both ends. (the second is often technically usefull, as it avoids unnecessary division by |v|^2) Recall that K=1/R=cross(acceleration,speed)/|speed|^3.
Moreover, a 7-th argument 'insist_on_speed_signs' can be supplied to select solutions: If insist_on_speed_signs == 1, only consider solutions where speeds at both ends are positively proportional to the given ones. If insist_on_speed_signs == 0, allow speeds to point in the opposite direction (both at the same time) If insist_on_speed_signs == -1, allow speeds to point in both direction independantly.
Definition at line 625 of file sbasis-geometric.cpp.
References org::w3c::dom::svg::a, c, cross(), curvature(), Barcode::Code39Ext::i, org::w3c::dom::svg::result, solve_lambda0(), sqrt(), and Geom::Piecewise< T >::valueAt().
Referenced by cubics_fitting_curvature(), and cubics_with_prescribed_curvature().
{
std::vector<D2<SBasis> > result;
//speed of cubic bezier will be lambda0*dM0 and lambda1*dM1,
//with lambda0 and lambda1 s.t. curvature at both ends is the same
//as the curvature of the given curve.
std::vector<double> lambda0,lambda1;
double dM1xdM0=cross(dM1,dM0);
if (fabs(dM1xdM0)<epsilon){
if (fabs(d2M0xdM0)<epsilon || fabs(d2M1xdM1)<epsilon){
return result;
}
double lbda02 = 6.*cross(M1-M0,dM0)/d2M0xdM0;
double lbda12 =-6.*cross(M1-M0,dM1)/d2M1xdM1;
if (lbda02<0 || lbda12<0){
return result;
}
lambda0.push_back(std::sqrt(lbda02) );
lambda1.push_back(std::sqrt(lbda12) );
}else{
//solve: lambda1 = a0 lambda0^2 + c0
// lambda0 = a1 lambda1^2 + c1
double a0,c0,a1,c1;
a0 = -d2M0xdM0/2/dM1xdM0;
c0 = 3*cross(M1-M0,dM0)/dM1xdM0;
a1 = -d2M1xdM1/2/dM1xdM0;
c1 = -3*cross(M1-M0,dM1)/dM1xdM0;
if (fabs(a0)<epsilon){
lambda1.push_back( c0 );
lambda0.push_back( a1*c0*c0 + c1 );
}else if (fabs(a1)<epsilon){
lambda0.push_back( c1 );
lambda1.push_back( a0*c1*c1 + c0 );
}else{
//find lamda0 by solving a deg 4 equation d0+d1*X+...+d4*X^4=0
double a[5];
a[0] = c1+a1*c0*c0;
a[1] = -1;
a[2] = 2*a1*a0*c0;
a[3] = 0;
a[4] = a1*a0*a0;
//vector<double> solns=solve_poly(a,4);
vector<double> solns=solve_lambda0(a0,a1,c0,c1,insist_on_speed_signs);
for (unsigned i=0;i<solns.size();i++){
double lbda0=solns[i];
double lbda1=c0+a0*lbda0*lbda0;
//is this solution pointing in the + direction at both ends?
if (lbda0>=0. && lbda1>=0.){
lambda0.push_back( lbda0);
lambda1.push_back( lbda1);
}
//is this solution pointing in the - direction at both ends?
else if (lbda0<=0. && lbda1<=0. && insist_on_speed_signs<=0){
lambda0.push_back( lbda0);
lambda1.push_back( lbda1);
}
//ok,this solution is pointing in the + and - directions.
else if (insist_on_speed_signs<0){
lambda0.push_back( lbda0);
lambda1.push_back( lbda1);
}
}
}
}
for (unsigned i=0; i<lambda0.size(); i++){
Point V0 = lambda0[i]*dM0;
Point V1 = lambda1[i]*dM1;
D2<SBasis> cubic;
for(unsigned dim=0;dim<2;dim++){
SBasis c(2, Linear());
c[0] = Linear(M0[dim],M1[dim]);
c[1] = Linear( M0[dim]-M1[dim]+V0[dim],
-M0[dim]+M1[dim]-V1[dim]);
cubic[dim] = c;
}
#if 0
Piecewise<SBasis> k = curvature(result);
double dM0_l = dM0.length();
double dM1_l = dM1.length();
g_warning("Target radii: %f, %f", dM0_l*dM0_l*dM0_l/d2M0xdM0,dM1_l*dM1_l*dM1_l/d2M1xdM1);
g_warning("Obtained radii: %f, %f",1/k.valueAt(0),1/k.valueAt(1));
#endif
result.push_back(cubic);
}
return(result);
}
| std::vector< D2< SBasis > > Geom::cubics_fitting_curvature | ( | Point const & | M0, | |
| Point const & | M1, | |||
| Point const & | dM0, | |||
| Point const & | dM1, | |||
| Point const & | d2M0, | |||
| Point const & | d2M1, | |||
| int | insist_on_speed_signs = 1, |
|||
| double | epsilon = 1e-5 | |||
| ) |
Definition at line 719 of file sbasis-geometric.cpp.
References cross(), and cubics_fitting_curvature().
{
double d2M0xdM0 = cross(d2M0,dM0);
double d2M1xdM1 = cross(d2M1,dM1);
return cubics_fitting_curvature(M0,M1,dM0,dM1,d2M0xdM0,d2M1xdM1,insist_on_speed_signs,epsilon);
}
| std::vector< D2< SBasis > > Geom::cubics_with_prescribed_curvature | ( | Point const & | M0, | |
| Point const & | M1, | |||
| Point const & | dM0, | |||
| Point const & | dM1, | |||
| double | k0, | |||
| double | k1, | |||
| int | insist_on_speed_signs = 1, |
|||
| double | error = 1e-5 | |||
| ) |
Definition at line 730 of file sbasis-geometric.cpp.
References cubics_fitting_curvature(), and Geom::Point::length().
{
double length;
length = dM0.length();
double d2M0xdM0 = k0*length*length*length;
length = dM1.length();
double d2M1xdM1 = k1*length*length*length;
return cubics_fitting_curvature(M0,M1,dM0,dM1,d2M0xdM0,d2M1xdM1,insist_on_speed_signs,epsilon);
}
returns a function giving the curvature at each point in M.
- Parameters:
-
M the Element. tol the maximum error allowed.
Todo: claimed incomplete. Check.
Definition at line 361 of file sbasis-geometric.cpp.
References cross(), derivative(), divide(), dot(), org::w3c::dom::svg::result, and unitVector().
Referenced by cubics_fitting_curvature(), curvature(), Inkscape::LivePathEffect::LPESketch::doEffect_pwd2(), Inkscape::LivePathEffect::LPEDynastroke::doEffect_pwd2(), and sp_connector_toolbox_selection_changed().
{
D2<SBasis> dM=derivative(M);
Piecewise<SBasis> result;
Piecewise<D2<SBasis> > unitv = unitVector(dM,tol);
Piecewise<SBasis> dMlength = dot(Piecewise<D2<SBasis> >(dM),unitv);
Piecewise<SBasis> k = cross(derivative(unitv),unitv);
k = divide(k,dMlength,tol,3);
return(k);
}
returns a function giving the curvature at each point in M.
- Parameters:
-
M the Element. tol the maximum error allowed.
Todo: claimed incomplete. Check.
Definition at line 379 of file sbasis-geometric.cpp.
References Geom::Piecewise< T >::concat(), curvature(), cutAtRoots(), Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, org::w3c::dom::svg::result, Geom::Piecewise< T >::segs, Geom::Piecewise< T >::setDomain(), and Geom::Piecewise< T >::size().
{
Piecewise<SBasis> result;
Piecewise<D2<SBasis> > VV = cutAtRoots(V);
result.cuts.push_back(VV.cuts.front());
for (unsigned i=0; i<VV.size(); i++){
Piecewise<SBasis> curv_seg;
curv_seg = curvature(VV.segs[i],tol);
curv_seg.setDomain(Interval(VV.cuts[i],VV.cuts[i+1]));
result.concat(curv_seg);
}
return result;
}
| std::vector<double> Geom::curve_mono_splits | ( | Curve const & | d | ) |
This returns the times when the x or y derivative is 0 in the curve.
Definition at line 461 of file path-intersection.cpp.
References append(), Geom::Curve::derivative(), Geom::Curve::roots(), X, and Y.
Referenced by curve_self_crossings().
| Crossings Geom::curve_self_crossings | ( | Curve const & | a | ) |
Definition at line 625 of file path-intersection.cpp.
References append(), curve_mono_splits(), Barcode::Code39Ext::i, and pair_intersect().
Definition at line 54 of file path-intersection.h.
References bounds(), Barcode::Code39Ext::i, offset_crossings(), Geom::Path::size(), and sweep_bounds().
{
T t;
Crossings ret;
std::vector<Rect> bounds_a = bounds(a), bounds_b = bounds(b);
std::vector<std::vector<unsigned> > ixs = sweep_bounds(bounds_a, bounds_b);
for(unsigned i = 0; i < a.size(); i++) {
for(std::vector<unsigned>::iterator jp = ixs[i].begin(); jp != ixs[i].end(); jp++) {
Crossings cc = t.crossings(a[i], b[*jp]);
offset_crossings(cc, i, *jp);
ret.insert(ret.end(), cc.begin(), cc.end());
}
}
return ret;
}
| Piecewise< D2< SBasis > > Geom::cutAtRoots | ( | Piecewise< D2< SBasis > > const & | M, | |
| double | tol = 1e-4 | |||
| ) |
Definition at line 136 of file sbasis-geometric.cpp.
References Barcode::Code39Ext::i, M, partition(), polyhedron_3d::r, roots(), and vect_intersect().
Referenced by atan2(), curvature(), and unitVector().
{
vector<double> rts;
for (unsigned i=0; i<M.size(); i++){
vector<double> seg_rts = roots((M.segs[i])[0]);
seg_rts = vect_intersect(seg_rts, roots((M.segs[i])[1]), ZERO);
Linear mapToDom = Linear(M.cuts[i],M.cuts[i+1]);
for (unsigned r=0; r<seg_rts.size(); r++){
seg_rts[r]= mapToDom(seg_rts[r]);
}
rts.insert(rts.end(),seg_rts.begin(),seg_rts.end());
}
return partition(M,rts);
}
| static Point Geom::darray_center_tangent | ( | Point const | d[], | |
| unsigned const | center, | |||
| unsigned const | len | |||
| ) | [static] |
Estimates the (backward) tangent at d[center], by averaging the two segments connected to d[center] (and then normalizing the result).
- Note:
- The tangent is "backwards", i.e. it is with respect to decreasing index rather than increasing index.
- Precondition:
- (0 < center < len - 1) and d is uniqued (at least in the immediate vicinity of center).
Definition at line 815 of file bezier-utils.cpp.
References Geom::Point::normalize(), and rot90().
Estimate the (forward) tangent at point d[first + 0.5].
Unlike the center and right versions, this calculates the tangent in the way one might expect, i.e., wrt increasing index into d.
- Precondition:
- (2 <= len) and (d[0] != d[1]).
Referenced by generate_bezier().
Estimate the (forward) tangent at point d[0].
Unlike the center and right versions, this calculates the tangent in the way one might expect, i.e., wrt increasing index into d.
- Precondition:
- 2 <= len.
- d[0] != d[1].
- all[p in d] in_svg_plane(p).
- Postcondition:
- is_unit_vector(ret).
Estimates the (backward) tangent at d[last].
- Note:
- The tangent is "backwards", i.e. it is with respect to decreasing index rather than increasing index.
- Precondition:
- 2 <= len.
- d[len - 1] != d[len - 2].
- all[p in d] in_svg_plane(p).
Estimates the (backward) tangent at d[last - 0.5].
- Note:
- The tangent is "backwards", i.e. it is with respect to decreasing index rather than increasing index.
- Precondition:
- 2 <= len.
- d[len - 1] != d[len - 2].
- all[p in d] in_svg_plane(p).
Definition at line 732 of file bezier-utils.cpp.
References unit_vector().
Referenced by generate_bezier().
{
assert( 2 <= len );
unsigned const last = len - 1;
unsigned const prev = last - 1;
assert( d[last] != d[prev] );
return unit_vector( d[prev] - d[last] );
}
Returns x rounded to the nearest places decimal places.
Implemented in terms of round, i.e. we make no guarantees as to what happens if x is half way between two rounded numbers.
Note: places is the number of decimal places without using scientific (e) notation, not the number of significant figures. This function may not be suitable for values of x whose magnitude is so far from 1 that one would want to use scientific (e) notation.
places may be negative: e.g. places = -2 means rounding to a multiple of .01
Definition at line 76 of file utils.h.
References pow(), and round().
Referenced by operator<<(), and Geom::Point::round().
Definition at line 44 of file angle.h.
References M_PI.
Referenced by sp_svg_transform_read().
{ return deg*M_PI/180.0;}
| D2<T> Geom::derivative | ( | D2< T > const & | a | ) |
Definition at line 411 of file d2.h.
References derivative(), X, and Y.
{
return D2<T>(derivative(a[X]), derivative(a[Y]));
}
| Piecewise<T> Geom::derivative | ( | Piecewise< T > const & | a | ) |
Definition at line 752 of file piecewise.h.
References Geom::Piecewise< T >::cuts, derivative(), Barcode::Code39Ext::i, org::w3c::dom::svg::result, and Geom::Piecewise< T >::segs.
| Poly Geom::derivative | ( | Poly const & | p | ) |
| Bezier Geom::derivative | ( | const Bezier & | a | ) | [inline] |
Definition at line 362 of file bezier.h.
References Bezier(), Geom::Bezier::c_, Barcode::Code39Ext::i, and Geom::Bezier::order().
Referenced by Gear::_involute(), all_nearest_points(), arcLengthSb(), atan2(), Geom::BezierCurve< 1 >::boundsLocal(), centroid(), curvature(), Geom::SBasisCurve::derivative(), derivative(), length_integrating(), nearest_point(), set_pos_and_anchor(), and Geom::sturm::sturm().
| SBasis Geom::derivative | ( | SBasis const & | a | ) |
Compute the derivative of a (Exact).
- Parameters:
-
a sbasis functions
- Returns:
- sbasis da/dt
| std::vector<Path> Geom::desanitize | ( | Shape const & | s | ) | [inline] |
Definition at line 131 of file 2geom/shape.h.
References Geom::Shape::getContent(), and paths_from_regions().
{
return paths_from_regions(s.getContent());
}
Definition at line 254 of file line.h.
References Geom::Point::ccw(), dot(), Geom::Line::isDegenerate(), Geom::Line::origin(), and Geom::Line::versor().
Referenced by Inkscape::UI::PathManipulator::_updateDragPoint(), are_near(), box3d_half_line_crosses_joining_line(), chord_length_parameterize(), compute_hook(), control_poly_flat_enough(), distance(), Inkscape::LivePathEffect::LPEGears::doEffect_path(), Inkscape::UI::Node::dragged(), Inkscape::UI::Handle::dragged(), estimate_lengths(), Inkscape::UI::Node::setType(), and vector_stretch().
Definition at line 198 of file ray.h.
References distance(), Geom::Ray::nearestPoint(), and Geom::Ray::pointAt().
{
double t = _ray.nearestPoint(_point);
return distance(_point, _ray.pointAt(t));
}
Returns the smallest distance between p and rect.
Definition at line 190 of file rect.h.
References distanceSq(), and sqrt().
{
return std::sqrt(distanceSq(p, rect));
}
Definition at line 312 of file line.h.
References L2(), Geom::BezierCurve< order >::nearestPoint(), and Geom::BezierCurve< order >::pointAt().
{
double t = _segment.nearestPoint(_point);
return L2(_point - _segment.pointAt(t));
}
compute the square of the distance between points a and b.
Definition at line 224 of file 2geom/point.h.
References L2sq().
Referenced by Geom::SVGEllipticalArc::allNearestPoints(), Geom::Path::allNearestPoints(), Geom::EllipticalArc::allNearestPoints(), distance(), and Geom::Path::nearestPoint().
Definition at line 164 of file rect.h.
References Geom::D2< Interval >::bottom(), Geom::D2< Interval >::left(), Geom::D2< Interval >::right(), Geom::D2< Interval >::top(), X, and Y.
| Piecewise< SBasis > Geom::divide | ( | Piecewise< SBasis > const & | a, | |
| Piecewise< SBasis > const & | b, | |||
| unsigned | k | |||
| ) |
Referenced by atan2(), curvature(), Inkscape::LivePathEffect::LPEPerspectivePath::doEffect_pwd2(), and Geom::sturm::sturm().
| Piecewise< SBasis > Geom::divide | ( | Piecewise< SBasis > const & | a, | |
| SBasis const & | b, | |||
| double | tol, | |||
| unsigned | k, | |||
| double | zero | |||
| ) |
| Piecewise< SBasis > Geom::divide | ( | Piecewise< SBasis > const & | a, | |
| Piecewise< SBasis > const & | b, | |||
| double | tol, | |||
| unsigned | k, | |||
| double | zero | |||
| ) |
| Piecewise< SBasis > Geom::divide | ( | SBasis const & | a, | |
| Piecewise< SBasis > const & | b, | |||
| double | tol, | |||
| unsigned | k, | |||
| double | zero | |||
| ) |
| Piecewise< SBasis > Geom::divide | ( | SBasis const & | a, | |
| SBasis const & | b, | |||
| double | tol, | |||
| unsigned | k, | |||
| double | zero | |||
| ) |
| Poly Geom::divide | ( | Poly const & | a, | |
| Poly const & | b, | |||
| Poly & | r | |||
| ) |
| SBasis2d Geom::divide | ( | SBasis2d const & | a, | |
| SBasis2d const & | b, | |||
| int | k | |||
| ) |
| SBasis Geom::divide | ( | SBasis const & | a, | |
| SBasis const & | b, | |||
| int | k | |||
| ) |
Compute a / b to k terms.
- Parameters:
-
a,b sbasis functions
- Returns:
- sbasis a/b
It is recommended to use the piecewise version unless you have good reason.
| T Geom::dot | ( | D2< T > const & | a, | |
| D2< T > const & | b | |||
| ) | [inline] |
Definition at line 314 of file d2.h.
References Barcode::Code39Ext::i, and polyhedron_3d::r.
Referenced by Inkscape::ObjectSnapper::_snapPathsConstrained(), arcLengthSb(), Geom::make_elliptical_arc::bound_exceeded(), centroid(), SnapManager::constrainedSnap(), Inkscape::LineSnapper::constrainedSnap(), cross(), curvature(), distance(), distance(), Geom::detail::bezier_clipping::distance_control_points(), distanceLessThanOrEqual(), DistanceToCubic(), Geom::Piecewise< T >::dot(), estimate_lengths(), Geom::Line::fromNormalDistance(), Geom::ConvexHull::furthest(), intersect_polish_root(), L2(), length_integrating(), lensq(), Box3D::Line::lie_on_same_side(), line_intersection(), line_segment_intersect(), line_twopoint_intersect(), Geom::ConvexHull::narrowest_diameter(), Geom::Ray::nearestPoint(), NewtonRaphsonRootFind(), RecDistanceToCubic(), rect_line_intersect(), Inkscape::SelTrans::rotateRequest(), segment_intersect(), sp_dyna_draw_context_root_handler(), sp_guide_distance_from_pt(), sp_guideline_point(), Geom::Line::timeAtProjection(), and unitVector().
| T Geom::elem_portion | ( | const Piecewise< T > & | a, | |
| unsigned | i, | |||
| double | from, | |||
| double | to | |||
| ) |
Definition at line 313 of file piecewise.h.
References Geom::Piecewise< T >::cuts, portion(), and Geom::Piecewise< T >::size().
Referenced by partition(), portion(), and remove_short_cuts_extending().
| static void Geom::eliminate_duplicates_p | ( | std::vector< Point > & | pts | ) | [static] |
Definition at line 231 of file 2geom/geom.cpp.
Referenced by rect_line_intersect().
{
unsigned int size = pts.size();
if (size < 2)
return;
if (size == 2) {
if (pts[0] == pts[1]) {
pts.pop_back();
}
} else {
std::sort(pts.begin(), pts.end(), &is_less);
if (size == 3) {
if (pts[0] == pts[1]) {
pts.erase(pts.begin());
} else if (pts[1] == pts[2]) {
pts.pop_back();
}
} else {
// we have size == 4
if (pts[2] == pts[3]) {
pts.pop_back();
}
if (pts[0] == pts[1]) {
pts.erase(pts.begin());
}
}
}
}
| Matrix Geom::elliptic_quadratic_form | ( | Matrix const & | m | ) |
Given a matrix m such that unit_circle = m*x, this returns the quadratic form x*A*x = 1.
Referenced by NrMatrixTest::testEllipticQuadraticForm().
Definition at line 361 of file recursive-bezier-intersection.cpp.
Referenced by intersect_polish_root().
{
dbl_64 s;
s.d64 = value;
s.i64 += eps;
return s.d64;
}
| static void Geom::estimate_bi | ( | Point | b[4], | |
| unsigned | ei, | |||
| Point const | data[], | |||
| double const | u[], | |||
| unsigned | len | |||
| ) | [static] |
Definition at line 500 of file bezier-utils.cpp.
References b, B0, B1, B2, B3, NR::d, and Barcode::Code39Ext::i.
Referenced by generate_bezier().
{
if(!(1 <= ei && ei <= 2))
return;
unsigned const oi = 3 - ei;
double num[2] = {0., 0.};
double den = 0.;
for (unsigned i = 0; i < len; ++i) {
double const ui = u[i];
double const b[4] = {
B0(ui),
B1(ui),
B2(ui),
B3(ui)
};
for (unsigned d = 0; d < 2; ++d) {
num[d] += b[ei] * (b[0] * bezier[0][d] +
b[oi] * bezier[oi][d] +
b[3] * bezier[3][d] +
- data[i][d]);
}
den -= b[ei] * b[ei];
}
if (den != 0.) {
for (unsigned d = 0; d < 2; ++d) {
bezier[ei][d] = num[d] / den;
}
} else {
bezier[ei] = ( oi * bezier[0] + ei * bezier[3] ) / 3.;
}
}
| static void Geom::estimate_lengths | ( | Point | bezier[], | |
| Point const | data[], | |||
| double const | u[], | |||
| unsigned | len, | |||
| Point const & | tHat1, | |||
| Point const & | tHat2 | |||
| ) | [static] |
- Todo:
- Check whether this special-casing is necessary now that NewtonRaphsonRootFind handles non-positive denominator.
- Todo:
- Check whether this special-casing is necessary now that NewtonRaphsonRootFind handles non-positive denominator.
Definition at line 395 of file bezier-utils.cpp.
References B0, B1, B2, B3, distance(), dot(), addnodes::e, Barcode::Code39Ext::i, and X.
Referenced by generate_bezier().
{
double C[2][2]; /* Matrix C. */
double X[2]; /* Matrix X. */
/* Create the C and X matrices. */
C[0][0] = 0.0;
C[0][1] = 0.0;
C[1][0] = 0.0;
C[1][1] = 0.0;
X[0] = 0.0;
X[1] = 0.0;
/* First and last control points of the Bezier curve are positioned exactly at the first and
last data points. */
bezier[0] = data[0];
bezier[3] = data[len - 1];
for (unsigned i = 0; i < len; i++) {
/* Bezier control point coefficients. */
double const b0 = B0(uPrime[i]);
double const b1 = B1(uPrime[i]);
double const b2 = B2(uPrime[i]);
double const b3 = B3(uPrime[i]);
/* rhs for eqn */
Point const a1 = b1 * tHat1;
Point const a2 = b2 * tHat2;
C[0][0] += dot(a1, a1);
C[0][1] += dot(a1, a2);
C[1][0] = C[0][1];
C[1][1] += dot(a2, a2);
/* Additional offset to the data point from the predicted point if we were to set bezier[1]
to bezier[0] and bezier[2] to bezier[3]. */
Point const shortfall
= ( data[i]
- ( ( b0 + b1 ) * bezier[0] )
- ( ( b2 + b3 ) * bezier[3] ) );
X[0] += dot(a1, shortfall);
X[1] += dot(a2, shortfall);
}
/* We've constructed a pair of equations in the form of a matrix product C * alpha = X.
Now solve for alpha. */
double alpha_l, alpha_r;
/* Compute the determinants of C and X. */
double const det_C0_C1 = C[0][0] * C[1][1] - C[1][0] * C[0][1];
if ( det_C0_C1 != 0 ) {
/* Apparently Kramer's rule. */
double const det_C0_X = C[0][0] * X[1] - C[0][1] * X[0];
double const det_X_C1 = X[0] * C[1][1] - X[1] * C[0][1];
alpha_l = det_X_C1 / det_C0_C1;
alpha_r = det_C0_X / det_C0_C1;
} else {
/* The matrix is under-determined. Try requiring alpha_l == alpha_r.
*
* One way of implementing the constraint alpha_l == alpha_r is to treat them as the same
* variable in the equations. We can do this by adding the columns of C to form a single
* column, to be multiplied by alpha to give the column vector X.
*
* We try each row in turn.
*/
double const c0 = C[0][0] + C[0][1];
if (c0 != 0) {
alpha_l = alpha_r = X[0] / c0;
} else {
double const c1 = C[1][0] + C[1][1];
if (c1 != 0) {
alpha_l = alpha_r = X[1] / c1;
} else {
/* Let the below code handle this. */
alpha_l = alpha_r = 0.;
}
}
}
/* If alpha negative, use the Wu/Barsky heuristic (see text). (If alpha is 0, you get
coincident control points that lead to divide by zero in any subsequent
NewtonRaphsonRootFind() call.) */
if ( alpha_l < 1.0e-6 ||
alpha_r < 1.0e-6 )
{
alpha_l = alpha_r = distance(data[0], data[len-1]) / 3.0;
}
/* Control points 1 and 2 are positioned an alpha distance out on the tangent vectors, left and
right, respectively. */
bezier[1] = alpha_l * tHat1 + bezier[0];
bezier[2] = alpha_r * tHat2 + bezier[3];
return;
}
Definition at line 82 of file chebyshev.cpp.
References Geom::wrap::f, Geom::wrap::fa, Geom::wrap::fb, Geom::wrap::in, and Geom::wrap::pp.
| std::vector< std::vector< unsigned > > Geom::fake_cull | ( | unsigned | a, | |
| unsigned | b | |||
| ) |
| Geom::Point Geom::finalPoint | ( | PathVector const & | path_in | ) | [inline] |
Definition at line 97 of file pathvector.h.
Referenced by Inkscape::LivePathEffect::LPELineSegment::doEffect_path().
{
return path_in.back().finalPoint();
}
| void Geom::find_bernstein_roots | ( | double const * | w, | |
| unsigned | degree, | |||
| std::vector< double > & | solutions, | |||
| unsigned | depth, | |||
| double | left_t, | |||
| double | right_t, | |||
| bool | use_secant | |||
| ) |
Referenced by Geom::Bezier::roots().
| unsigned Geom::find_bottom_right | ( | ConvexHull const & | a | ) |
| void Geom::find_collinear_normal | ( | std::vector< std::pair< double, double > > & | xs, | |
| std::vector< Point > const & | A, | |||
| std::vector< Point > const & | B, | |||
| double | precision = 1e-5 | |||
| ) |
Definition at line 1246 of file bezier-clipping.cpp.
{
using detail::bezier_clipping::get_solutions;
using detail::bezier_clipping::collinear_normal_tag;
get_solutions<collinear_normal_tag>(xs, A, B, precision);
}
| unsigned Geom::find_crossing | ( | Crossings const & | cr, | |
| Crossing | x, | |||
| unsigned | i | |||
| ) |
Definition at line 89 of file 2geom/shape.cpp.
| void Geom::find_intersections | ( | std::vector< std::pair< double, double > > & | xs, | |
| D2< SBasis > const & | A, | |||
| D2< SBasis > const & | B | |||
| ) |
| void Geom::find_intersections | ( | std::vector< std::pair< double, double > > & | xs, | |
| std::vector< Point > const & | A, | |||
| std::vector< Point > const & | B, | |||
| double | precision | |||
| ) |
| void Geom::find_intersections_bezier_clipping | ( | std::vector< std::pair< double, double > > & | xs, | |
| std::vector< Point > const & | A, | |||
| std::vector< Point > const & | B, | |||
| double | precision = 1e-5 | |||
| ) |
Definition at line 1268 of file bezier-clipping.cpp.
{
using detail::bezier_clipping::get_solutions;
using detail::bezier_clipping::intersection_point_tag;
get_solutions<intersection_point_tag>(xs, A, B, precision);
}
| void Geom::find_intersections_bezier_recursive | ( | std::vector< std::pair< double, double > > & | xs, | |
| OldBezier | a, | |||
| OldBezier | b | |||
| ) | [static] |
Definition at line 445 of file recursive-bezier-intersection.cpp.
References intersect_BB(), recursively_intersect(), and wangs_theorem().
Referenced by find_intersections_bezier_recursive().
{
if( intersect_BB( a, b ) )
{
recursively_intersect( a, 0., 1., wangs_theorem(a),
b, 0., 1., wangs_theorem(b),
xs);
}
/*for(unsigned i = 0; i < xs.size(); i++)
intersect_polish_root(a, xs[i].first,
b, xs[i].second);*/
std::sort(xs.begin(), xs.end());
}
| void Geom::find_intersections_bezier_recursive | ( | std::vector< std::pair< double, double > > & | xs, | |
| vector< Geom::Point > const & | A, | |||
| vector< Geom::Point > const & | B, | |||
| double | precision | |||
| ) |
Definition at line 63 of file recursive-bezier-intersection.cpp.
References org::w3c::dom::svg::a, b, find_intersections_bezier_recursive(), and Geom::OldBezier::p.
{
OldBezier a, b;
a.p = A;
b.p = B;
return find_intersections_bezier_recursive(xs, a,b);
}
| void Geom::find_parametric_bezier_roots | ( | Geom::Point const * | w, | |
| unsigned | degree, | |||
| std::vector< double > & | solutions, | |||
| unsigned | depth | |||
| ) |
| void Geom::find_self_intersections | ( | std::vector< std::pair< double, double > > & | xs, | |
| D2< SBasis > const & | A | |||
| ) |
| std::vector<double> Geom::find_tangents | ( | Point | P, | |
| D2< SBasis > const & | A | |||
| ) |
returns all the parameter values of A whose tangent passes through P.
Definition at line 747 of file sbasis-geometric.cpp.
References Geom::D2< T >::cross(), Geom::detail::bezier_clipping::derivative(), roots(), and shift().
| void Geom::first_false | ( | std::vector< std::vector< bool > > | visited, | |
| unsigned & | i, | |||
| unsigned & | j | |||
| ) |
Definition at line 78 of file 2geom/shape.cpp.
References scour::end, and org::w3c::dom::find().
| void Geom::flip_crossings | ( | Crossings & | crs | ) |
| Piecewise<D2<SBasis> > Geom::force_continuity | ( | Piecewise< D2< SBasis > > const & | f, | |
| double | tol, | |||
| bool | closed | |||
| ) |
Definition at line 135 of file d2-sbasis.cpp.
References c, Geom::SBasis::empty(), org::w3c::dom::svg::f, L2sq(), org::w3c::dom::svg::result, and Geom::Piecewise< T >::segs.
Referenced by Inkscape::LivePathEffect::LPERecursiveSkeleton::doEffect_pwd2(), Inkscape::LivePathEffect::LPEPatternAlongPath::doEffect_pwd2(), Inkscape::LivePathEffect::LPEEnvelope::doEffect_pwd2(), Inkscape::LivePathEffect::LPEDynastroke::doEffect_pwd2(), and Inkscape::LivePathEffect::LPEBendPath::doEffect_pwd2().
{
if (f.size()==0) return f;
Piecewise<D2<SBasis> > result=f;
unsigned cur = (closed)? 0:1;
unsigned prev = (closed)? f.size()-1:0;
while(cur<f.size()){
Point pt0 = f.segs[prev].at1();
Point pt1 = f.segs[cur ].at0();
if (tol<=0 || L2sq(pt0-pt1)<tol*tol){
pt0 = (pt0+pt1)/2;
for (unsigned dim=0; dim<2; dim++){
SBasis &prev_sb=result.segs[prev][dim];
SBasis &cur_sb =result.segs[cur][dim];
Coord const c=pt0[dim];
if (prev_sb.empty()) {
prev_sb = SBasis(Linear(0.0, c));
} else {
prev_sb[0][1] = c;
}
if (cur_sb.empty()) {
cur_sb = SBasis(Linear(c, 0.0));
} else {
cur_sb[0][0] = c;
}
}
}
prev = cur++;
}
return result;
}
Creates a Matrix given an axis and origin point.
The axis is represented as two vectors, which represent skew, rotation, and scaling in two dimensions. from_basis(Point(1, 0), Point(0, 1), Point(0, 0)) would return the identity matrix.
- Parameters:
-
x_basis the vector for the x-axis. y_basis the vector for the y-axis. offset the translation applied by the matrix.
- Returns:
- The new Matrix.
Referenced by Inkscape::LivePathEffect::findShadowedTime().
Definition at line 320 of file 2geom/shape.cpp.
Referenced by pick_coincident().
| std::vector<Piecewise<D2<SBasis> > > Geom::fuse_nearby_ends | ( | std::vector< Piecewise< D2< SBasis > > > const & | f, | |
| double | tol | |||
| ) |
Definition at line 215 of file d2-sbasis.cpp.
References org::w3c::dom::svg::a, b, Geom::Piecewise< T >::concat(), org::w3c::dom::svg::f, Geom::Piecewise< T >::firstValue(), Barcode::Code39Ext::i, L2(), Geom::Piecewise< T >::lastValue(), org::w3c::dom::svg::result, Geom::Piecewise< T >::segs, set_first_point(), and set_last_point().
Referenced by Inkscape::LivePathEffect::LPEPatternAlongPath::doEffect_pwd2().
{
if ( f.size()==0 ) return f;
std::vector<Piecewise<D2<SBasis> > > result;
std::vector<std::vector<unsigned> > pre_result;
for (unsigned i=0; i<f.size(); i++){
bool inserted = false;
Point a = f[i].firstValue();
Point b = f[i].lastValue();
for (unsigned j=0; j<pre_result.size(); j++){
Point aj = f.at(pre_result[j].back()).lastValue();
Point bj = f.at(pre_result[j].front()).firstValue();
if ( L2(a-aj) < tol ) {
pre_result[j].push_back(i);
inserted = true;
break;
}
if ( L2(b-bj) < tol ) {
pre_result[j].insert(pre_result[j].begin(),i);
inserted = true;
break;
}
}
if (!inserted) {
pre_result.push_back(std::vector<unsigned>());
pre_result.back().push_back(i);
}
}
for (unsigned i=0; i<pre_result.size(); i++){
Piecewise<D2<SBasis> > comp;
for (unsigned j=0; j<pre_result[i].size(); j++){
Piecewise<D2<SBasis> > new_comp = f.at(pre_result[i][j]);
if ( j>0 ){
set_first_point( new_comp, comp.segs.back().at1() );
}
comp.concat(new_comp);
}
if ( L2(comp.firstValue()-comp.lastValue()) < tol ){
//TODO: check sizes!!!
set_last_point( comp, comp.segs.front().at0() );
}
result.push_back(comp);
}
return result;
return f;
}
| Poly Geom::gcd | ( | Poly const & | a, | |
| Poly const & | b, | |||
| const | double | |||
| ) |
| static void Geom::generate_bezier | ( | Point | bezier[], | |
| Point const | data[], | |||
| double const | u[], | |||
| unsigned const | len, | |||
| Point const & | tHat1, | |||
| Point const & | tHat2, | |||
| double const | tolerance_sq | |||
| ) | [static] |
Fill in bezier[] based on the given data and tangent requirements, using a least-squares fit.
Each of tHat1 and tHat2 should be either a zero vector or a unit vector. If it is zero, then bezier[1 or 2] is estimated without constraint; otherwise, it bezier[1 or 2] is placed in the specified direction from bezier[0 or 3].
- Parameters:
-
tolerance_sq Used only for an initial guess as to tangent directions when tHat1 or tHat2 is zero.
Definition at line 368 of file bezier-utils.cpp.
References darray_left_tangent(), darray_right_tangent(), estimate_bi(), estimate_lengths(), is_zero(), and unit_vector().
{
bool const est1 = is_zero(tHat1);
bool const est2 = is_zero(tHat2);
Point est_tHat1( est1
? darray_left_tangent(data, len, tolerance_sq)
: tHat1 );
Point est_tHat2( est2
? darray_right_tangent(data, len, tolerance_sq)
: tHat2 );
estimate_lengths(bezier, data, u, len, est_tHat1, est_tHat2);
/* We find that darray_right_tangent tends to produce better results
for our current freehand tool than full estimation. */
if (est1) {
estimate_bi(bezier, 1, data, u, len);
if (bezier[1] != bezier[0]) {
est_tHat1 = unit_vector(bezier[1] - bezier[0]);
}
estimate_lengths(bezier, data, u, len, est_tHat1, est_tHat2);
}
}
| NodeType Geom::get_nodetype | ( | Curve const & | c_incoming, | |
| Curve const & | c_outgoing | |||
| ) |
Referenced by Inkscape::LivePathEffect::LPESpiro::doEffect(), and sp_shape_snappoints().
| ConvexHull Geom::graham_merge | ( | ConvexHull | a, | |
| ConvexHull | b | |||
| ) |
if we modified graham scan to work top to bottom as proposed in lect754.pdf we could replace the angle sort with a simple merge sort type algorithm. furthermore, we could do the graham scan online, avoiding a bunch of memory copies. That would probably be linear. -- njh
| D2<SBasis> Geom::handles_to_sbasis | ( | T const & | handles, | |
| unsigned | order | |||
| ) | [inline] |
Definition at line 70 of file bezier-to-sbasis.h.
References bezier_to_sbasis(), and Barcode::Code39Ext::i.
| double Geom::hausdorf | ( | D2< SBasis > & | A, | |
| D2< SBasis > const & | B, | |||
| double | m_precision, | |||
| double * | a_t, | |||
| double * | b_t | |||
| ) |
Compute the symmetric Hausdorf distance.
| double Geom::hausdorfl | ( | D2< SBasis > & | A, | |
| D2< SBasis > const & | B, | |||
| double | m_precision, | |||
| double * | a_t, | |||
| double * | b_t | |||
| ) |
Compute the Hausdorf distance from A to B only.
| Matrix Geom::identity | ( | ) | [inline] |
Returns the Identity Matrix.
Definition at line 136 of file matrix.h.
Referenced by Inkscape::ObjectSnapper::_collectPaths(), Inkscape::Extension::Internal::CairoRenderContext::_createPatternPainter(), Inkscape::ObjectSnapper::_snapPaths(), box3d_set_transform(), clip_ref_changed(), clonetiler_get_transform(), Inkscape::UI::SkewHandle::computeTransform(), Inkscape::UI::ScaleSideHandle::computeTransform(), Inkscape::UI::ScaleCornerHandle::computeTransform(), connector_spacing_changed(), Inkscape::ObjectSnapper::constrainedSnap(), Inkscape::Extension::Internal::CairoRenderer::createContext(), SPGradientTest::createSuiteSubclass(), do_trace(), do_update(), feed_path_to_cairo(), Inkscape::ObjectSnapper::freeSnap(), generate_marker(), Inkscape::Filters::FilterUnits::get_matrix_user2units(), Inkscape::ObjectSnapper::guideConstrainedSnap(), Inkscape::ObjectSnapper::guideFreeSnap(), i2anc_affine(), i2i_affine(), SPItem::init(), SPGradientImpl::init(), font_instance::InitTheFace(), Inkscape::Extension::Internal::LaTeXTextRenderer::LaTeXTextRenderer(), font_instance::LoadGlyph(), mask_ref_changed(), nr_arena_shape_update_fill(), nr_arena_shape_update_stroke(), Inkscape::LivePathEffect::GroupBBoxEffect::original_bbox(), paint(), SPLGPainter::painter_new(), Path_for_item(), Inkscape::UI::PathManipulator::PathManipulator(), pattern_tile(), Inkscape::Filters::FilterImage::render(), Inkscape::LivePathEffect::LPERoughHatches::resetDefaults(), Inkscape::LivePathEffect::LPEExtrude::resetDefaults(), Inkscape::SelTrans::scaleRequest(), set_to_accumulated(), SPGradientImpl::setGradientAttr(), Inkscape::UI::Widget::RegisteredTransformedPoint::setTransform(), Inkscape::SelTrans::skewRequest(), sp_canvas_item_i2w_affine(), sp_canvas_item_init(), sp_canvastext_init(), sp_document_setup_viewport(), sp_dyna_draw_context_root_handler(), sp_flood_do_flood_fill(), sp_flowtext_modified(), sp_flowtext_print(), sp_flowtext_show(), sp_flowtext_update(), sp_gradient_convert_to_userspace(), sp_gradient_reset_to_userspace(), sp_image_set_curve(), sp_item_gradient_get_coords(), sp_item_group_ungroup(), sp_item_invoke_show(), sp_item_set(), sp_item_transform_repr(), sp_item_update(), sp_item_write_transform(), sp_line_set_transform(), sp_marker_update(), sp_offset_move_compensate(), sp_path_set_transform(), sp_root_build(), sp_root_update(), sp_selected_path_create_offset_object(), sp_selected_path_do_offset(), sp_selected_path_simplify_item(), sp_selection_group_impl(), sp_selection_paste_impl(), sp_shape_print(), Inkscape::Extension::Internal::sp_shape_render(), sp_shape_show(), sp_shape_update(), sp_svg_transform_read(), sp_symbol_init(), Inkscape::Extension::Internal::sp_symbol_render(), sp_symbol_update(), sp_text_align_mode_changed(), sp_text_modified(), sp_text_print(), sp_text_show(), sp_text_update(), sp_use_get_parent_transform(), sp_use_get_root_transform(), sp_use_unlink(), sp_use_update(), Inkscape::SelTrans::stretchRequest(), SPGradientTest::testGetG2dGetGs2dSetGs2d(), SvgAffineTest::testReadIdentity(), SPGradientTest::testSetGradientTransform(), and SvgAffineTest::testWriteIdentity().
{
return Matrix(1.0, 0.0,
0.0, 1.0,
0.0, 0.0);
}
| iter Geom::inc | ( | iter const & | x, | |
| unsigned | n | |||
| ) |
Definition at line 73 of file 2geom/path.cpp.
References Barcode::Code39Ext::i.
Referenced by Geom::Path::appendPortionTo().
| Coord Geom::infinity | ( | ) | [inline] |
Definition at line 51 of file coord.h.
Referenced by NR::Rect::_inf(), gr_knot_moved_handler(), and Inkscape::LivePathEffect::ArrayParam< StorageType >::readsvg().
{ return std::numeric_limits<Coord>::infinity(); }
| Geom::Point Geom::initialPoint | ( | PathVector const & | path_in | ) | [inline] |
Definition at line 91 of file pathvector.h.
Referenced by Inkscape::LivePathEffect::LPELineSegment::doEffect_path(), and Inkscape::LivePathEffect::LPEConstructGrid::doEffect_path().
{
return path_in.front().initialPoint();
}
| std::vector<Path> Geom::inner_sanitize | ( | std::vector< Path > const & | ps | ) |
Definition at line 416 of file 2geom/shape.cpp.
References Geom::Path::append(), crossing_along(), crossing_dual(), crossings_among(), Geom::Crossing::getTime(), outer_crossing(), uniconv-ext::p, pick_coincident(), reverse(), Geom::Path::size(), and Geom::Path::STITCH_DISCONTINUOUS.
{
CrossingSet crs(crossings_among(ps));
Regions chunks;
std::vector<bool> used_path(ps.size(), false);
std::vector<std::vector<bool> > visited;
for(unsigned i = 0; i < crs.size(); i++)
visited.push_back(std::vector<bool>(crs[i].size(), false));
std::vector<Path> result_paths;
while(true) {
unsigned ix = 0, jx = 0;
bool dir = false;
//find an outer crossing by trying various paths and checking if the crossings are used
for(; ix < crs.size(); ix++) {
//TODO: optimize so it doesn't unecessarily check stuff
bool cont = true;
for(unsigned j = 0; j < crs[ix].size(); j++) {
if(!visited[ix][j]) { cont = false; break; }
}
if(cont) continue;
unsigned rix = ix, rjx = jx;
outer_crossing(rix, rjx, dir, ps, crs);
if(rix >= crs.size() || visited[rix][rjx]) continue;
ix = rix; jx = rjx;
break;
}
if(ix == crs.size()) break;
crossing_dual(ix, jx, crs);
dir = !dir;
Path res;
do {
visited[ix][jx] = true;
//unsigned nix = ix, njx = jx;
//crossing_dual(nix, njx, crs);
//visited[nix][njx] = true;
unsigned fix = ix, fjx = jx;
bool new_dir = dir;
jx = crossing_along(crs[ix][jx].getTime(ix), ix, jx, dir, crs[ix]);
if(crs[ix][jx].a != crs[ix][jx].b) crossing_dual(ix, jx, crs); else new_dir = !new_dir;
jx = pick_coincident(ix, jx, new_dir, ps, crs);
//unsigned nix = ix, njx = jx;
//crossing_dual(nix, njx, crs);
Crossing from = crs[fix][fjx],
to = crs[ix][jx];
if(dir) {
// backwards
#ifdef SHAPE_DEBUG
std::cout << "r" << ix << "[" << from.getTime(ix) << ", " << to.getTime(ix) << "]\n";
#endif
Path p = ps[ix].portion(from.getTime(ix), to.getTime(ix)).reverse();
for(unsigned i = 0; i < p.size(); i++)
res.append(p[i], Path::STITCH_DISCONTINUOUS);
} else {
// forwards
#ifdef SHAPE_DEBUG
std::cout << "f" << ix << "[" << from.getTime(ix) << ", " << to.getTime(ix) << "]\n";
#endif
ps[ix].appendPortionTo(res, from.getTime(ix), to.getTime(ix));
}
dir = new_dir;
} while(!visited[ix][jx]);
#ifdef SHAPE_DEBUG
std::cout << "added " << res.size() << "\n";
#endif
result_paths.push_back(res);
}
for(unsigned i = 0; i < crs.size(); i++) {
if(crs[i].empty() && !used_path[i])
result_paths.push_back(ps[i]);
}
return result_paths;
}
| int Geom::inner_winding | ( | Path const & | p, | |
| std::vector< Path > const & | ps | |||
| ) |
Definition at line 315 of file 2geom/shape.cpp.
References Geom::Path::initialPoint(), paths_winding(), and winding().
{
Point pnt = p.initialPoint();
return paths_winding(ps, pnt) - winding(p, pnt) + 1;
}
| D2<T> Geom::integral | ( | D2< T > const & | a | ) |
| Piecewise<T> Geom::integral | ( | Piecewise< T > const & | a | ) |
Definition at line 738 of file piecewise.h.
References c, Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, integral(), org::w3c::dom::svg::result, and Geom::Piecewise< T >::segs.
{
Piecewise<T> result;
result.segs.resize(a.segs.size());
result.cuts = a.cuts;
typename T::output_type c = a.segs[0].at0();
for(unsigned i = 0; i < a.segs.size(); i++){
result.segs[i] = integral(a.segs[i])*(a.cuts[i+1]-a.cuts[i]);
result.segs[i]+= c-result.segs[i].at0();
c = result.segs[i].at1();
}
return result;
}
| Poly Geom::integral | ( | Poly const & | p | ) |
| SBasis2d Geom::integral | ( | SBasis2d const & | c | ) |
| Bezier Geom::integral | ( | const Bezier & | a | ) | [inline] |
Definition at line 373 of file bezier.h.
References Barcode::Code39Ext::i, and Geom::Bezier::order().
Referenced by arcLengthSb(), atan2(), centroid(), Inkscape::LivePathEffect::LPESketch::doEffect_pwd2(), Inkscape::LivePathEffect::LPEPathLength::doEffect_pwd2(), and integral().
| SBasis Geom::integral | ( | SBasis const & | c | ) |
Compute the integral of a (Exact).
- Parameters:
-
a sbasis functions
- Returns:
- sbasis integral(a)
| Piecewise< SBasis > Geom::interpolate | ( | std::vector< double > | times, | |
| std::vector< double > | values, | |||
| unsigned | smoothness | |||
| ) |
Retruns a Piecewise SBasis with prescribed values at prescribed times.
- Parameters:
-
times,: vector of times at which the values are given. Should be sorted in increasing order. values,: vector of prescribed values. Should have the same size as times and be sorted accordingly. smoothness,: (defaults to 1) regularity class of the result: 0=piecewise linear, 1=continuous derivative, etc...
| OptInterval Geom::intersect | ( | const Interval & | a, | |
| const Interval & | b | |||
| ) | [inline] |
Definition at line 257 of file interval.h.
References Geom::Interval::max(), max(), min, and Geom::Interval::min().
Referenced by intersect().
| OptRect Geom::intersect | ( | Rect const & | a, | |
| Rect const & | b | |||
| ) | [inline] |
| bool Geom::intersect_BB | ( | OldBezier | a, | |
| OldBezier | b | |||
| ) |
Definition at line 170 of file recursive-bezier-intersection.cpp.
References Geom::OldBezier::bounds().
Referenced by find_intersections_bezier_recursive(), and recursively_intersect().
{
double minax, maxax, minay, maxay;
a.bounds(minax, maxax, minay, maxay);
double minbx, maxbx, minby, maxby;
b.bounds(minbx, maxbx, minby, maxby);
// Test bounding box of b against bounding box of a
// Not >= : need boundary case
return not( ( minax > maxbx ) || ( minay > maxby )
|| ( minbx > maxax ) || ( minby > maxay ) );
}
| static int Geom::intersect_polish_f | ( | const gsl_vector * | x, | |
| void * | params, | |||
| gsl_vector * | f | |||
| ) | [static] |
Definition at line 341 of file recursive-bezier-intersection.cpp.
{
const double x0 = gsl_vector_get (x, 0);
const double x1 = gsl_vector_get (x, 1);
Geom::Point dx = ((struct rparams *) params)->A(x0) -
((struct rparams *) params)->B(x1);
gsl_vector_set (f, 0, dx[0]);
gsl_vector_set (f, 1, dx[1]);
return GSL_SUCCESS;
}
| static void Geom::intersect_polish_root | ( | D2< SBasis > const & | A, | |
| double & | s, | |||
| D2< SBasis > const & | B, | |||
| double & | t | |||
| ) | [static] |
we want to solve J*(x1 - x0) = f(x0)
|dA(s)[0] -dB(t)[0]| (X1 - X0) = A(s) - B(t) |dA(s)[1] -dB(t)[1]|
Definition at line 178 of file basic-intersection.cpp.
References c, dot(), addnodes::e, EpsilonBy(), Barcode::Code39Ext::i, Geom::Matrix::inverse(), L1(), n, status, and Geom::D2< T >::valueAndDerivatives().
Referenced by mono_intersect(), and pair_intersect().
{
#ifdef HAVE_GSL
const gsl_multiroot_fsolver_type *T;
gsl_multiroot_fsolver *sol;
int status;
size_t iter = 0;
#endif
std::vector<Point> as, bs;
as = A.valueAndDerivatives(s, 2);
bs = B.valueAndDerivatives(t, 2);
Point F = as[0] - bs[0];
double best = dot(F, F);
for(int i = 0; i < 4; i++) {
// We're using the standard transformation matricies, which is numerically rather poor. Much better to solve the equation using elimination.
Matrix jack(as[1][0], as[1][1],
-bs[1][0], -bs[1][1],
0, 0);
Point soln = (F)*jack.inverse();
double ns = s - soln[0];
double nt = t - soln[1];
as = A.valueAndDerivatives(ns, 2);
bs = B.valueAndDerivatives(nt, 2);
F = as[0] - bs[0];
double trial = dot(F, F);
if (trial > best*0.1) {// we have standards, you know
// At this point we could do a line search
break;
}
best = trial;
s = ns;
t = nt;
}
#ifdef HAVE_GSL
const size_t n = 2;
struct rparams p = {A, B};
gsl_multiroot_function f = {&intersect_polish_f, n, &p};
double x_init[2] = {s, t};
gsl_vector *x = gsl_vector_alloc (n);
gsl_vector_set (x, 0, x_init[0]);
gsl_vector_set (x, 1, x_init[1]);
T = gsl_multiroot_fsolver_hybrids;
sol = gsl_multiroot_fsolver_alloc (T, 2);
gsl_multiroot_fsolver_set (sol, &f, x);
do
{
iter++;
status = gsl_multiroot_fsolver_iterate (sol);
if (status) /* check if solver is stuck */
break;
status =
gsl_multiroot_test_residual (sol->f, 1e-12);
}
while (status == GSL_CONTINUE && iter < 1000);
s = gsl_vector_get (sol->x, 0);
t = gsl_vector_get (sol->x, 1);
gsl_multiroot_fsolver_free (sol);
gsl_vector_free (x);
#endif
{
// This code does a neighbourhood search for minor improvements.
double best_v = L1(A(s) - B(t));
//std::cout << "------\n" << best_v << std::endl;
Point best(s,t);
while (true) {
Point trial = best;
double trial_v = best_v;
for(int nsi = -1; nsi < 2; nsi++) {
for(int nti = -1; nti < 2; nti++) {
Point n(EpsilonBy(best[0], nsi),
EpsilonBy(best[1], nti));
double c = L1(A(n[0]) - B(n[1]));
//std::cout << c << "; ";
if (c < trial_v) {
trial = n;
trial_v = c;
}
}
}
if(trial == best) {
//std::cout << "\n" << s << " -> " << s - best[0] << std::endl;
//std::cout << t << " -> " << t - best[1] << std::endl;
//std::cout << best_v << std::endl;
s = best[0];
t = best[1];
return;
} else {
best = trial;
best_v = trial_v;
}
}
}
}
| static void Geom::intersect_polish_root | ( | OldBezier & | A, | |
| double & | s, | |||
| OldBezier & | B, | |||
| double & | t | |||
| ) | [static] |
Definition at line 370 of file recursive-bezier-intersection.cpp.
References c, addnodes::e, EpsilonBy(), org::w3c::dom::svg::f, L1(), n, status, and voronoi::x.
{
const gsl_multiroot_fsolver_type *T;
gsl_multiroot_fsolver *sol;
int status;
size_t iter = 0;
const size_t n = 2;
struct rparams p = {A, B};
gsl_multiroot_function f = {&intersect_polish_f, n, &p};
double x_init[2] = {s, t};
gsl_vector *x = gsl_vector_alloc (n);
gsl_vector_set (x, 0, x_init[0]);
gsl_vector_set (x, 1, x_init[1]);
T = gsl_multiroot_fsolver_hybrids;
sol = gsl_multiroot_fsolver_alloc (T, 2);
gsl_multiroot_fsolver_set (sol, &f, x);
do
{
iter++;
status = gsl_multiroot_fsolver_iterate (sol);
if (status) /* check if solver is stuck */
break;
status =
gsl_multiroot_test_residual (sol->f, 1e-12);
}
while (status == GSL_CONTINUE && iter < 1000);
s = gsl_vector_get (sol->x, 0);
t = gsl_vector_get (sol->x, 1);
gsl_multiroot_fsolver_free (sol);
gsl_vector_free (x);
// This code does a neighbourhood search for minor improvements.
double best_v = L1(A(s) - B(t));
//std::cout << "------\n" << best_v << std::endl;
Point best(s,t);
while (true) {
Point trial = best;
double trial_v = best_v;
for(int nsi = -1; nsi < 2; nsi++) {
for(int nti = -1; nti < 2; nti++) {
Point n(EpsilonBy(best[0], nsi),
EpsilonBy(best[1], nti));
double c = L1(A(n[0]) - B(n[1]));
//std::cout << c << "; ";
if (c < trial_v) {
trial = n;
trial_v = c;
}
}
}
if(trial == best) {
//std::cout << "\n" << s << " -> " << s - best[0] << std::endl;
//std::cout << t << " -> " << t - best[1] << std::endl;
//std::cout << best_v << std::endl;
s = best[0];
t = best[1];
return;
} else {
best = trial;
best_v = trial_v;
}
}
}
| static void Geom::intersect_polish_root | ( | Curve const & | A, | |
| double & | s, | |||
| Curve const & | B, | |||
| double & | t | |||
| ) | [static] |
we want to solve J*(x1 - x0) = f(x0)
|dA(s)[0] -dB(t)[0]| (X1 - X0) = A(s) - B(t) |dA(s)[1] -dB(t)[1]|
Definition at line 229 of file path-intersection.cpp.
References dot(), addnodes::e, Barcode::Code39Ext::i, Geom::Matrix::inverse(), n, Geom::Curve::pointAndDerivatives(), and status.
{
std::vector<Point> as, bs;
as = A.pointAndDerivatives(s, 2);
bs = B.pointAndDerivatives(t, 2);
Point F = as[0] - bs[0];
double best = dot(F, F);
for(int i = 0; i < 4; i++) {
// We're using the standard transformation matricies, which is numerically rather poor. Much better to solve the equation using elimination.
Matrix jack(as[1][0], as[1][1],
-bs[1][0], -bs[1][1],
0, 0);
Point soln = (F)*jack.inverse();
double ns = s - soln[0];
double nt = t - soln[1];
if (ns<0) ns=0;
else if (ns>1) ns=1;
if (nt<0) nt=0;
else if (nt>1) nt=1;
as = A.pointAndDerivatives(ns, 2);
bs = B.pointAndDerivatives(nt, 2);
F = as[0] - bs[0];
double trial = dot(F, F);
if (trial > best*0.1) // we have standards, you know
// At this point we could do a line search
break;
best = trial;
s = ns;
t = nt;
}
#ifdef HAVE_GSL
if(0) { // the GSL version is more accurate, but taints this with GPL
const size_t n = 2;
struct rparams p = {A, B};
gsl_multiroot_function f = {&intersect_polish_f, n, &p};
double x_init[2] = {s, t};
gsl_vector *x = gsl_vector_alloc (n);
gsl_vector_set (x, 0, x_init[0]);
gsl_vector_set (x, 1, x_init[1]);
const gsl_multiroot_fsolver_type *T = gsl_multiroot_fsolver_hybrids;
gsl_multiroot_fsolver *sol = gsl_multiroot_fsolver_alloc (T, 2);
gsl_multiroot_fsolver_set (sol, &f, x);
int status = 0;
size_t iter = 0;
do
{
iter++;
status = gsl_multiroot_fsolver_iterate (sol);
if (status) /* check if solver is stuck */
break;
status =
gsl_multiroot_test_residual (sol->f, 1e-12);
}
while (status == GSL_CONTINUE && iter < 1000);
s = gsl_vector_get (sol->x, 0);
t = gsl_vector_get (sol->x, 1);
gsl_multiroot_fsolver_free (sol);
gsl_vector_free (x);
}
#endif
}
| ConvexHull Geom::intersection | ( | ConvexHull | , | |
| ConvexHull | ||||
| ) |
Referenced by Inkscape::CanvasAxonomGridSnapper::_getSnapLines(), avoid_item_poly(), box3d_half_line_crosses_joining_line(), Inkscape::LineSnapper::constrainedSnap(), Inkscape::SnappedLine::intersect(), Inkscape::SnappedLineSegment::intersect(), make_angle_bisector_line(), and Path::PointToCurvilignPosition().
| OptCrossing Geom::intersection | ( | Line const & | l1, | |
| Line const & | l2 | |||
| ) |
| OptCrossing Geom::intersection | ( | LineSegment const & | ls1, | |
| LineSegment const & | ls2 | |||
| ) |
| OptCrossing Geom::intersection | ( | Ray const & | r1, | |
| Ray const & | r2 | |||
| ) |
| OptCrossing Geom::intersection | ( | Line const & | l1, | |
| Ray const & | r2 | |||
| ) | [inline] |
Definition at line 397 of file line.h.
References Geom::detail::intersection_impl().
{
return detail::intersection_impl(r2, l1, 1);
}
| OptCrossing Geom::intersection | ( | Ray const & | r1, | |
| Line const & | l2 | |||
| ) | [inline] |
Definition at line 390 of file line.h.
References Geom::detail::intersection_impl().
{
return detail::intersection_impl(r1, l2, 0);
}
| OptCrossing Geom::intersection | ( | Line const & | l1, | |
| LineSegment const & | ls2 | |||
| ) | [inline] |
Definition at line 409 of file line.h.
References Geom::detail::intersection_impl().
{
return detail::intersection_impl(ls2, l1, 1);
}
| OptCrossing Geom::intersection | ( | LineSegment const & | ls1, | |
| Line const & | l2 | |||
| ) | [inline] |
Definition at line 403 of file line.h.
References Geom::detail::intersection_impl().
{
return detail::intersection_impl(ls1, l2, 0);
}
| OptCrossing Geom::intersection | ( | LineSegment const & | ls1, | |
| Ray const & | r2 | |||
| ) | [inline] |
Definition at line 415 of file line.h.
References Geom::detail::intersection_impl().
{
return detail::intersection_impl(ls1, r2, 0);
}
| OptCrossing Geom::intersection | ( | Ray const & | r1, | |
| LineSegment const & | ls2 | |||
| ) | [inline] |
Definition at line 422 of file line.h.
References Geom::detail::intersection_impl().
{
return detail::intersection_impl(ls2, r1, 1);
}
| int Geom::intersector_ccw | ( | const Geom::Point & | p0, | |
| const Geom::Point & | p1, | |||
| const Geom::Point & | p2 | |||
| ) |
Referenced by line_segment_intersectp().
| bool Geom::intersectp | ( | ConvexHull | a, | |
| ConvexHull | b | |||
| ) |
| SBasis2d Geom::inverse | ( | SBasis2d const & | a, | |
| int | k | |||
| ) |
| SBasis Geom::inverse | ( | SBasis | a, | |
| int | k | |||
| ) |
find the function a^-1 such that a^-1 composed with a to k terms is the identity function
- Parameters:
-
a sbasis function
- Returns:
- sbasis a^-1 s.t. a^-1(a(t)) = 1
The function must have 'unit range'("a00 = 0 and a01 = 1") and be monotonic.
| bool Geom::is_unit_vector | ( | Point const & | p | ) |
Referenced by fit_and_split(), interpolate(), sketch_interpolate(), sp_spiral_fit_and_draw(), and sp_spiral_get_tangent().
| bool Geom::is_zero | ( | Point const & | p | ) |
Returns true iff p is a zero vector, i.e. Point(0, 0).
(NaN is considered non-zero.)
Referenced by Inkscape::ObjectSnapper::_snapPathsConstrained(), fit_and_split(), generate_bezier(), interpolate(), and sketch_interpolate().
Compute the L1 norm, or manhattan distance, of p.
Referenced by intersect_polish_root(), and NrTypesTest::testL1L2LInftyNorms().
Compute the L2, or euclidean, norm of p.
Definition at line 174 of file 2geom/point.h.
References Geom::Point::length().
{ return p.length(); }
| SBasis Geom::L2 | ( | D2< SBasis > const & | a, | |
| unsigned | k | |||
| ) |
Definition at line 8 of file d2-sbasis.cpp.
Referenced by Inkscape::LivePathEffect::_circle3(), Inkscape::SelTrans::_keepClosestPointOnly(), Inkscape::ObjectSnapper::_snapNodes(), Inkscape::ObjectSnapper::_snapPathsConstrained(), SnapManager::_snapTransformed(), Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(), add_cap(), Box3D::VPDrag::addDragger(), GrDrag::addDragger(), GrDrag::addStopNearPoint(), Inkscape::LivePathEffect::append_half_circle(), Path::AttemptSimplify(), box3d_snap(), Geom::SVGEllipticalArc::calculate_center_and_extreme_angles(), circle_circle_intersection(), Inkscape::LineSnapper::constrainedSnap(), Path::ConvertEvenLines(), Path::CurvilignToPosition(), Path::DashSubPath(), distance(), distance_to_segment(), distanceLessThanOrEqual(), Inkscape::LivePathEffect::LPECurveStitch::doEffect_path(), Inkscape::LivePathEffect::LPECircleWithRadius::doEffect_path(), Inkscape::LivePathEffect::LPERoughHatches::doEffect_pwd2(), Inkscape::LivePathEffect::LPEOffset::doEffect_pwd2(), Inkscape::LivePathEffect::LPECopyRotate::doOnApply(), Path::DoStroke(), GrDrag::dropColor(), Path::ExtendFit(), Inkscape::LineSnapper::freeSnap(), fuse_nearby_ends(), get_snap_vector(), gr_knot_moved_handler(), gr_knot_moved_midpoint_handler(), Inkscape::SelTrans::grab(), Inkscape::LivePathEffect::LPEKnotNS::idx_of_nearest(), Inkscape::SnappedLine::intersect(), Inkscape::SnappedLineSegment::intersect(), Inkscape::SnappedCurve::intersect(), Inkscape::SnappedPoint::isOtherSnapBetter(), Inkscape::ObjectSnapper::isUnselectedNode(), StarKnotHolderEntity2::knot_set(), StarKnotHolderEntity1::knot_set(), Inkscape::LivePathEffect::Pl::KnotHolderEntityRightEnd::knot_set(), Inkscape::LivePathEffect::Pl::KnotHolderEntityLeftEnd::knot_set(), Inkscape::LivePathEffect::CR::KnotHolderEntityRotationAngle::knot_set(), Inkscape::LivePathEffect::CR::KnotHolderEntityStartingAngle::knot_set(), Box3D::Line::lambda(), Path::Length(), Shape::MakeOffset(), Shape::MakeTweak(), Inkscape::Rubberband::move(), Inkscape::UI::Widget::Rotateable::on_motion(), Path::PositionToLength(), Inkscape::Snapper::SnapConstraint::projection(), Box3D::Line::pts_coincide(), Path::RecBezierTo(), Path::RecCubicTo(), Inkscape::LivePathEffect::LPERoughHatches::resetDefaults(), rot90_rel(), Inkscape::SelTrans::rotateRequest(), GrDrag::selectByCoords(), Proj::TransfMat3x4::set_infinite_direction(), sp_dropper_context_root_handler(), sp_dyna_draw_apply(), sp_dyna_draw_brush(), sp_dyna_draw_context_root_handler(), sp_eraser_apply(), sp_eraser_brush(), sp_event_context_snap_delay_handler(), sp_gradient_context_is_over_line(), sp_item_gradient_set_coords(), sp_knot_distance(), sp_offset_set_shape(), sp_selected_path_simplify_items(), sp_selection_rotate_screen(), sp_spiral_drag(), sp_spiral_get_tangent(), sp_star_drag(), sp_star_get_curvepoint(), sp_text_context_update_cursor(), sp_tweak_color_recursive(), sp_tweak_dilate_recursive(), sp_ui_drag_data_received(), spdc_pen_set_angle_distance_status_message(), split_at_discontinuities(), StrokeNormalize(), Path::TangentOnArcAt(), Path::TangentOnBezAt(), Path::TangentOnCubAt(), Path::TangentOnSegAt(), NrTypesTest::testL1L2LInftyNorms(), Geom::Ellipse::transformed(), tweak_colors_in_gradient(), unclump_dist(), and Box3D::vp_knot_moved_handler().
Compute the square of L2 norm of p.
Warning: this can overflow where L2 won't.
Definition at line 177 of file 2geom/point.h.
Referenced by Geom::SVGEllipticalArc::calculate_center_and_extreme_angles(), Geom::EllipticalArc::calculate_center_and_extreme_angles(), distanceSq(), force_continuity(), Inkscape::UI::Handle::move(), and Geom::angle_cmp::operator()().
| double Geom::length | ( | LineSegment const & | _segment | ) | [inline] |
Definition at line 219 of file bezier-curve.h.
References draw_from_triangle::distance(), Geom::BezierCurve< order >::finalPoint(), and Geom::BezierCurve< order >::initialPoint().
Referenced by arcLengthSb(), lpetool_create_measuring_items(), lpetool_update_measuring_items(), Geom::detail::bezier_clipping::map_to(), Geom::detail::bezier_clipping::orientation_line(), and Geom::Curve::unitTangentAt().
{
return distance(_segment.initialPoint(), _segment.finalPoint());
}
Calculates the length of a D2<SBasis> through gsl integration.
- Parameters:
-
s the Element. tol the maximum error allowed.
If you only want the total length, this routine faster and more accurate than constructing an arcLengthSb.
Definition at line 481 of file sbasis-geometric.cpp.
References length_integrating(), and org::w3c::dom::svg::result.
{
double result = 0;
double abs_error = 0;
length_integrating(s, result, abs_error, tol);
return result;
}
Calculates the length of a Piecewise<D2<SBasis> > through gsl integration.
- Parameters:
-
s the Element. tol the maximum error allowed.
If you only want the total length, this routine faster and more accurate than constructing an arcLengthSb.
Definition at line 495 of file sbasis-geometric.cpp.
References Barcode::Code39Ext::i, length_integrating(), and org::w3c::dom::svg::result.
| void Geom::length_integrating | ( | D2< SBasis > const & | B, | |
| double & | result, | |||
| double & | abs_error, | |||
| double | tol | |||
| ) |
Calculates the length of a D2<SBasis> through gsl integration.
- Parameters:
-
B the Element. tol the maximum error allowed. result variable to be incremented with the length of the path abs_error variable to be incremented with the estimated error
If you only want the length, this routine may be faster/more accurate.
Definition at line 455 of file sbasis-geometric.cpp.
References derivative(), dot(), err, and dxf_input::w.
Referenced by length().
{
D2<SBasis> dB = derivative(B);
SBasis dB2 = dot(dB, dB);
gsl_function F;
gsl_integration_workspace * w
= gsl_integration_workspace_alloc (20);
F.function = &sb_length_integrating;
F.params = (void*)&dB2;
double quad_result, err;
/* We could probably use the non adaptive code here if we removed any cusps first. */
gsl_integration_qag (&F, 0, 1, 0, tol, 20,
GSL_INTEG_GAUSS21, w, &quad_result, &err);
abs_error += err;
result += quad_result;
}
Definition at line 495 of file bezier-utils.cpp.
References dot().
Referenced by ArcAnglesAndCenter(), compute_max_error_ratio(), and NewtonRaphsonRootFind().
Given two points and a parameter t [0, 1], return a point proportionally from a to b by t.
Akin to 1 degree bezier.
Definition at line 211 of file 2geom/point.h.
Definition at line 51 of file linear.h.
Referenced by Bezier(), Geom::detail::bezier_clipping::left_portion(), Geom::detail::bezier_clipping::right_portion(), sketch_interpolate(), Geom::OldBezier::split(), split(), Inkscape::UI::PathManipulator::subdivideSegment(), and Geom::Linear::valueAt().
| IntersectorKind Geom::line_intersection | ( | Geom::Point const & | n0, | |
| double const | d0, | |||
| Geom::Point const & | n1, | |||
| double const | d1, | |||
| Geom::Point & | result | |||
| ) |
Finds the intersection of the two (infinite) lines defined by the points p such that dot(n0, p) == d0 and dot(n1, p) == d1.
If the two lines intersect, then result becomes their point of intersection; otherwise, result remains unchanged.
This function finds the intersection of the two lines (infinite) defined by n0.X = d0 and x1.X = d1. The algorithm is as follows: To compute the intersection point use kramer's rule:
* convert lines to form * ax + by = c * dx + ey = f * * ( * e.g. a = (x2 - x1), b = (y2 - y1), c = (x2 - x1)*x1 + (y2 - y1)*y1 * ) * * In our case we use: * a = n0.x d = n1.x * b = n0.y e = n1.y * c = d0 f = d1 * * so: * * adx + bdy = cd * adx + aey = af * * bdy - aey = cd - af * (bd - ae)y = cd - af * * y = (cd - af)/(bd - ae) * * repeat for x and you get: * * x = (fb - ce)/(bd - ae)
If the denominator (bd-ae) is 0 then the lines are parallel, if the numerators are 0 then the lines coincide.
- Todo:
- Why not use existing but outcommented code below (HAVE_NEW_INTERSECTOR_CODE)?
Definition at line 60 of file 2geom/geom.cpp.
References dot(), Point, rot90(), X, and Y.
Referenced by line_segment_intersect(), line_twopoint_intersect(), and segment_intersect().
{
double denominator = dot(Geom::rot90(n0), n1);
double X = n1[Geom::Y] * d0 -
n0[Geom::Y] * d1;
/* X = (-d1, d0) dot (n0[Y], n1[Y]) */
if (denominator == 0) {
if ( X == 0 ) {
return coincident;
} else {
return parallel;
}
}
double Y = n0[Geom::X] * d1 -
n1[Geom::X] * d0;
result = Geom::Point(X, Y) / denominator;
return intersects;
}
| IntersectorKind Geom::line_segment_intersect | ( | Geom::Point const & | p00, | |
| Geom::Point const & | p01, | |||
| Geom::Point const & | p10, | |||
| Geom::Point const & | p11, | |||
| Geom::Point & | result | |||
| ) |
Determine whether & where a line segments intersects an (infinite) line.
If there is no intersection, then result remains unchanged.
- Precondition:
- neither segment is zero-length; i.e. p00 != p01 and p10 != p11.
Definition at line 157 of file 2geom/geom.cpp.
References dot(), line_intersection(), and line_segment_intersectp().
Referenced by rect_line_intersect().
{
if(line_segment_intersectp(p00, p01, p10, p11)) {
Geom::Point n0 = (p01 - p00).ccw();
double d0 = dot(n0,p00);
Geom::Point n1 = (p11 - p10).ccw();
double d1 = dot(n1,p10);
return line_intersection(n0, d0, n1, d1, result);
} else {
return no_intersection;
}
}
| bool Geom::line_segment_intersectp | ( | Geom::Point const & | p00, | |
| Geom::Point const & | p01, | |||
| Geom::Point const & | p10, | |||
| Geom::Point const & | p11 | |||
| ) |
Determine whether the line segment from p00 to p01 intersects the infinite line passing through p10 and p11.
This doesn't find the point of intersection, use the line_intersect function above, or the segment_intersection interface below.
- Precondition:
- neither segment is zero-length; i.e. p00 != p01 and p10 != p11.
Definition at line 121 of file 2geom/geom.cpp.
References intersector_ccw().
Referenced by line_segment_intersect(), and segment_intersectp().
{
if(p00 == p01) return false;
if(p10 == p11) return false;
return ((intersector_ccw(p00, p01, p10) * intersector_ccw(p00, p01, p11)) <= 0 );
}
| IntersectorKind Geom::line_twopoint_intersect | ( | Geom::Point const & | p00, | |
| Geom::Point const & | p01, | |||
| Geom::Point const & | p10, | |||
| Geom::Point const & | p11, | |||
| Geom::Point & | result | |||
| ) |
Determine whether & where two line segments intersect.
If the two segments don't intersect, then result remains unchanged.
- Precondition:
- neither segment is zero-length; i.e. p00 != p01 and p10 != p11.
Definition at line 204 of file 2geom/geom.cpp.
References dot(), and line_intersection().
{
Geom::Point n0 = (p01 - p00).ccw();
double d0 = dot(n0,p00);
Geom::Point n1 = (p11 - p10).ccw();
double d1 = dot(n1,p10);
return line_intersection(n0, d0, n1, d1, result);
}
| bool Geom::linear_intersect | ( | Point | A0, | |
| Point | A1, | |||
| Point | B0, | |||
| Point | B1, | |||
| double & | tA, | |||
| double & | tB, | |||
| double & | det | |||
| ) |
Finds the intersection between the lines defined by A0 & A1, and B0 & B1.
Returns through the last 3 parameters, returning the t-values on the lines and the cross-product of the deltas (a useful byproduct). The return value indicates if the time values are within their proper range on the line segments.
Definition at line 164 of file path-intersection.cpp.
References cross(), and NR::d.
Referenced by mono_intersect(), mono_pair(), and pair_intersect().
Compute the L infinity, or maximum, norm of p.
Referenced by Path::ConvertEvenLines(), Path::ConvertPositionsToMoveTo(), Path::DoSimplify(), Path::Fill(), in_svg_plane(), Path::IsNulCurve(), Inkscape::UI::Dialog::ActionAlign::on_button_click(), pen_handle_motion_notify(), pencil_handle_motion_notify(), sp_draw_anchor_test(), Path::Stroke(), Path::SubContractOutline(), and NrTypesTest::testL1L2LInftyNorms().
Referenced by Inkscape::Filters::_effect_subsample_step_log2(), Inkscape::XML::LogBuilder::detach(), Inkscape::UI::Widget::display_to_value(), finish_incomplete_transaction(), gm_writepgm(), Inkscape::UI::Widget::ZoomStatus::init(), SPDesktopWidget::init(), log4(), NormalDistribution(), Inkscape::XML::SimpleDocument::rollback(), sp_desktop_widget_update_zoom(), sp_document_maybe_done(), sp_document_redo(), sp_document_undo(), sp_dtw_zoom_display_to_value(), sp_dyna_draw_brush(), sp_eraser_brush(), and Inkscape::UI::Widget::ZoomStatus::update().
Definition at line 306 of file recursive-bezier-intersection.cpp.
References log().
Referenced by wangs_theorem().
| bool Geom::logical_xor | ( | bool | a, | |
| bool | b | |||
| ) | [inline] |
Definition at line 42 of file utils.h.
Referenced by Geom::Region::includes(), Geom::Shape::inside_invariants(), Geom::SVGEllipticalArc::roots(), and Geom::EllipticalArc::roots().
| Line Geom::make_angle_bisector_line | ( | Line const & | l1, | |
| Line const & | l2 | |||
| ) |
Definition at line 337 of file line.cpp.
References Geom::detail::bezier_clipping::angle(), angle_between(), addnodes::e, intersection(), Geom::Line::pointAt(), THROW_RANGEERROR, and Geom::Line::versor().
{
OptCrossing crossing;
try
{
crossing = intersection(l1, l2);
}
catch(InfiniteSolutions e)
{
return l1;
}
if (!crossing)
{
THROW_RANGEERROR("passed lines are parallel");
}
Point O = l1.pointAt(crossing->ta);
Point A = l1.pointAt(crossing->ta + 1);
double angle = angle_between(l1.versor(), l2.versor());
Point B = (angle > 0) ? l2.pointAt(crossing->tb + 1)
: l2.pointAt(crossing->tb - 1);
return make_angle_bisector_line(A, O, B);
}
Definition at line 353 of file line.h.
References M, and middle_point().
{
Point M = middle_point(A,B);
return Line(O,M);
}
| Ray Geom::make_angle_bisector_ray | ( | Ray const & | r1, | |
| Ray const & | r2 | |||
| ) | [inline] |
Definition at line 230 of file ray.h.
References angle_between(), are_near(), M, middle_point(), Geom::Ray::origin(), Geom::Ray::pointAt(), and THROW_RANGEERROR.
{
if ( !are_near(r1.origin(), r2.origin()) )
{
THROW_RANGEERROR("passed rays have not the same origin");
}
Point M = middle_point(r1.pointAt(1), r2.pointAt(1) );
if (angle_between(r1, r2) > M_PI) M = 2 * r1.origin() - M;
return Ray(r1.origin(), M);
}
| Line Geom::make_bisector_line | ( | LineSegment const & | _segment | ) | [inline] |
Definition at line 346 of file line.h.
References make_orthogonal_line(), and middle_point().
{
return make_orthogonal_line( middle_point(_segment), Line(_segment) );
}
Definition at line 41 of file d2-sbasis.cpp.
References org::w3c::dom::svg::a, NR::d, and Barcode::Code39Ext::i.
Referenced by Inkscape::LivePathEffect::bend(), Inkscape::LivePathEffect::LPECurveStitch::doEffect_path(), Inkscape::LivePathEffect::LPERecursiveSkeleton::doEffect_pwd2(), Inkscape::LivePathEffect::LPEPerspectivePath::doEffect_pwd2(), Inkscape::LivePathEffect::LPEPatternAlongPath::doEffect_pwd2(), Inkscape::LivePathEffect::LPEEnvelope::doEffect_pwd2(), Inkscape::LivePathEffect::LPEDynastroke::doEffect_pwd2(), Inkscape::LivePathEffect::LPEBendPath::doEffect_pwd2(), Inkscape::LivePathEffect::LPERoughHatches::linearSnake(), and Inkscape::LivePathEffect::LPECurveStitch::resetDefaults().
Definition at line 327 of file line.h.
References Geom::Point::cw(), Geom::Line::origin(), and Geom::Line::versor().
Referenced by make_bisector_line().
{
Line l;
l.origin(_point);
l.versor(_line.versor().cw());
return l;
}
Definition at line 337 of file line.h.
References Geom::Line::origin().
{
Line l(_line);
l.origin(_point);
return l;
}
| double Geom::map_circular_arc_on_unit_interval | ( | double | angle, | |
| double | start_angle, | |||
| double | end_angle, | |||
| bool | cw = true | |||
| ) | [inline] |
Definition at line 54 of file angle.h.
Referenced by Geom::SVGEllipticalArc::map_to_01(), and Geom::EllipticalArc::map_to_01().
| Coord Geom::map_unit_interval_on_circular_arc | ( | Coord | t, | |
| double | start_angle, | |||
| double | end_angle, | |||
| bool | cw = true | |||
| ) | [inline] |
Definition at line 71 of file angle.h.
References Geom::detail::bezier_clipping::angle(), and M_PI.
Referenced by Geom::SVGEllipticalArc::pointAndDerivatives(), and Geom::EllipticalArc::pointAndDerivatives().
{
double sweep_angle = end_angle - start_angle;
if ( !cw ) sweep_angle = -sweep_angle;
sweep_angle = std::fmod(sweep_angle, 2*M_PI);
if ( sweep_angle < 0 ) sweep_angle += 2*M_PI;
Coord angle = start_angle;
if ( cw )
{
angle += sweep_angle * t;
}
else
{
angle -= sweep_angle * t;
}
angle = std::fmod(angle, 2*M_PI);
if (angle < 0) angle += 2*M_PI;
return angle;
}
| bool Geom::matrix_equalp | ( | Geom::Matrix const & | m0, | |
| Geom::Matrix const & | m1, | |||
| Geom::Coord const | epsilon | |||
| ) |
Return the greater of the two functions pointwise.
- Parameters:
-
f,g two functions
Referenced by Geom::SVGEllipticalArc::allNearestPoints(), Geom::EllipticalArc::allNearestPoints(), control_poly_flat_enough(), Geom::Bernsteins::control_poly_flat_enough(), Geom::D2< Interval >::corner(), Geom::detail::bezier_clipping::distance_control_points(), Geom::QuadTree::insert(), intersect(), Lmax(), Geom::D2< Interval >::maxExtent(), operator+(), Geom::Poly::operator+(), operator-(), Geom::Poly::operator-(), Geom::Poly::operator-=(), portion(), sbasis_size(), Geom::QuadTree::search(), tail_error(), Geom::SBasis::tailError(), unitVector(), and wangs_theorem().
Return the greater of the two functions pointwise.
- Parameters:
-
f,g two functions
Return the greater of the two functions pointwise.
- Parameters:
-
f,g two functions
Return the greater of the two functions pointwise.
- Parameters:
-
f,g two functions
| ConvexHull Geom::merge | ( | ConvexHull | a, | |
| ConvexHull | b | |||
| ) |
Referenced by Geom::Crosser< Path >::crossings().
| void Geom::merge_crossings | ( | Crossings & | a, | |
| Crossings & | b, | |||
| unsigned | i | |||
| ) |
Referenced by Geom::MonoCrosser::crossings().
| Point Geom::middle_point | ( | LineSegment const & | _segment | ) | [inline] |
Definition at line 213 of file bezier-curve.h.
References Geom::BezierCurve< order >::finalPoint(), and Geom::BezierCurve< order >::initialPoint().
Referenced by Geom::SVGEllipticalArc::calculate_center_and_extreme_angles(), Inkscape::UI::MultiPathManipulator::joinNodes(), make_angle_bisector_line(), make_angle_bisector_ray(), make_bisector_line(), Inkscape::UI::TransformHandleSet::setBounds(), sp_shape_snappoints(), Inkscape::UI::SkewHandle::startTransform(), Inkscape::UI::ScaleSideHandle::startTransform(), and Inkscape::UI::PathManipulator::weldNodes().
{
return ( _segment.initialPoint() + _segment.finalPoint() ) / 2;
}
Definition at line 193 of file 2geom/point.h.
{
return (P1 + P2) / 2;
}
Return the more negative of the two functions pointwise.
- Parameters:
-
f,g two functions
Return the more negative of the two functions pointwise.
- Parameters:
-
f,g two functions
Referenced by control_poly_flat_enough(), Geom::Bernsteins::control_poly_flat_enough(), Geom::D2< Interval >::corner(), Geom::detail::bezier_clipping::distance_control_points(), Geom::QuadTree::insert(), Geom::make_elliptical_arc::make_elliptiarc(), Geom::D2< Interval >::minExtent(), Geom::Poly::operator+(), Geom::Poly::operator-(), Geom::Poly::operator-=(), Geom::SVGEllipticalArc::pointAndDerivatives(), Geom::EllipticalArc::pointAndDerivatives(), portion(), Geom::QuadTree::search(), truncate(), and Geom::Poly::val_and_deriv().
Return the more negative of the two functions pointwise.
- Parameters:
-
f,g two functions
Return the more negative of the two functions pointwise.
- Parameters:
-
f,g two functions
| int Geom::mod | ( | int | i, | |
| int | l | |||
| ) |
Definition at line 172 of file convex-cover.cpp.
| void Geom::mono_intersect | ( | Curve const & | A, | |
| double | Al, | |||
| double | Ah, | |||
| Curve const & | B, | |||
| double | Bl, | |||
| double | Bh, | |||
| Crossings & | ret, | |||
| double | tol = 0.1, |
|||
| unsigned | depth = 0 | |||
| ) |
Definition at line 374 of file path-intersection.cpp.
References B0, B1, intersect_polish_root(), Geom::D2< Interval >::intersects(), linear_intersect(), Geom::D2< Interval >::maxExtent(), mid, Geom::Curve::pointAt(), and tol.
{
if( Al >= Ah || Bl >= Bh) return;
//std::cout << " " << depth << "[" << Al << ", " << Ah << "]" << "[" << Bl << ", " << Bh << "]";
Point A0 = A.pointAt(Al), A1 = A.pointAt(Ah),
B0 = B.pointAt(Bl), B1 = B.pointAt(Bh);
//inline code that this implies? (without rect/interval construction)
Rect Ar = Rect(A0, A1), Br = Rect(B0, B1);
if(!Ar.intersects(Br) || A0 == A1 || B0 == B1) return;
if(depth > 12 || (Ar.maxExtent() < tol && Ar.maxExtent() < tol)) {
double tA, tB, c;
if(linear_intersect(A.pointAt(Al), A.pointAt(Ah),
B.pointAt(Bl), B.pointAt(Bh),
tA, tB, c)) {
tA = tA * (Ah - Al) + Al;
tB = tB * (Bh - Bl) + Bl;
intersect_polish_root(A, tA,
B, tB);
if(depth % 2)
ret.push_back(Crossing(tB, tA, c < 0));
else
ret.push_back(Crossing(tA, tB, c > 0));
return;
}
}
if(depth > 12) return;
double mid = (Bl + Bh)/2;
mono_intersect(B, Bl, mid,
A, Al, Ah,
ret, tol, depth+1);
mono_intersect(B, mid, Bh,
A, Al, Ah,
ret, tol, depth+1);
}
| Crossings Geom::mono_intersect | ( | Curve const & | A, | |
| Interval const & | Ad, | |||
| Curve const & | B, | |||
| Interval const & | Bd | |||
| ) |
| void Geom::mono_pair | ( | Path const & | A, | |
| double | Al, | |||
| double | Ah, | |||
| Path const & | B, | |||
| double | Bl, | |||
| double | Bh, | |||
| Crossings & | ret, | |||
| double | , | |||
| unsigned | depth = 0 | |||
| ) |
Takes two paths and time ranges on them, with the invariant that the paths are monotonic on the range.
Splits A when the linear intersection doesn't exist or is inaccurate. Uses the fact that it is monotonic to do very fast local bounds.
Definition at line 425 of file path-intersection.cpp.
References B0, B1, Geom::D2< Interval >::intersects(), linear_intersect(), Geom::D2< Interval >::maxExtent(), mid, and Geom::Path::pointAt().
Referenced by Geom::MonoCrosser::crossings().
{
if( Al >= Ah || Bl >= Bh) return;
std::cout << " " << depth << "[" << Al << ", " << Ah << "]" << "[" << Bl << ", " << Bh << "]";
Point A0 = A.pointAt(Al), A1 = A.pointAt(Ah),
B0 = B.pointAt(Bl), B1 = B.pointAt(Bh);
//inline code that this implies? (without rect/interval construction)
Rect Ar = Rect(A0, A1), Br = Rect(B0, B1);
if(!Ar.intersects(Br) || A0 == A1 || B0 == B1) return;
if(depth > 12 || (Ar.maxExtent() < 0.1 && Ar.maxExtent() < 0.1)) {
double tA, tB, c;
if(linear_intersect(A0, A1, B0, B1,
tA, tB, c)) {
tA = tA * (Ah - Al) + Al;
tB = tB * (Bh - Bl) + Bl;
if(depth % 2)
ret.push_back(Crossing(tB, tA, c < 0));
else
ret.push_back(Crossing(tA, tB, c > 0));
return;
}
}
if(depth > 12) return;
double mid = (Bl + Bh)/2;
mono_pair(B, Bl, mid,
A, Al, Ah,
ret, depth+1);
mono_pair(B, mid, Bh,
A, Al, Ah,
ret, depth+1);
}
| std::vector< std::vector< double > > Geom::multi_roots | ( | Piecewise< SBasis > const & | f, | |
| std::vector< double > const & | values | |||
| ) |
| std::vector< std::vector< double > > Geom::multi_roots | ( | SBasis const & | f, | |
| std::vector< double > const & | levels, | |||
| double | htol, | |||
| double | vtol, | |||
| double | a, | |||
| double | b | |||
| ) |
Solve f(t)=c for several c at once.
- Parameters:
-
f sbasis function levels vector of 'y' values htol,vtol a,b left and right bounds
- Returns:
- a vector of vectors, one for each y giving roots
Effectively computes: results = roots(f(y_i)) for all y_i
algo: -compute f at both ends of the given segment [a,b]. -compute bounds m<df(t)<M for df on the segment. let c and C be the levels below and above f(a): going from f(a) down to c with slope m takes at least time (f(a)-c)/m going from f(a) up to C with slope M takes at least time (C-f(a))/M From this we conclude there are no roots before a'=a+min((f(a)-c)/m,(C-f(a))/M). Do the same for b: compute some b' such that there are no roots in (b',b]. -if [a',b'] is not empty, repeat the process with [a',(a'+b')/2] and [(a'+b')/2,b']. unfortunately, extra care is needed about rounding errors, and also to avoid the repetition of roots, making things tricky and unpleasant...
TODO: Make sure the code is "rounding-errors proof" and take care about repetition of roots!
| static void Geom::multi_roots_internal | ( | SBasis const & | f, | |
| SBasis const & | df, | |||
| std::vector< double > const & | levels, | |||
| std::vector< std::vector< double > > & | roots, | |||
| double | htol, | |||
| double | vtol, | |||
| double | a, | |||
| double | fa, | |||
| double | b, | |||
| double | fb | |||
| ) | [static] |
Definition at line 182 of file sbasis-roots.cpp.
References bounds_local(), c, org::w3c::dom::svg::f, max, Geom::Interval::max(), Geom::Interval::min(), min, roots(), Geom::SBasis::size(), and upper_level().
{
if (f.size()==0){
int idx;
idx=upper_level(levels,0,vtol);
if (idx<(int)levels.size()&&fabs(levels.at(idx))<=vtol){
roots[idx].push_back(a);
roots[idx].push_back(b);
}
return;
}
// if (f.size()==1){
// int idxa=upper_level(levels,fa);
// int idxb=upper_level(levels,fb);
// if (fa==fb){
// if (fa==levels[idxa]){
// roots[a]=idxa;
// roots[b]=idxa;
// }
// return;
// }
// int idx_min=std::min(idxa,idxb);
// int idx_max=std::max(idxa,idxb);
// if (idx_max==levels.size()) idx_max-=1;
// for(int i=idx_min;i<=idx_max; i++){
// double t=a+(b-a)*(levels[i]-fa)/(fb-fa);
// if(a<t&&t<b) roots[t]=i;
// }
// return;
// }
if ((b-a)<htol){
//TODO: use different tol for t and f ?
//TODO: unsigned idx ? (remove int casts when fixed)
int idx=std::min(upper_level(levels,fa,vtol),upper_level(levels,fb,vtol));
if (idx==(int)levels.size()) idx-=1;
double c=levels.at(idx);
if((fa-c)*(fb-c)<=0||fabs(fa-c)<vtol||fabs(fb-c)<vtol){
roots[idx].push_back((a+b)/2);
}
return;
}
int idxa=upper_level(levels,fa,vtol);
int idxb=upper_level(levels,fb,vtol);
Interval bs = *bounds_local(df,Interval(a,b));
//first times when a level (higher or lower) can be reached from a or b.
double ta_hi,tb_hi,ta_lo,tb_lo;
ta_hi=ta_lo=b+1;//default values => no root there.
tb_hi=tb_lo=a-1;//default values => no root there.
if (idxa<(int)levels.size() && fabs(fa-levels.at(idxa))<vtol){//a can be considered a root.
//ta_hi=ta_lo=a;
roots[idxa].push_back(a);
ta_hi=ta_lo=a+htol;
}else{
if (bs.max()>0 && idxa<(int)levels.size())
ta_hi=a+(levels.at(idxa )-fa)/bs.max();
if (bs.min()<0 && idxa>0)
ta_lo=a+(levels.at(idxa-1)-fa)/bs.min();
}
if (idxb<(int)levels.size() && fabs(fb-levels.at(idxb))<vtol){//b can be considered a root.
//tb_hi=tb_lo=b;
roots[idxb].push_back(b);
tb_hi=tb_lo=b-htol;
}else{
if (bs.min()<0 && idxb<(int)levels.size())
tb_hi=b+(levels.at(idxb )-fb)/bs.min();
if (bs.max()>0 && idxb>0)
tb_lo=b+(levels.at(idxb-1)-fb)/bs.max();
}
double t0,t1;
t0=std::min(ta_hi,ta_lo);
t1=std::max(tb_hi,tb_lo);
//hum, rounding errors frighten me! so I add this +tol...
if (t0>t1+htol) return;//no root here.
if (fabs(t1-t0)<htol){
multi_roots_internal(f,df,levels,roots,htol,vtol,t0,f(t0),t1,f(t1));
}else{
double t,t_left,t_right,ft,ft_left,ft_right;
t_left =t_right =t =(t0+t1)/2;
ft_left=ft_right=ft=f(t);
int idx=upper_level(levels,ft,vtol);
if (idx<(int)levels.size() && fabs(ft-levels.at(idx))<vtol){//t can be considered a root.
roots[idx].push_back(t);
//we do not want to count it twice (from the left and from the right)
t_left =t-htol/2;
t_right=t+htol/2;
ft_left =f(t_left);
ft_right=f(t_right);
}
multi_roots_internal(f,df,levels,roots,htol,vtol,t0 ,f(t0) ,t_left,ft_left);
multi_roots_internal(f,df,levels,roots,htol,vtol,t_right,ft_right,t1 ,f(t1) );
}
}
| SBasis Geom::multiply | ( | SBasis const & | a, | |
| SBasis const & | b | |||
| ) |
Compute the pointwise product of a and b (Exact).
- Parameters:
-
a,b sbasis functions
- Returns:
- sbasis equal to a*b
Definition at line 10 of file d2-sbasis.cpp.
Referenced by centroid(), multiply(), operator*(), operator*=(), and sqrt_internal().
| SBasis2d Geom::multiply | ( | SBasis2d const & | a, | |
| SBasis2d const & | b | |||
| ) |
| SBasis Geom::multiply_add | ( | SBasis const & | a, | |
| SBasis const & | b, | |||
| SBasis | c | |||
| ) |
Compute the pointwise product of a and b adding c (Exact).
- Parameters:
-
a,b,c sbasis functions
- Returns:
- sbasis equal to a*b+c
The added term is almost free
| double Geom::nearest_point | ( | Point const & | p, | |
| D2< SBasis > const & | c, | |||
| double | from = 0, |
|||
| double | to = 1 | |||
| ) | [inline] |
Definition at line 76 of file nearest-point.h.
References derivative(), and nearest_point().
{
return nearest_point(p, c, Geom::derivative(c), from, to);
}
Definition at line 154 of file 2geom/curve.h.
References Geom::Curve::nearestPoint().
Referenced by Inkscape::UI::PathManipulator::_updateDragPoint(), Inkscape::LivePathEffect::PB::KnotHolderEntityEnd::bisector_end_set(), Inkscape::LivePathEffect::LPEOffset::doEffect_pwd2(), Inkscape::LivePathEffect::TtC::KnotHolderEntityRightEnd::knot_set(), Inkscape::LivePathEffect::TtC::KnotHolderEntityLeftEnd::knot_set(), Inkscape::LivePathEffect::TtC::KnotHolderEntityAttachPt::knot_set(), Inkscape::LivePathEffect::AB::KnotHolderEntityRightEnd::knot_set(), Inkscape::LivePathEffect::AB::KnotHolderEntityLeftEnd::knot_set(), nearest_point(), Geom::SBasisCurve::nearestPoint(), and Geom::Curve::nearestPoint().
| double Geom::nearest_point | ( | Point const & | p, | |
| D2< SBasis > const & | c, | |||
| D2< SBasis > const & | dc, | |||
| double | from, | |||
| double | to | |||
| ) |
| double Geom::nearest_point | ( | Point const & | p, | |
| Piecewise< D2< SBasis > > const & | c, | |||
| double | from, | |||
| double | to | |||
| ) |
Definition at line 111 of file nearest-point.h.
References c, and nearest_point().
Definition at line 689 of file 2geom/path.h.
References Geom::Path::nearestPoint().
| boost::optional< PathVectorPosition > Geom::nearestPoint | ( | PathVector const & | path_in, | |
| Point const & | _point, | |||
| double * | distance_squared | |||
| ) |
Referenced by Inkscape::UI::PathManipulator::_updateDragPoint().
| static double Geom::NewtonRaphsonRootFind | ( | BezierCurve const | Q, | |
| Point const & | P, | |||
| double const | u | |||
| ) | [static] |
Use Newton-Raphson iteration to find better root.
- Parameters:
-
Q Current fitted curve P Digitized point u Parameter value for "P"
- Returns:
- Improved u
Definition at line 575 of file bezier-utils.cpp.
References bezier_pt(), dot(), DOUBLE_ASSERT, Barcode::Code39Ext::i, IS_FINITE, and lensq().
Referenced by reparameterize().
{
assert( 0.0 <= u );
assert( u <= 1.0 );
/* Generate control vertices for Q'. */
Point Q1[3];
for (unsigned i = 0; i < 3; i++) {
Q1[i] = 3.0 * ( Q[i+1] - Q[i] );
}
/* Generate control vertices for Q''. */
Point Q2[2];
for (unsigned i = 0; i < 2; i++) {
Q2[i] = 2.0 * ( Q1[i+1] - Q1[i] );
}
/* Compute Q(u), Q'(u) and Q''(u). */
Point const Q_u = bezier_pt(3, Q, u);
Point const Q1_u = bezier_pt(2, Q1, u);
Point const Q2_u = bezier_pt(1, Q2, u);
/* Compute f(u)/f'(u), where f is the derivative wrt u of distsq(u) = 0.5 * the square of the
distance from P to Q(u). Here we're using Newton-Raphson to find a stationary point in the
distsq(u), hopefully corresponding to a local minimum in distsq (and hence a local minimum
distance from P to Q(u)). */
Point const diff = Q_u - P;
double numerator = dot(diff, Q1_u);
double denominator = dot(Q1_u, Q1_u) + dot(diff, Q2_u);
double improved_u;
if ( denominator > 0. ) {
/* One iteration of Newton-Raphson:
improved_u = u - f(u)/f'(u) */
improved_u = u - ( numerator / denominator );
} else {
/* Using Newton-Raphson would move in the wrong direction (towards a local maximum rather
than local minimum), so we move an arbitrary amount in the right direction. */
if ( numerator > 0. ) {
improved_u = u * .98 - .01;
} else if ( numerator < 0. ) {
/* Deliberately asymmetrical, to reduce the chance of cycling. */
improved_u = .031 + u * .98;
} else {
improved_u = u;
}
}
if (!IS_FINITE(improved_u)) {
improved_u = u;
} else if ( improved_u < 0.0 ) {
improved_u = 0.0;
} else if ( improved_u > 1.0 ) {
improved_u = 1.0;
}
/* Ensure that improved_u isn't actually worse. */
{
double const diff_lensq = lensq(diff);
for (double proportion = .125; ; proportion += .125) {
if ( lensq( bezier_pt(3, Q, improved_u) - P ) > diff_lensq ) {
if ( proportion > 1.0 ) {
//g_warning("found proportion %g", proportion);
improved_u = u;
break;
}
improved_u = ( ( 1 - proportion ) * improved_u +
proportion * u );
} else {
break;
}
}
}
DOUBLE_ASSERT(improved_u);
return improved_u;
}
Referenced by curve_sweep().
| std::vector<double> Geom::offset_doubles | ( | std::vector< double > const & | x, | |
| double | offs | |||
| ) |
Convenience function to add a value to each entry in a vector of doubles.
Definition at line 471 of file path-intersection.cpp.
References Barcode::Code39Ext::i.
| bool Geom::operator!= | ( | Linear2d const & | a, | |
| Linear2d const & | b | |||
| ) | [inline] |
Definition at line 140 of file sbasis-2d.h.
References Barcode::Code39Ext::i.
| bool Geom::operator!= | ( | Linear const & | a, | |
| Linear const & | b | |||
| ) | [inline] |
| bool Geom::operator!= | ( | Matrix const & | a, | |
| Matrix const & | b | |||
| ) | [inline] |
| bool Geom::operator!= | ( | D2< T > const & | a, | |
| D2< T > const & | b | |||
| ) | [inline] |
| PathVector Geom::operator* | ( | PathVector const & | path_in, | |
| Translate const & | m | |||
| ) | [inline] |
Definition at line 70 of file pathvector.h.
{
PathVector ret(path_in);
ret *= m;
return ret;
}
| Matrix Geom::operator* | ( | Translate const & | t, | |
| Scale const & | s | |||
| ) |
| Matrix Geom::operator* | ( | Translate const & | t, | |
| Rotate const & | r | |||
| ) |
| Matrix Geom::operator* | ( | Scale const & | s, | |
| Translate const & | t | |||
| ) |
| Matrix Geom::operator* | ( | Matrix const & | m, | |
| Translate const & | t | |||
| ) |
| Matrix Geom::operator* | ( | Matrix const & | m, | |
| Rotate const & | r | |||
| ) |
Definition at line 526 of file piecewise.h.
References Geom::Piecewise< T >::cuts, Geom::Piecewise< T >::empty(), Barcode::Code39Ext::i, Geom::Piecewise< T >::push_seg(), Geom::Piecewise< T >::segs, and Geom::Piecewise< T >::size().
| Piecewise<T> Geom::operator* | ( | Piecewise< T > const & | a, | |
| T | b | |||
| ) |
Definition at line 539 of file piecewise.h.
References Geom::Piecewise< T >::cuts, Geom::Piecewise< T >::empty(), Barcode::Code39Ext::i, Geom::Piecewise< T >::push_seg(), Geom::Piecewise< T >::segs, and Geom::Piecewise< T >::size().
| Piecewise<T2> Geom::operator* | ( | Piecewise< T1 > const & | a, | |
| Piecewise< T2 > const & | b | |||
| ) |
Definition at line 623 of file piecewise.h.
References Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, partition(), Geom::Piecewise< T >::push_seg(), Geom::Piecewise< T >::segs, and Geom::Piecewise< T >::size().
{
//function_requires<MultiplicableConcept<T1> >();
//function_requires<MultiplicableConcept<T2> >();
Piecewise<T1> pa = partition(a, b.cuts);
Piecewise<T2> pb = partition(b, a.cuts);
Piecewise<T2> ret = Piecewise<T2>();
assert(pa.size() == pb.size());
ret.segs.reserve(pa.size());
ret.cuts = pa.cuts;
for (unsigned i = 0; i < pa.size(); i++)
ret.push_seg(pa[i] * pb[i]);
return ret;
}
| ConvexHull Geom::operator* | ( | ConvexHull const & | p, | |
| T const & | m | |||
| ) |
Definition at line 154 of file convex-cover.h.
References Geom::ConvexHull::boundary, and Barcode::Code39Ext::i.
Definition at line 141 of file 2geom/point.h.
{ return p * s; }
| Interval Geom::operator* | ( | const Interval & | a, | |
| const Interval & | b | |||
| ) | [inline] |
Definition at line 202 of file interval.h.
References Geom::Interval::max(), and Geom::Interval::min().
| Matrix Geom::operator* | ( | Scale const & | s, | |
| Matrix const & | m | |||
| ) |
| Matrix Geom::operator* | ( | Matrix const & | m, | |
| Scale const & | s | |||
| ) |
| SBasis2d Geom::operator* | ( | SBasis2d const & | a, | |
| SBasis2d const & | b | |||
| ) |
Definition at line 124 of file d2-sbasis.cpp.
References org::w3c::dom::svg::a, Barcode::Code39Ext::i, Geom::Piecewise< T >::push(), Geom::Piecewise< T >::push_cut(), and org::w3c::dom::svg::result.
| Matrix Geom::operator* | ( | Matrix const & | m0, | |
| Matrix const & | m1 | |||
| ) |
Compute the pointwise product of a and b (Exact).
- Parameters:
-
a,b sbasis functions
- Returns:
- sbasis equal to a*b
| D2<T> Geom::operator* | ( | D2< T > const & | v, | |
| Matrix const & | m | |||
| ) |
| D2<T> Geom::operator* | ( | D2< T > const & | a, | |
| T const & | b | |||
| ) | [inline] |
| PathVector Geom::operator* | ( | PathVector const & | path_in, | |
| Matrix const & | m | |||
| ) | [inline] |
Definition at line 55 of file pathvector.h.
{
PathVector ret(path_in);
ret *= m;
return ret;
}
| SBasis Geom::operator* | ( | SBasis const & | a, | |
| SBasis const & | b | |||
| ) | [inline] |
| void Geom::operator*= | ( | PathVector & | path_in, | |
| Translate const & | m | |||
| ) | [inline] |
Definition at line 64 of file pathvector.h.
{
for(PathVector::iterator it = path_in.begin(); it != path_in.end(); ++it) {
(*it) *= m;
}
}
| Piecewise<T>& Geom::operator*= | ( | Piecewise< T > & | a, | |
| Piecewise< T > const & | b | |||
| ) | [inline] |
| Interval Geom::operator*= | ( | Interval & | a, | |
| const Interval & | b | |||
| ) | [inline] |
Definition at line 128 of file sbasis-2d.h.
References Barcode::Code39Ext::i.
| Matrix& Geom::operator*= | ( | Matrix & | a, | |
| Matrix const & | b | |||
| ) | [inline] |
| SBasis& Geom::operator*= | ( | SBasis & | a, | |
| SBasis const & | b | |||
| ) | [inline] |
Definition at line 566 of file piecewise.h.
References Barcode::Code39Ext::i, and Geom::Piecewise< T >::size().
Compute the pointwise product of a and b and store the value in a (Exact).
- Parameters:
-
a,b sbasis functions
- Returns:
- sbasis equal to a*b
| void Geom::operator*= | ( | PathVector & | path_in, | |
| Matrix const & | m | |||
| ) | [inline] |
Definition at line 49 of file pathvector.h.
{
for(PathVector::iterator it = path_in.begin(); it != path_in.end(); ++it) {
(*it) *= m;
}
}
| PathVector Geom::operator+ | ( | PathVector const & | path_in, | |
| Point const & | p | |||
| ) | [inline] |
Definition at line 84 of file pathvector.h.
{
PathVector ret(path_in);
ret *= Translate(p);
return ret;
}
| Piecewise<T> Geom::operator+ | ( | Piecewise< T > const & | a, | |
| Piecewise< T > const & | b | |||
| ) |
Definition at line 586 of file piecewise.h.
References Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, partition(), Geom::Piecewise< T >::push_seg(), and Geom::Piecewise< T >::segs.
| Piecewise<T> Geom::operator+ | ( | Piecewise< T > const & | a, | |
| typename T::output_type | b | |||
| ) |
Definition at line 471 of file piecewise.h.
References Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, and Geom::Piecewise< T >::size().
| Interval Geom::operator+ | ( | const Interval & | a, | |
| const Interval & | b | |||
| ) | [inline] |
Definition at line 192 of file interval.h.
References Geom::Interval::max(), and Geom::Interval::min().
| Linear2d Geom::operator+ | ( | Linear2d const & | a, | |
| Linear2d const & | b | |||
| ) | [inline] |
| Linear Geom::operator+ | ( | Linear const & | a, | |
| Linear const & | b | |||
| ) | [inline] |
| SBasis2d Geom::operator+ | ( | const SBasis2d & | a, | |
| const SBasis2d & | b | |||
| ) | [inline] |
Definition at line 215 of file sbasis-2d.h.
References Geom::SBasis2d::index(), max(), org::w3c::dom::svg::result, Geom::SBasis2d::us, and Geom::SBasis2d::vs.
{
SBasis2d result;
result.us = std::max(a.us, b.us);
result.vs = std::max(a.vs, b.vs);
const unsigned out_size = result.us*result.vs;
result.resize(out_size);
for(unsigned vi = 0; vi < result.vs; vi++) {
for(unsigned ui = 0; ui < result.us; ui++) {
Linear2d bo;
if(ui < a.us && vi < a.vs)
bo += a.index(ui, vi);
if(ui < b.us && vi < b.vs)
bo += b.index(ui, vi);
result.index(ui, vi) = bo;
}
}
return result;
}
| D2<T> Geom::operator+ | ( | D2< T > const & | a, | |
| D2< T > const & | b | |||
| ) | [inline] |
| SBasis Geom::operator+ | ( | const SBasis & | a, | |
| const SBasis & | b | |||
| ) |
Compute the pointwise sum of a and b (Exact).
- Parameters:
-
a,b sbasis functions
- Returns:
- sbasis equal to a+b
| void Geom::operator+= | ( | PathVector & | path_in, | |
| Point const & | p | |||
| ) | [inline] |
Definition at line 78 of file pathvector.h.
{
for(PathVector::iterator it = path_in.begin(); it != path_in.end(); ++it) {
(*it) *= Translate(p);
}
}
| Piecewise<T>& Geom::operator+= | ( | Piecewise< T > & | a, | |
| Piecewise< T > const & | b | |||
| ) | [inline] |
| Interval Geom::operator+= | ( | Interval & | a, | |
| const Interval & | b | |||
| ) | [inline] |
| Linear2d& Geom::operator+= | ( | Linear2d & | a, | |
| Linear2d const & | b | |||
| ) | [inline] |
| Linear& Geom::operator+= | ( | Linear & | a, | |
| Linear const & | b | |||
| ) | [inline] |
| SBasis2d& Geom::operator+= | ( | SBasis2d & | a, | |
| const Linear2d & | b | |||
| ) | [inline] |
| Piecewise<T>& Geom::operator+= | ( | Piecewise< T > & | a, | |
| typename T::output_type | b | |||
| ) |
Definition at line 493 of file piecewise.h.
References Geom::Piecewise< T >::empty(), Barcode::Code39Ext::i, Geom::Piecewise< T >::push(), Geom::Piecewise< T >::push_cut(), and Geom::Piecewise< T >::size().
| D2<T> Geom::operator+= | ( | D2< T > & | a, | |
| D2< T > const & | b | |||
| ) | [inline] |
| SBasis & Geom::operator+= | ( | SBasis & | a, | |
| const SBasis & | b | |||
| ) |
Compute the pointwise sum of a and b and store in a (Exact).
- Parameters:
-
a,b sbasis functions
- Returns:
- sbasis equal to a+b
| Piecewise<T> Geom::operator- | ( | Piecewise< T > const & | a | ) |
Definition at line 515 of file piecewise.h.
References Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, and Geom::Piecewise< T >::size().
| Linear Geom::operator- | ( | Linear const & | a | ) | [inline] |
| SBasis2d Geom::operator- | ( | const SBasis2d & | a, | |
| const SBasis2d & | b | |||
| ) | [inline] |
Definition at line 235 of file sbasis-2d.h.
References Geom::SBasis2d::index(), max(), org::w3c::dom::svg::result, Geom::SBasis2d::us, and Geom::SBasis2d::vs.
{
SBasis2d result;
result.us = std::max(a.us, b.us);
result.vs = std::max(a.vs, b.vs);
const unsigned out_size = result.us*result.vs;
result.resize(out_size);
for(unsigned vi = 0; vi < result.vs; vi++) {
for(unsigned ui = 0; ui < result.us; ui++) {
Linear2d bo;
if(ui < a.us && vi < a.vs)
bo += a.index(ui, vi);
if(ui < b.us && vi < b.vs)
bo -= b.index(ui, vi);
result.index(ui, vi) = bo;
}
}
return result;
}
| Interval Geom::operator- | ( | const Interval & | a, | |
| const Interval & | b | |||
| ) | [inline] |
Definition at line 195 of file interval.h.
References Geom::Interval::max(), and Geom::Interval::min().
| SBasis Geom::operator- | ( | const SBasis & | p | ) | [inline] |
| SBasis2d Geom::operator- | ( | const SBasis2d & | p | ) | [inline] |
Definition at line 205 of file sbasis-2d.h.
References Barcode::Code39Ext::i, and org::w3c::dom::svg::result.
| Piecewise<T> Geom::operator- | ( | Piecewise< T > const & | a, | |
| typename T::output_type | b | |||
| ) |
Definition at line 482 of file piecewise.h.
References Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, and Geom::Piecewise< T >::size().
| Linear2d Geom::operator- | ( | Linear2d const & | a | ) | [inline] |
Definition at line 102 of file sbasis-2d.h.
References Geom::Linear2d::a.
| Linear2d Geom::operator- | ( | Linear2d const & | a, | |
| Linear2d const & | b | |||
| ) | [inline] |
| Piecewise<T> Geom::operator- | ( | Piecewise< T > const & | a, | |
| Piecewise< T > const & | b | |||
| ) |
Definition at line 599 of file piecewise.h.
References Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, partition(), Geom::Piecewise< T >::push_seg(), and Geom::Piecewise< T >::segs.
{
boost::function_requires<AddableConcept<T> >();
Piecewise<T> pa = partition(a, b.cuts), pb = partition(b, a.cuts);
Piecewise<T> ret = Piecewise<T>();
assert(pa.size() == pb.size());
ret.segs.reserve(pa.size());
ret.cuts = pa.cuts;
for (unsigned i = 0; i < pa.size(); i++)
ret.push_seg(pa[i] - pb[i]);
return ret;
}
| D2<T> Geom::operator- | ( | D2< T > const & | a, | |
| D2< T > const & | b | |||
| ) | [inline] |
| D2<T> Geom::operator- | ( | D2< T > const & | a | ) | [inline] |
| SBasis Geom::operator- | ( | const SBasis & | a, | |
| const SBasis & | b | |||
| ) |
Compute the pointwise difference of a and b (Exact).
- Parameters:
-
a,b sbasis functions
- Returns:
- sbasis equal to a-b
| Linear Geom::operator- | ( | Linear const & | a, | |
| Linear const & | b | |||
| ) | [inline] |
| SBasis2d& Geom::operator-= | ( | SBasis2d & | a, | |
| const Linear2d & | b | |||
| ) | [inline] |
| Piecewise<T>& Geom::operator-= | ( | Piecewise< T > & | a, | |
| typename T::output_type | b | |||
| ) |
Definition at line 503 of file piecewise.h.
References Geom::Piecewise< T >::empty(), Barcode::Code39Ext::i, Geom::Piecewise< T >::push(), Geom::Piecewise< T >::push_cut(), and Geom::Piecewise< T >::size().
| Piecewise<T>& Geom::operator-= | ( | Piecewise< T > & | a, | |
| Piecewise< T > const & | b | |||
| ) | [inline] |
| Interval Geom::operator-= | ( | Interval & | a, | |
| const Interval & | b | |||
| ) | [inline] |
| Linear2d& Geom::operator-= | ( | Linear2d & | a, | |
| Linear2d const & | b | |||
| ) | [inline] |
| Linear& Geom::operator-= | ( | Linear & | a, | |
| Linear const & | b | |||
| ) | [inline] |
| D2<T> Geom::operator-= | ( | D2< T > & | a, | |
| D2< T > const & | b | |||
| ) | [inline] |
| SBasis & Geom::operator-= | ( | SBasis & | a, | |
| const SBasis & | b | |||
| ) |
Compute the pointwise difference of a and b and store in a (Exact).
- Parameters:
-
a,b sbasis functions
- Returns:
- sbasis equal to a-b
Definition at line 552 of file piecewise.h.
References Geom::Piecewise< T >::cuts, Geom::Piecewise< T >::empty(), Barcode::Code39Ext::i, Geom::Piecewise< T >::push_seg(), Geom::Piecewise< T >::segs, and Geom::Piecewise< T >::size().
Definition at line 574 of file piecewise.h.
References Barcode::Code39Ext::i, and Geom::Piecewise< T >::size().
| std::ostream& Geom::operator<< | ( | std::ostream & | out_file, | |
| const Linear & | bo | |||
| ) | [inline] |
| std::ostream& Geom::operator<< | ( | std::ostream & | out_file, | |
| const SBasis2d & | p | |||
| ) | [inline] |
Definition at line 346 of file sbasis-2d.h.
References Barcode::Code39Ext::i.
| std::ostream& Geom::operator<< | ( | std::ostream & | out_file, | |
| const Geom::D2< T > & | in_d2 | |||
| ) | [inline] |
| std::ostream& Geom::operator<< | ( | std::ostream & | out_file, | |
| const Bezier & | b | |||
| ) | [inline] |
Definition at line 401 of file bezier.h.
References Barcode::Code39Ext::i, and Geom::Bezier::size().
| std::ostream& Geom::operator<< | ( | std::ostream & | out_file, | |
| const SBasis & | p | |||
| ) | [inline] |
| std::ostream& Geom::operator<< | ( | std::ostream & | out_file, | |
| const Geom::Point & | in_pnt | |||
| ) | [inline] |
A function to print out the Point.
It just prints out the coords on the given output stream
Definition at line 145 of file 2geom/point.h.
{
out_file << "X: " << in_pnt[X] << " Y: " << in_pnt[Y];
return out_file;
}
| std::ostream& Geom::operator<< | ( | std::ostream & | out_file, | |
| const Linear2d & | bo | |||
| ) | [inline] |
Definition at line 340 of file sbasis-2d.h.
{
out_file << "{" << bo[0] << ", " << bo[1] << "}, ";
out_file << "{" << bo[2] << ", " << bo[3] << "}";
return out_file;
}
| std::ostream& Geom::operator<< | ( | std::ostream & | out_file, | |
| const Geom::Matrix & | m | |||
| ) | [inline] |
| std::ostream& Geom::operator<< | ( | std::ostream & | out_file, | |
| const Poly & | in_poly | |||
| ) | [inline] |
Definition at line 215 of file poly.h.
References Barcode::Code39Ext::i.
{
if(in_poly.size() == 0)
out_file << "0";
else {
for(int i = (int)in_poly.size()-1; i >= 0; --i) {
if(i == 1) {
out_file << "" << in_poly[i] << "*x";
out_file << " + ";
} else if(i) {
out_file << "" << in_poly[i] << "*x^" << i;
out_file << " + ";
} else
out_file << in_poly[i];
}
}
return out_file;
}
| std::basic_ostream<charT>& Geom::operator<< | ( | std::basic_ostream< charT > & | os, | |
| const SVGEllipticalArc & | ea | |||
| ) | [inline] |
Definition at line 378 of file svg-elliptical-arc.h.
References decimal_round(), rad_to_deg(), X, and Y.
{
os << "{ cx: " << ea.center(X) << ", cy: " << ea.center(Y)
<< ", rx: " << ea.ray(X) << ", ry: " << ea.ray(Y)
<< ", rot angle: " << decimal_round(rad_to_deg(ea.rotation_angle()),2)
<< ", start angle: " << decimal_round(rad_to_deg(ea.start_angle()),2)
<< ", end angle: " << decimal_round(rad_to_deg(ea.end_angle()),2)
<< " }";
return os;
}
| bool Geom::operator== | ( | D2< T > const & | a, | |
| D2< T > const & | b | |||
| ) | [inline] |
| bool Geom::operator== | ( | Matrix const & | a, | |
| Matrix const & | b | |||
| ) | [inline] |
| bool Geom::operator== | ( | Linear const & | a, | |
| Linear const & | b | |||
| ) | [inline] |
| bool Geom::operator== | ( | Linear2d const & | a, | |
| Linear2d const & | b | |||
| ) | [inline] |
Definition at line 134 of file sbasis-2d.h.
References Barcode::Code39Ext::i.
| void Geom::outer_crossing | ( | unsigned & | ix, | |
| unsigned & | jx, | |||
| bool & | dir, | |||
| std::vector< Path > const & | ps, | |||
| CrossingSet const & | crs | |||
| ) |
Definition at line 391 of file 2geom/shape.cpp.
References bounds(), crossing_along(), Geom::D2< Interval >::left(), dxf_input::val, X, and Y.
Referenced by inner_sanitize().
{
Rect bounds = *(ps[ix].boundsFast());
double ry = bounds[Y].middle();
double max_val = bounds.left(), max_t = 0;
ix = ps.size();
for(unsigned i = 0; i < ps.size(); i++) {
if(!crs[i].empty()) {
std::vector<double> rts = ps[i].roots(ry, Y);
for(unsigned j = 0; j < rts.size(); j++) {
double val = ps[i].valueAt(rts[j], X);
if(val > max_val) {
ix = i;
max_val = val;
max_t = rts[j];
}
}
}
}
if(ix != ps.size()) {
dir = ps[ix].valueAt(max_t + 0.01, Y) >
ps[ix].valueAt(max_t - 0.01, Y);
jx = crossing_along(max_t, ix, jx, dir, crs[ix]);
}
}
| unsigned Geom::outer_index | ( | Regions const & | ps | ) |
Referenced by Geom::Shape::update_fill().
| void Geom::output | ( | HLineSegment const & | curve, | |
| SVGPathSink & | sink | |||
| ) |
Definition at line 43 of file 2geom/svg-path.cpp.
References Geom::HLineSegment::finalPoint(), and Geom::SVGPathSink::hlineTo().
{
sink.hlineTo(curve.finalPoint()[X]);
}
| void Geom::output | ( | VLineSegment const & | curve, | |
| SVGPathSink & | sink | |||
| ) |
Definition at line 47 of file 2geom/svg-path.cpp.
References Geom::VLineSegment::finalPoint(), and Geom::SVGPathSink::vlineTo().
{
sink.vlineTo(curve.finalPoint()[Y]);
}
| void Geom::output | ( | SVGEllipticalArc const & | curve, | |
| SVGPathSink & | sink | |||
| ) |
Definition at line 63 of file 2geom/svg-path.cpp.
References Geom::SVGPathSink::arcTo(), Geom::SVGEllipticalArc::finalPoint(), Geom::SVGEllipticalArc::large_arc_flag(), Geom::SVGEllipticalArc::ray(), Geom::SVGEllipticalArc::rotation_angle(), Geom::SVGEllipticalArc::sweep_flag(), X, and Y.
| void Geom::output | ( | Curve const & | curve, | |
| SVGPathSink & | sink | |||
| ) |
Definition at line 37 of file 2geom/svg-path.cpp.
References Geom::SVGPathSink::curveTo(), voronoi::pts, sbasis_to_bezier(), and Geom::Curve::toSBasis().
Referenced by Inkscape::LivePathEffect::LPEAngleBisector::doEffect_path(), Inkscape::LivePathEffect::LPEdoEffectStackTest::doEffect_pwd2(), Inkscape::LivePathEffect::LPETangentToCurve::doEffect_pwd2(), Inkscape::LivePathEffect::LPESketch::doEffect_pwd2(), Inkscape::LivePathEffect::LPERuler::doEffect_pwd2(), Inkscape::LivePathEffect::LPERecursiveSkeleton::doEffect_pwd2(), Inkscape::LivePathEffect::LPEPerspectivePath::doEffect_pwd2(), Inkscape::LivePathEffect::LPEPerpBisector::doEffect_pwd2(), Inkscape::LivePathEffect::LPEPatternAlongPath::doEffect_pwd2(), Inkscape::LivePathEffect::LPEParallel::doEffect_pwd2(), Inkscape::LivePathEffect::LPEOffset::doEffect_pwd2(), Inkscape::LivePathEffect::LPEEnvelope::doEffect_pwd2(), Inkscape::LivePathEffect::LPEDynastroke::doEffect_pwd2(), Inkscape::LivePathEffect::LPECopyRotate::doEffect_pwd2(), Inkscape::LivePathEffect::LPEBendPath::doEffect_pwd2(), doTest(), doTest1(), dumpDoc(), Inkscape::LivePathEffect::find_corners(), Inkscape::Extension::Internal::PovOutput::out(), Inkscape::Extension::Internal::JavaFXOutput::out(), and output_as().
{
std::vector<Point> pts;
sbasis_to_bezier(pts, curve.toSBasis(), 2); //TODO: use something better!
sink.curveTo(pts[0], pts[1], pts[2]);
}
| void Geom::output | ( | LineSegment const & | curve, | |
| SVGPathSink & | sink | |||
| ) |
Definition at line 59 of file 2geom/svg-path.cpp.
References Geom::SVGPathSink::quadTo().
{
sink.quadTo(curve[1], curve[2]);
}
| bool Geom::output_as | ( | Curve const & | curve, | |
| SVGPathSink & | sink | |||
| ) |
Definition at line 70 of file 2geom/svg-path.cpp.
References output().
{
T const *t = dynamic_cast<T const *>(&curve);
if (t) {
output(*t, sink);
return true;
} else {
return false;
}
}
| void Geom::output_svg_path | ( | Path & | path, | |
| SVGPathSink & | sink | |||
| ) |
| void Geom::pair_intersect | ( | Curve const & | A, | |
| double | Al, | |||
| double | Ah, | |||
| Curve const & | B, | |||
| double | Bl, | |||
| double | Bh, | |||
| Crossings & | ret, | |||
| unsigned | depth = 0 | |||
| ) |
This uses the local bounds functions of curves to generically intersect two.
It passes in the curves, time intervals, and keeps track of depth, while returning the results through the Crossings parameter.
Definition at line 318 of file path-intersection.cpp.
References Geom::Curve::boundsLocal(), intersect_polish_root(), linear_intersect(), mid, and Geom::Curve::pointAt().
Referenced by Geom::SimpleCrosser::crossings(), and curve_self_crossings().
{
// std::cout << depth << "(" << Al << ", " << Ah << ")\n";
OptRect Ar = A.boundsLocal(Interval(Al, Ah));
if (!Ar) return;
OptRect Br = B.boundsLocal(Interval(Bl, Bh));
if (!Br) return;
if(! Ar->intersects(*Br)) return;
//Checks the general linearity of the function
if((depth > 12)) { // || (A.boundsLocal(Interval(Al, Ah), 1).maxExtent() < 0.1
//&& B.boundsLocal(Interval(Bl, Bh), 1).maxExtent() < 0.1)) {
double tA, tB, c;
if(linear_intersect(A.pointAt(Al), A.pointAt(Ah),
B.pointAt(Bl), B.pointAt(Bh),
tA, tB, c)) {
tA = tA * (Ah - Al) + Al;
tB = tB * (Bh - Bl) + Bl;
intersect_polish_root(A, tA,
B, tB);
if(depth % 2)
ret.push_back(Crossing(tB, tA, c < 0));
else
ret.push_back(Crossing(tA, tB, c > 0));
return;
}
}
if(depth > 12) return;
double mid = (Bl + Bh)/2;
pair_intersect(B, Bl, mid,
A, Al, Ah,
ret, depth+1);
pair_intersect(B, mid, Bh,
A, Al, Ah,
ret, depth+1);
}
| Crossings Geom::pair_intersect | ( | Curve const & | A, | |
| Interval const & | Ad, | |||
| Curve const & | B, | |||
| Interval const & | Bd | |||
| ) |
| void Geom::parse_svg_path | ( | char const * | str, | |
| SVGPathSink & | sink | |||
| ) | throw (SVGPathParseError) |
Referenced by parse_svg_path(), read_svgd(), and sp_svg_read_pathv().
| std::vector<Path> Geom::parse_svg_path | ( | char const * | str | ) | throw (SVGPathParseError) [inline] |
Definition at line 47 of file svg-path-parser.h.
References parse_svg_path().
{
typedef std::vector<Path> Subpaths;
typedef std::back_insert_iterator<Subpaths> Inserter;
Subpaths subpaths;
Inserter iter(subpaths);
SVGPathGenerator<Inserter> generator(iter);
parse_svg_path(str, generator);
return subpaths;
}
| SBasis2d Geom::partial_derivative | ( | SBasis2d const & | f, | |
| int | dim | |||
| ) |
| Piecewise<T> Geom::partition | ( | const Piecewise< T > & | pw, | |
| std::vector< double > const & | c | |||
| ) |
Piecewise<T> partition(const Piecewise<T> &pw, std::vector<double> const &c); Further subdivides the Piecewise<T> such that there is a cut at every value in c.
Precondition: c sorted lower to higher.
//Given Piecewise<T> a and b: Piecewise<T> ac = a.partition(b.cuts); Piecewise<T> bc = b.partition(a.cuts); //ac.cuts should be equivalent to bc.cuts
Definition at line 329 of file piecewise.h.
References Geom::Piecewise< T >::cuts, elem_portion(), Geom::Piecewise< T >::empty(), Barcode::Code39Ext::i, Geom::Piecewise< T >::invariants(), portion(), Geom::Piecewise< T >::push(), Geom::Piecewise< T >::push_cut(), Geom::Piecewise< T >::push_seg(), Geom::Piecewise< T >::reserve(), Geom::Piecewise< T >::segs, Geom::Piecewise< T >::segT(), and Geom::Piecewise< T >::size().
Referenced by cross(), cutAtRoots(), Geom::Piecewise< T >::dot(), Geom::Piecewise< T >::lerp(), operator*(), operator+(), operator-(), and sectionize().
{
assert(pw.invariants());
if(c.empty()) return Piecewise<T>(pw);
Piecewise<T> ret = Piecewise<T>();
ret.reserve(c.size() + pw.cuts.size() - 1);
if(pw.empty()) {
ret.cuts = c;
for(unsigned i = 0; i < c.size() - 1; i++)
ret.push_seg(T());
return ret;
}
unsigned si = 0, ci = 0; //Segment index, Cut index
//if the cuts have something earlier than the Piecewise<T>, add portions of the first segment
while(c[ci] < pw.cuts.front() && ci < c.size()) {
bool isLast = (ci == c.size()-1 || c[ci + 1] >= pw.cuts.front());
ret.push_cut(c[ci]);
ret.push_seg( elem_portion(pw, 0, c[ci], isLast ? pw.cuts.front() : c[ci + 1]) );
ci++;
}
ret.push_cut(pw.cuts[0]);
double prev = pw.cuts[0]; //previous cut
//Loop which handles cuts within the Piecewise<T> domain
//Should have the cuts = segs + 1 invariant
while(si < pw.size() && ci <= c.size()) {
if(ci == c.size() && prev <= pw.cuts[si]) { //cuts exhausted, straight copy the rest
ret.segs.insert(ret.segs.end(), pw.segs.begin() + si, pw.segs.end());
ret.cuts.insert(ret.cuts.end(), pw.cuts.begin() + si + 1, pw.cuts.end());
return ret;
}else if(ci == c.size() || c[ci] >= pw.cuts[si + 1]) { //no more cuts within this segment, finalize
if(prev > pw.cuts[si]) { //segment already has cuts, so portion is required
ret.push_seg(portion(pw[si], pw.segT(prev, si), 1.0));
} else { //plain copy is fine
ret.push_seg(pw[si]);
}
ret.push_cut(pw.cuts[si + 1]);
prev = pw.cuts[si + 1];
si++;
} else if(c[ci] == pw.cuts[si]){ //coincident
//Already finalized the seg with the code immediately above
ci++;
} else { //plain old subdivision
ret.push(elem_portion(pw, si, prev, c[ci]), c[ci]);
prev = c[ci];
ci++;
}
}
//input cuts extend further than this Piecewise<T>, extend the last segment.
while(ci < c.size()) {
if(c[ci] > prev) {
ret.push(elem_portion(pw, pw.size() - 1, prev, c[ci]), c[ci]);
prev = c[ci];
}
ci++;
}
return ret;
}
| bool Geom::path_direction | ( | Path const & | p | ) |
This function should only be applied to simple paths (regions), as otherwise a boolean winding direction is undefined.
It returns true for fill, false for hole. Defaults to using the sign of area when it reaches funny cases.
Referenced by Geom::Region::Region().
| std::vector< Path > Geom::path_from_piecewise | ( | Geom::Piecewise< Geom::D2< Geom::SBasis > > const & | B, | |
| double | tol, | |||
| bool | only_cubicbeziers | |||
| ) |
Make a path from a d2 sbasis.
- Parameters:
-
p the d2 Symmetric basis polynomial
- Returns:
- a Path
If only_cubicbeziers is true, the resulting path may only contain CubicBezier curves. TODO: some of this logic should be lifted into svg-path
Referenced by Inkscape::LivePathEffect::LPECurveStitch::doEffect_path(), Inkscape::LivePathEffect::LPEAngleBisector::doEffect_path(), Inkscape::LivePathEffect::Effect::doEffect_path(), Inkscape::LivePathEffect::PathParam::set_new_value(), sketch_interpolate(), and SPCurve::stretch_endpoints().
Make a path from a d2 sbasis.
- Parameters:
-
p the d2 Symmetric basis polynomial
- Returns:
- a Path
If only_cubicbeziers is true, the resulting path may only contain CubicBezier curves.
Referenced by cubicbezierpath_from_sbasis().
| std::vector< double > Geom::path_mono_splits | ( | Path const & | p | ) |
Finds all the monotonic splits for a path.
Only includes the split between curves if they switch derivative directions at that point.
Referenced by paths_mono_splits().
| std::vector<Path> Geom::paths_from_regions | ( | Regions const & | rs | ) | [inline] |
Definition at line 101 of file region.h.
References Barcode::Code39Ext::i.
Referenced by crossings_between(), and desanitize().
| std::vector<std::vector<double> > Geom::paths_mono_splits | ( | std::vector< Path > const & | ps | ) |
Applies path_mono_splits to multiple paths, and returns the results such that time-set i corresponds to Path i.
Definition at line 508 of file path-intersection.cpp.
References Barcode::Code39Ext::i, and path_mono_splits().
Referenced by Geom::MonoCrosser::crossings().
{
std::vector<std::vector<double> > ret;
for(unsigned i = 0; i < ps.size(); i++)
ret.push_back(path_mono_splits(ps[i]));
return ret;
}
| static Piecewise<D2<SBasis> > Geom::paths_to_pw | ( | std::vector< Path > | paths | ) | [inline, static] |
Definition at line 680 of file 2geom/path.h.
References Geom::Piecewise< T >::concat(), and Barcode::Code39Ext::i.
Referenced by lpetool_create_measuring_items(), and lpetool_update_measuring_items().
| int Geom::paths_winding | ( | std::vector< Path > const & | ps, | |
| Point | p | |||
| ) |
Definition at line 301 of file 2geom/shape.cpp.
References winding().
Referenced by inner_winding().
| unsigned Geom::pick_coincident | ( | unsigned | ix, | |
| unsigned | jx, | |||
| bool & | rev, | |||
| std::vector< Path > const & | ps, | |||
| CrossingSet const & | crs | |||
| ) |
Definition at line 326 of file 2geom/shape.cpp.
References are_near(), c, cross(), fudgerize(), org::w3c::dom::xpath::LESS_THAN, and dxf_input::val.
Referenced by inner_sanitize().
{
unsigned ex_jx = jx;
unsigned oix = crs[ix][jx].getOther(ix);
double otime = crs[ix][jx].getTime(oix);
Point cross_point = ps[oix].pointAt(otime),
along = ps[oix].pointAt(fudgerize(otime, rev)) - cross_point,
prev = -along;
bool ex_dir = rev;
for(unsigned k = jx; k < crs[ix].size(); k++) {
unsigned koix = crs[ix][k].getOther(ix);
if(koix == oix) {
if(!are_near(otime, crs[ix][k].getTime(oix))) break;
for(unsigned dir = 0; dir < 2; dir++) {
Point val = ps[ix].pointAt(fudgerize(crs[ix][k].getTime(ix), dir)) - cross_point;
Cmp to_prev = cmp(cross(val, prev), 0);
Cmp from_along = cmp(cross(along, val), 0);
Cmp c = cmp(from_along, to_prev);
if(c == EQUAL_TO && from_along == LESS_THAN) {
ex_jx = k;
prev = val;
ex_dir = dir;
}
}
}
}
rev = ex_dir;
return ex_jx;
}
| Point Geom::pointAt | ( | PathVector const & | path_in, | |
| PathVectorPosition const | pvp | |||
| ) | [inline] |
Definition at line 120 of file pathvector.h.
References Geom::PathVectorPosition::path_nr, and Geom::PathVectorPosition::t.
Referenced by split_bounds().
{
return path_in[pvp.path_nr].pointAt(pvp.t);
}
| void Geom::polish_intersections | ( | std::vector< std::pair< double, double > > & | xs, | |
| D2< SBasis > const & | A, | |||
| D2< SBasis > const & | B | |||
| ) |
| SBasis Geom::poly_to_sbasis | ( | Poly const & | p | ) |
Changes the basis of p to be sbasis.
- Parameters:
-
p the Monomial basis polynomial
- Returns:
- the Symmetric basis polynomial
This algorithm is horribly slow and numerically terrible. Only for testing.
| D2<T> Geom::portion | ( | const D2< T > & | a, | |
| Interval | i | |||
| ) | [inline] |
| SBasis Geom::portion | ( | const SBasis & | t, | |
| Interval | ivl | |||
| ) | [inline] |
| Piecewise<T> Geom::portion | ( | const Piecewise< T > & | pw, | |
| double | from, | |||
| double | to | |||
| ) |
Piecewise<T> portion(const Piecewise<T> &pw, double from, double to); Returns a Piecewise<T> with a defined domain of [min(from, to), max(from, to)].
Definition at line 396 of file piecewise.h.
References Geom::Piecewise< T >::cuts, elem_portion(), Geom::Piecewise< T >::empty(), Barcode::Code39Ext::i, Geom::Piecewise< T >::invariants(), max(), min(), portion(), Geom::Piecewise< T >::push(), Geom::Piecewise< T >::push_cut(), Geom::Piecewise< T >::push_seg(), Geom::Piecewise< T >::reserve(), Geom::Piecewise< T >::segN(), Geom::Piecewise< T >::segs, Geom::Piecewise< T >::segT(), and Geom::Piecewise< T >::size().
{
if(pw.empty() || from == to) return Piecewise<T>();
Piecewise<T> ret;
double temp = from;
from = std::min(from, to);
to = std::max(temp, to);
unsigned i = pw.segN(from);
ret.push_cut(from);
if(i == pw.size() - 1 || to <= pw.cuts[i + 1]) { //to/from inhabit the same segment
ret.push(elem_portion(pw, i, from, to), to);
return ret;
}
ret.push_seg(portion( pw[i], pw.segT(from, i), 1.0 ));
i++;
unsigned fi = pw.segN(to, i);
ret.reserve(fi - i + 1);
if (to == pw.cuts[fi]) fi-=1;
ret.segs.insert(ret.segs.end(), pw.segs.begin() + i, pw.segs.begin() + fi); //copy segs
ret.cuts.insert(ret.cuts.end(), pw.cuts.begin() + i, pw.cuts.begin() + fi + 1); //and their cuts
ret.push_seg( portion(pw[fi], 0.0, pw.segT(to, fi)));
if(to != ret.cuts.back()) ret.push_cut(to);
ret.invariants();
return ret;
}
Definition at line 336 of file bezier.h.
References Bezier(), NULL, Geom::Bezier::order(), and subdivideArr().
Referenced by bounds_local(), Geom::FragmentConcept< T >::constraints(), elem_portion(), partition(), Geom::SBasisCurve::portion(), portion(), and Geom::BezierCurve< 1 >::portion().
{
//TODO: implement better?
std::valarray<Coord> res(a.order() + 1);
if(from == 0) {
if(to == 1) { return Bezier(a); }
subdivideArr(to, &const_cast<Bezier&>(a).c_[0], &res[0], NULL, a.order());
return Bezier(&res[0], a.order());
}
subdivideArr(from, &const_cast<Bezier&>(a).c_[0], NULL, &res[0], a.order());
if(to == 1) return Bezier(&res[0], a.order());
std::valarray<Coord> res2(a.order()+1);
subdivideArr((to - from)/(1 - from), &res[0], &res2[0], NULL, a.order());
return Bezier(&res2[0], a.order());
}
| D2<T> Geom::portion | ( | const D2< T > & | a, | |
| Coord | f, | |||
| Coord | t | |||
| ) | [inline] |
| T Geom::portion | ( | const T & | t, | |
| const Interval & | i | |||
| ) | [inline] |
Definition at line 100 of file concepts.h.
References Geom::Interval::max(), Geom::Interval::min(), and portion().
| Scale Geom::pow | ( | Scale const & | s, | |
| int | n | |||
| ) |
| Translate Geom::pow | ( | Translate const & | t, | |
| int | n | |||
| ) |
Referenced by Inkscape::SVG::PathString::State::appendRelativeCoord(), Inkscape::Filters::calcFilter(), clonetiler_apply(), clonetiler_get_transform(), decimal_round(), Inkscape::decimal_round(), Inkscape::LivePathEffect::LPEVonKoch::doEffect_path(), Inkscape::LivePathEffect::LPESketch::doEffect_pwd2(), Inkscape::LivePathEffect::LPELattice::doEffect_pwd2(), Inkscape::UI::CurveDragPoint::dragged(), Inkscape::UI::Widget::UnitMenu::getDefaultStep(), gr_knot_moved_midpoint_handler(), org::siox::CieLab::init(), SpiralKnotHolderEntityOuter::knot_set(), Inkscape::Filters::SpotLight::light_components(), lwpline2svg(), Shape::MakeOffset(), Shape::MakeTweak(), Inkscape::UI::Widget::ZoomStatus::on_value_changed(), pattern2dasharray(), pline2svg(), random_position(), Inkscape::Extension::Internal::SingularValueDecomposition::rank(), Inkscape::Filters::FilterComponentTransfer::render(), rround(), sp_dtw_zoom_value_changed(), sp_dtw_zoom_value_to_display(), sp_export_bbox_equal(), sp_spiral_get_polar(), sp_spiral_get_xy(), sp_svg_number_write_d(), sp_svg_number_write_de(), sp_xml_dtoa(), org::siox::CieLab::toRGB(), tweak_profile(), and Inkscape::UI::Widget::value_to_display().
| Rotate Geom::pow | ( | Rotate | x, | |
| long | n | |||
| ) |
| Coord Geom::pow | ( | Coord | x, | |
| long | n | |||
| ) |
| Matrix Geom::pow | ( | Matrix | t, | |
| int | n | |||
| ) |
| Matrix Geom::pow | ( | Matrix | x, | |
| long | n | |||
| ) |
Definition at line 91 of file transforms.cpp.
References org::w3c::dom::svg::result, and Geom::Matrix::setIdentity().
| Rotate Geom::pow | ( | Rotate | t, | |
| int | n | |||
| ) |
Definition at line 361 of file line.h.
References Geom::Line::nearestPoint(), and Geom::Line::pointAt().
Referenced by Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(), Inkscape::LineSnapper::constrainedSnap(), Inkscape::LineSnapper::freeSnap(), and sp_dt_guide_event().
{
return _line.pointAt( _line.nearestPoint(_point) );
}
| LineSegment Geom::projection | ( | LineSegment const & | _segment, | |
| Line const & | _line | |||
| ) | [inline] |
Definition at line 367 of file line.h.
References Geom::BezierCurve< order >::finalPoint(), Geom::BezierCurve< order >::initialPoint(), Geom::Line::nearestPoint(), and Geom::Line::segment().
{
return _line.segment( _line.nearestPoint(_segment.initialPoint()),
_line.nearestPoint(_segment.finalPoint()) );
}
Definition at line 46 of file angle.h.
Referenced by Inkscape::UI::Dialogs::GuidelinePropertiesDialog::_setup(), Inkscape::LivePathEffect::CR::KnotHolderEntityRotationAngle::knot_set(), Inkscape::LivePathEffect::CR::KnotHolderEntityStartingAngle::knot_set(), operator<<(), Inkscape::SelTrans::rotateRequest(), Inkscape::SelTrans::skewRequest(), sp_guide_description(), and sp_svg_write_curve().
{ return rad*180.0/M_PI;}
| std::vector<Path> Geom::read_svgd | ( | char const * | name | ) | throw (SVGPathParseError) [inline] |
Definition at line 59 of file svg-path-parser.h.
References polyhedron_3d::name, NULL, and parse_svg_path().
{
FILE* fi = fopen(name, "r");
if(fi == NULL) throw(std::runtime_error("Error opening file"));
char input[1024 * 10];
fgets(input, 1024 * 10, fi);
fclose(fi);
return parse_svg_path(input);
}
| SBasis Geom::reciprocal | ( | Linear const & | a, | |
| int | k | |||
| ) |
Compute the recpirocal of a.
- Parameters:
-
a sbasis functions
- Returns:
- sbasis 1/a
It is recommended to use the piecewise version unless you have good reason.
| SBasis2d Geom::reciprocal | ( | Linear2d const & | a, | |
| int | k | |||
| ) |
| boost::optional< Geom::LineSegment > Geom::rect_line_intersect | ( | Geom::Rect & | r, | |
| Geom::Line | l | |||
| ) |
| std::vector<Geom::Point> Geom::rect_line_intersect | ( | Geom::Point const & | c0, | |
| Geom::Point const & | c1, | |||
| Geom::Point const & | p0, | |||
| Geom::Point const & | p1 | |||
| ) |
Determine whether & where an (infinite) line intersects a rectangle.
c0, c1 are diagonal corners of the rectangle and p1, p1 are distinct points on the line
- Returns:
- A list (possibly empty) of points of intersection. If two such points (say r0 and r1) then it is guaranteed that the order of r0, r1 along the line is the same as the that of c0, c1 (i.e., the vectors r1 - r0 and p1 - p0 point into the same direction).
Definition at line 273 of file 2geom/geom.cpp.
References dot(), eliminate_duplicates_p(), intersects, line_segment_intersect(), Geom::NL::swap(), X, and Y.
Referenced by Inkscape::LivePathEffect::LPELineSegment::doEffect_path().
{
using namespace Geom;
std::vector<Point> results;
Point A(c0);
Point C(c1);
Point B(A[X], C[Y]);
Point D(C[X], A[Y]);
Point res;
if (line_segment_intersect(p0, p1, A, B, res) == intersects) {
results.push_back(res);
}
if (line_segment_intersect(p0, p1, B, C, res) == intersects) {
results.push_back(res);
}
if (line_segment_intersect(p0, p1, C, D, res) == intersects) {
results.push_back(res);
}
if (line_segment_intersect(p0, p1, D, A, res) == intersects) {
results.push_back(res);
}
eliminate_duplicates_p(results);
if (results.size() == 2) {
// sort the results so that the order is the same as that of p0 and p1
Point dir1 (results[1] - results[0]);
Point dir2 (p1 - p0);
if (dot(dir1, dir2) < 0) {
std::swap(results[0], results[1]);
}
}
return results;
}
| boost::optional< Geom::LineSegment > Geom::rect_line_intersect | ( | Geom::Rect & | r, | |
| Geom::LineSegment | ls | |||
| ) |
Determine whether & where an (infinite) line intersects a rectangle.
c0, c1 are diagonal corners of the rectangle and p1, p1 are distinct points on the line
- Returns:
- A list (possibly empty) of points of intersection. If two such points (say r0 and r1) then it is guaranteed that the order of r0, r1 along the line is the same as the that of c0, c1 (i.e., the vectors r1 - r0 and p1 - p0 point into the same direction).
| void Geom::recursively_intersect | ( | OldBezier | a, | |
| double | t0, | |||
| double | t1, | |||
| int | deptha, | |||
| OldBezier | b, | |||
| double | u0, | |||
| double | u1, | |||
| int | depthb, | |||
| std::vector< std::pair< double, double > > & | parameters | |||
| ) |
Definition at line 219 of file recursive-bezier-intersection.cpp.
References Geom::detail::bezier_clipping::det(), intersect_BB(), intersect_steps, Geom::OldBezier::p, and Geom::OldBezier::split().
Referenced by find_intersections_bezier_recursive().
{
intersect_steps ++;
//std::cout << deptha << std::endl;
if( deptha > 0 )
{
OldBezier A[2];
a.split(0.5, A[0], A[1]);
double tmid = (t0+t1)*0.5;
deptha--;
if( depthb > 0 )
{
OldBezier B[2];
b.split(0.5, B[0], B[1]);
double umid = (u0+u1)*0.5;
depthb--;
if( intersect_BB( A[0], B[0] ) )
recursively_intersect( A[0], t0, tmid, deptha,
B[0], u0, umid, depthb,
parameters );
if( intersect_BB( A[1], B[0] ) )
recursively_intersect( A[1], tmid, t1, deptha,
B[0], u0, umid, depthb,
parameters );
if( intersect_BB( A[0], B[1] ) )
recursively_intersect( A[0], t0, tmid, deptha,
B[1], umid, u1, depthb,
parameters );
if( intersect_BB( A[1], B[1] ) )
recursively_intersect( A[1], tmid, t1, deptha,
B[1], umid, u1, depthb,
parameters );
}
else
{
if( intersect_BB( A[0], b ) )
recursively_intersect( A[0], t0, tmid, deptha,
b, u0, u1, depthb,
parameters );
if( intersect_BB( A[1], b ) )
recursively_intersect( A[1], tmid, t1, deptha,
b, u0, u1, depthb,
parameters );
}
}
else
if( depthb > 0 )
{
OldBezier B[2];
b.split(0.5, B[0], B[1]);
double umid = (u0 + u1)*0.5;
depthb--;
if( intersect_BB( a, B[0] ) )
recursively_intersect( a, t0, t1, deptha,
B[0], u0, umid, depthb,
parameters );
if( intersect_BB( a, B[1] ) )
recursively_intersect( a, t0, t1, deptha,
B[0], umid, u1, depthb,
parameters );
}
else // Both segments are fully subdivided; now do line segments
{
double xlk = a.p.back()[X] - a.p[0][X];
double ylk = a.p.back()[Y] - a.p[0][Y];
double xnm = b.p.back()[X] - b.p[0][X];
double ynm = b.p.back()[Y] - b.p[0][Y];
double xmk = b.p[0][X] - a.p[0][X];
double ymk = b.p[0][Y] - a.p[0][Y];
double det = xnm * ylk - ynm * xlk;
if( 1.0 + det == 1.0 )
return;
else
{
double detinv = 1.0 / det;
double s = ( xnm * ymk - ynm *xmk ) * detinv;
double t = ( xlk * ymk - ylk * xmk ) * detinv;
if( ( s < 0.0 ) || ( s > 1.0 ) || ( t < 0.0 ) || ( t > 1.0 ) )
return;
parameters.push_back(std::pair<double, double>(t0 + s * ( t1 - t0 ),
u0 + t * ( u1 - u0 )));
}
}
}
| Regions Geom::region_boolean | ( | bool | rev, | |
| Region const & | a, | |||
| Region const & | b, | |||
| Crossings const & | cr_a, | |||
| Crossings const & | cr_b | |||
| ) |
| Regions Geom::region_boolean | ( | bool | rev, | |
| Region const & | a, | |||
| Region const & | b, | |||
| Crossings const & | cr | |||
| ) |
Referenced by region_boolean().
| Regions Geom::region_boolean | ( | bool | rev, | |
| Region const & | a, | |||
| Region const & | b | |||
| ) | [inline] |
Definition at line 113 of file region.h.
References crossings(), and region_boolean().
| std::vector<double> Geom::region_sizes | ( | Shape const & | a | ) |
Definition at line 208 of file 2geom/shape.cpp.
References Geom::Shape::size().
Referenced by shape_boolean_ra(), and shape_boolean_rb().
| Regions Geom::regions_from_paths | ( | std::vector< Path > const & | ps | ) | [inline] |
Definition at line 428 of file piecewise.h.
References Geom::Piecewise< T >::cuts, Geom::Piecewise< T >::empty(), Barcode::Code39Ext::i, Geom::Piecewise< T >::push(), Geom::Piecewise< T >::push_cut(), Geom::Piecewise< T >::reserve(), and Geom::Piecewise< T >::size().
Referenced by Inkscape::LivePathEffect::LPERecursiveSkeleton::doEffect_pwd2(), Inkscape::LivePathEffect::LPEPatternAlongPath::doEffect_pwd2(), Inkscape::LivePathEffect::LPEEnvelope::doEffect_pwd2(), and Inkscape::LivePathEffect::LPEBendPath::doEffect_pwd2().
| Piecewise<T> Geom::remove_short_cuts_extending | ( | Piecewise< T > const & | f, | |
| double | tol | |||
| ) |
Definition at line 443 of file piecewise.h.
References Geom::Piecewise< T >::cuts, elem_portion(), Geom::Piecewise< T >::empty(), Barcode::Code39Ext::i, Geom::Piecewise< T >::push(), Geom::Piecewise< T >::push_cut(), Geom::Piecewise< T >::reserve(), and Geom::Piecewise< T >::size().
{
if(f.empty()) return f;
Piecewise<T> ret;
ret.reserve(f.size());
ret.push_cut(f.cuts[0]);
double last = f.cuts[0]; // last cut included
for(unsigned i=0; i<f.size(); i++){
if (f.cuts[i+1]-f.cuts[i] >= tol) {
ret.push(elem_portion(f, i, last, f.cuts[i+1]), f.cuts[i+1]);
last = f.cuts[i+1];
}
}
return ret;
}
| static void Geom::reparameterize | ( | Point const | d[], | |
| unsigned const | len, | |||
| double | u[], | |||
| BezierCurve const | bezCurve | |||
| ) | [static] |
Given set of points and their parameterization, try to find a better assignment of parameter values for the points.
- Parameters:
-
d Array of digitized points. u Current parameter values. bezCurve Current fitted curve. len Number of values in both d and u arrays. Also the size of the array that is allocated for return.
Definition at line 546 of file bezier-utils.cpp.
References Barcode::Code39Ext::i, and NewtonRaphsonRootFind().
{
assert( 2 <= len );
unsigned const last = len - 1;
assert( bezCurve[0] == d[0] );
assert( bezCurve[3] == d[last] );
assert( u[0] == 0.0 );
assert( u[last] == 1.0 );
/* Otherwise, consider including 0 and last in the below loop. */
for (unsigned i = 1; i < last; i++) {
u[i] = NewtonRaphsonRootFind(bezCurve, d[i], u[i]);
}
}
| Linear Geom::reverse | ( | Linear const & | a | ) | [inline] |
| D2<T> Geom::reverse | ( | const D2< T > & | a | ) | [inline] |
| Bezier Geom::reverse | ( | const Bezier & | a | ) | [inline] |
Definition at line 329 of file bezier.h.
References Bezier(), Barcode::Code39Ext::i, Geom::Bezier::order(), and org::w3c::dom::svg::result.
Referenced by Inkscape::Text::Layout::Calculator::_findChunksForLine(), Geom::FragmentConcept< T >::constraints(), Inkscape::LivePathEffect::LPEOffset::doEffect_pwd2(), Inkscape::LivePathEffect::LPEExtrude::doEffect_pwd2(), Inkscape::LivePathEffect::LPEDynastroke::doEffect_pwd2(), inner_sanitize(), itos(), Inkscape::SelectionVerb::perform(), Inkscape::UI::Dialogs::recalcSwatchContents(), reverse(), Geom::BezierCurve< 1 >::reverse(), and ultos().
| SBasis Geom::reverse | ( | SBasis const & | a | ) | [inline] |
Returns a function which reverses the domain of a.
- Parameters:
-
a sbasis function
useful for reversing a parameteric curve.
Definition at line 194 of file sbasis.h.
References org::w3c::dom::svg::result, and reverse().
| Piecewise<T> Geom::reverse | ( | Piecewise< T > const & | f | ) |
Definition at line 767 of file piecewise.h.
References Geom::Piecewise< T >::cuts, scour::end, Barcode::Code39Ext::i, Geom::Piecewise< T >::push_cut(), Geom::Piecewise< T >::push_seg(), Geom::Piecewise< T >::reserve(), reverse(), Geom::Piecewise< T >::segs, Geom::Piecewise< T >::size(), scour::start, and voronoi::x.
{
Piecewise<T> ret = Piecewise<T>();
ret.reserve(f.size());
double start = f.cuts[0];
double end = f.cuts.back();
for (unsigned i = 0; i < f.cuts.size(); i++) {
double x = f.cuts[f.cuts.size() - 1 - i];
ret.push_cut(end - (x - start));
}
for (unsigned i = 0; i < f.segs.size(); i++)
ret.push_seg(reverse(f[f.segs.size() - i - 1]));
return ret;
}
| PathVector Geom::reverse_paths_and_order | ( | PathVector const & | path_in | ) |
Reverses all Paths and the order of paths in the vector as well.
Referenced by SPCurve::create_reverse().
| CrossingSet Geom::reverse_ta | ( | CrossingSet const & | cr, | |
| unsigned | split, | |||
| std::vector< double > | max | |||
| ) |
| Crossings Geom::reverse_ta | ( | Crossings const & | cr, | |
| std::vector< double > | max | |||
| ) |
Referenced by shape_boolean_ra().
| Crossings Geom::reverse_tb | ( | Crossings const & | cr, | |
| unsigned | split, | |||
| std::vector< double > | max | |||
| ) |
Referenced by shape_boolean_rb().
| CrossingSet Geom::reverse_tb | ( | CrossingSet const & | cr, | |
| unsigned | split, | |||
| std::vector< double > | max | |||
| ) |
| std::vector< double > Geom::roots | ( | Piecewise< SBasis > const & | f | ) |
Referenced by cutAtRoots(), Inkscape::LivePathEffect::LPESketch::doEffect_pwd2(), Inkscape::LivePathEffect::LPERuler::doEffect_pwd2(), Inkscape::LivePathEffect::LPEExtrude::doEffect_pwd2(), find_tangents(), Inkscape::LivePathEffect::findShadowedTime(), multi_roots_internal(), roots(), and solve_lambda0().
| std::vector< double > Geom::roots | ( | SBasis const & | s | ) |
Find all t s.t s(t) = 0.
- Parameters:
-
a sbasis function
- Returns:
- vector of zeros (roots)
| std::vector<double> Geom::roots | ( | const Piecewise< T > & | pw | ) |
Definition at line 459 of file piecewise.h.
References Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, roots(), and Geom::Piecewise< T >::size().
| std::vector<double> Geom::roots1 | ( | SBasis const & | s | ) |
Definition at line 350 of file sbasis-roots.cpp.
References NR::d, and polyhedron_3d::r.
Definition at line 51 of file d2-sbasis.cpp.
References Barcode::Code39Ext::i, M, Geom::Piecewise< T >::push(), Geom::Piecewise< T >::push_cut(), and org::w3c::dom::svg::result.
Referenced by Inkscape::CanvasAxonomGridSnapper::_getSnapLines(), Inkscape::UI::Dialogs::GuidelinePropertiesDialog::_onApply(), Inkscape::ObjectSnapper::_snapPathsConstrained(), Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(), add_cap(), centroid(), circle_circle_intersection(), SnapManager::constrainedSnap(), Inkscape::LineSnapper::constrainedSnap(), darray_center_tangent(), Inkscape::LivePathEffect::LPECurveStitch::doEffect_path(), Inkscape::LivePathEffect::LPETextLabel::doEffect_pwd2(), Inkscape::LivePathEffect::LPERuler::doEffect_pwd2(), Inkscape::LivePathEffect::LPERoughHatches::doEffect_pwd2(), Inkscape::LivePathEffect::LPERecursiveSkeleton::doEffect_pwd2(), Inkscape::LivePathEffect::LPEPatternAlongPath::doEffect_pwd2(), Inkscape::LivePathEffect::LPEOffset::doEffect_pwd2(), Inkscape::LivePathEffect::LPEExtrude::doEffect_pwd2(), Inkscape::LivePathEffect::LPEEnvelope::doEffect_pwd2(), Inkscape::LivePathEffect::LPEDynastroke::doEffect_pwd2(), Inkscape::LivePathEffect::LPEBendPath::doEffect_pwd2(), Geom::Eigen::Eigen(), Inkscape::LineSnapper::freeSnap(), Geom::Line::from_normal_and_dist(), Geom::Line::fromNormalDistance(), Inkscape::SnappedLine::getLine(), SnapManager::guideConstrainedSnap(), line_intersection(), Geom::ConvexHull::narrowest_diameter(), Geom::detail::bezier_clipping::normal(), Path::OutlineJoin(), rotate_degrees(), Inkscape::SelTrans::rotateRequest(), set_pos_and_anchor(), Inkscape::LivePathEffect::TextParam::setPosAndAnchor(), sp_dt_ruler_event(), sp_dyna_draw_apply(), sp_eraser_apply(), sp_guide_create(), spdc_endpoint_snap_rotation(), unclump_remove_behind(), and vectors_are_clockwise().
| D2<T> Geom::rot90 | ( | D2< T > const & | a | ) | [inline] |
Returns p * Geom::rotate_degrees(90), but more efficient.
Angle direction in Inkscape code: If you use the traditional mathematics convention that y increases upwards, then positive angles are anticlockwise as per the mathematics convention. If you take the common non-mathematical convention that y increases downwards, then positive angles are clockwise, as is common outside of mathematics.
There is no rot_neg90 function: use -rot90(p) instead.
Definition at line 207 of file 2geom/point.h.
Returns x rounded to the nearest integer.
It is unspecified what happens if x is half way between two integers: we may in future use rint/round on platforms that have them.
Definition at line 63 of file utils.h.
Referenced by decimal_round(), SPDesktopWidget::setWindowPosition(), slider_format_falue(), sp_canvas_scroll_to(), sp_ctrlline_update(), sp_guide_description(), sp_guideline_render(), sp_selection_create_bitmap_copy(), RoundTest::testNonNegRound(), and RoundTest::testNonPosRoung().
{ return std::floor(x + .5); }
| Shape Geom::sanitize | ( | std::vector< Path > const & | ps | ) |
| D2< SBasis > Geom::sb2d_cubic_solve | ( | SBasis2d const & | f, | |
| Geom::Point const & | A, | |||
| Geom::Point const & | B | |||
| ) |
Finds a path which traces the 0 contour of f, traversing from A to B as a single cubic d2<sbasis>.
The algorithm is based on matching direction and curvature at each end point.
| D2< SBasis > Geom::sb2dsolve | ( | SBasis2d const & | f, | |
| Geom::Point const & | A, | |||
| Geom::Point const & | B, | |||
| unsigned | degmax | |||
| ) |
Finds a path which traces the 0 contour of f, traversing from A to B as a single d2<sbasis>.
degmax specifies the degree (degree = 2*degmax-1, so a degmax of 2 generates a cubic fit). The algorithm is based on dividing out derivatives at each end point and does not use the curvature for fitting. It is less accurate than sb2d_cubic_solve, although this may be fixed in the future.
| unsigned Geom::sbasis_size | ( | D2< SBasis > const & | a | ) |
| void Geom::sbasis_to_bezier | ( | Bezier & | bz, | |
| SBasis const & | sb, | |||
| size_t | sz | |||
| ) |
Changes the basis of p to be bernstein.
- Parameters:
-
p the Symmetric basis polynomial
- Returns:
- the Bernstein basis polynomial
if the degree is even q is the order in the symmetrical power basis, if the degree is odd q is the order + 1 n is always the polynomial degree, i. e. the Bezier order sz is the number of bezier handles.
Referenced by build_from_sbasis(), and output().
| void Geom::sbasis_to_bezier | ( | std::vector< Point > & | bz, | |
| D2< SBasis > const & | sb, | |||
| size_t | sz | |||
| ) |
| Poly Geom::sbasis_to_poly | ( | SBasis const & | sb | ) |
Changes the basis of p to be monomial.
- Parameters:
-
p the Symmetric basis polynomial
- Returns:
- the Monomial basis polynomial
This algorithm is horribly slow and numerically terrible. Only for testing.
Definition at line 31 of file d2-sbasis.cpp.
References org::w3c::dom::svg::a, Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, partition(), Geom::Piecewise< T >::size(), voronoi::x, and voronoi::y.
Referenced by Inkscape::LivePathEffect::bend(), Inkscape::LivePathEffect::LPEPerspectivePath::doEffect_pwd2(), and SPCurve::stretch_endpoints().
| IntersectorKind Geom::segment_intersect | ( | Geom::Point const & | p00, | |
| Geom::Point const & | p01, | |||
| Geom::Point const & | p10, | |||
| Geom::Point const & | p11, | |||
| Geom::Point & | result | |||
| ) |
Determine whether & where two line segments intersect.
If the two segments don't intersect, then result remains unchanged.
- Precondition:
- neither segment is zero-length; i.e. p00 != p01 and p10 != p11.
Definition at line 181 of file 2geom/geom.cpp.
References dot(), line_intersection(), and segment_intersectp().
{
if(segment_intersectp(p00, p01, p10, p11)) {
Geom::Point n0 = (p01 - p00).ccw();
double d0 = dot(n0,p00);
Geom::Point n1 = (p11 - p10).ccw();
double d1 = dot(n1,p10);
return line_intersection(n0, d0, n1, d1, result);
} else {
return no_intersection;
}
}
| bool Geom::segment_intersectp | ( | Geom::Point const & | p00, | |
| Geom::Point const & | p01, | |||
| Geom::Point const & | p10, | |||
| Geom::Point const & | p11 | |||
| ) |
Determine whether two line segments intersect.
This doesn't find the point of intersection, use the line_intersect function above, or the segment_intersection interface below.
- Precondition:
- neither segment is zero-length; i.e. p00 != p01 and p10 != p11.
Definition at line 138 of file 2geom/geom.cpp.
References line_segment_intersectp().
Referenced by segment_intersect().
{
if(p00 == p01) return false;
if(p10 == p11) return false;
/* true iff ( (the p1 segment straddles the p0 infinite line)
* and (the p0 segment straddles the p1 infinite line) ). */
return (line_segment_intersectp(p00, p01, p10, p11) &&
line_segment_intersectp(p10, p11, p00, p01));
}
Referenced by Geom::Region::invariants(), and sp_shape_snappoints().
| static void Geom::set_first_point | ( | Piecewise< D2< SBasis > > & | f, | |
| Point | a | |||
| ) | [static] |
Definition at line 188 of file d2-sbasis.cpp.
References org::w3c::dom::svg::f, X, and Y.
Referenced by fuse_nearby_ends().
| static void Geom::set_last_point | ( | Piecewise< D2< SBasis > > & | f, | |
| Point | a | |||
| ) | [static] |
Definition at line 201 of file d2-sbasis.cpp.
References org::w3c::dom::svg::f, X, and Y.
Referenced by fuse_nearby_ends().
| static int Geom::SGN | ( | t | x | ) | [static] |
Definition at line 14 of file solve-bezier-one-d.cpp.
Referenced by crossing_count(), and Geom::Bernsteins::find_bernstein_roots().
| int Geom::sgn | ( | const T & | x | ) | [inline] |
Sign function - indicates the sign of a numeric type.
-1 indicates negative, 1 indicates positive, and 0 indicates, well, 0. Mathsy people will know this is basically the derivative of abs, except for the fact that it is defined on 0.
| int Geom::sgn | ( | unsigned int | j, | |
| unsigned int | k | |||
| ) | [inline] |
Definition at line 83 of file sbasis-to-bezier.cpp.
Referenced by bezier_to_sbasis(), Geom::sturm::count_signs(), Inkscape::LivePathEffect::Pl::KnotHolderEntityRightEnd::knot_set(), and Inkscape::LivePathEffect::Pl::KnotHolderEntityLeftEnd::knot_set().
{
assert (j >= k);
// we are sure that j >= k
return ((j-k) & 1u) ? -1 : 1;
}
Referenced by boolop(), shape_boolean_ra(), and shape_boolean_rb().
| Shape Geom::shape_boolean_ra | ( | bool | rev, | |
| Shape const & | a, | |||
| Shape const & | b, | |||
| CrossingSet const & | crs | |||
| ) |
Definition at line 216 of file 2geom/shape.cpp.
References Geom::Shape::inverse(), region_sizes(), reverse_ta(), shape_boolean(), and Geom::Shape::size().
Referenced by boolop().
{
return shape_boolean(rev, a.inverse(), b, reverse_ta(crs, a.size(), region_sizes(a)));
}
| Shape Geom::shape_boolean_rb | ( | bool | rev, | |
| Shape const & | a, | |||
| Shape const & | b, | |||
| CrossingSet const & | crs | |||
| ) |
Definition at line 220 of file 2geom/shape.cpp.
References Geom::Shape::inverse(), region_sizes(), reverse_tb(), shape_boolean(), and Geom::Shape::size().
Referenced by boolop().
{
return shape_boolean(rev, a, b.inverse(), reverse_tb(crs, a.size(), region_sizes(b)));
}
| SBasis Geom::shift | ( | SBasis const & | a, | |
| int | sh | |||
| ) |
multiply a by x^sh in place (Exact)
- Parameters:
-
a sbasis function sh power
- Returns:
- a
| SBasis Geom::shift | ( | Linear const & | a, | |
| int | sh | |||
| ) |
multiply a by x^sh (Exact)
- Parameters:
-
a linear function sh power
- Returns:
- a* x^sh
| SBasis2d Geom::shift | ( | SBasis2d const & | a, | |
| int | sh | |||
| ) |
Referenced by Inkscape::Extension::Internal::SingularValueDecomposition::calculate(), divide_by_sk(), Inkscape::LivePathEffect::LPERoughHatches::doEffect_pwd2(), feed_path_to_cairo(), find_tangents(), Inkscape::SelTrans::moveTo(), nr_arena_image_render(), Inkscape::snap_rectangular_box(), sp_event_show_modifier_tip(), sp_star_get_xy(), and sqrt_internal().
| SBasis2d Geom::shift | ( | Linear2d const & | a, | |
| int | sh | |||
| ) |
Definition at line 58 of file convex-cover.cpp.
References cross().
Referenced by Geom::ConvexHull::graham_scan(), Geom::ConvexHull::is_clockwise(), Geom::ConvexHull::is_left(), and Geom::ConvexHull::is_strict_left().
{
return cross((p1 - p0), (p2 - p0));
}
Return the sign of the two functions pointwise.
- Parameters:
-
f function
Return the sign of the two functions pointwise.
- Parameters:
-
f function
| SBasis Geom::sin | ( | Linear | b, | |
| int | k | |||
| ) |
Compute the sine of a to k terms.
- Parameters:
-
b linear function
- Returns:
- sbasis sin(a)
It is recommended to use the piecewise version unless you have good reason.
Compute the sine of a function.
- Parameters:
-
f function tol maximum error order maximum degree polynomial to use
Compute the sine of a function.
- Parameters:
-
f function tol maximum error order maximum degree polynomial to use
Referenced by Gear::_arc(), Inkscape::Text::Layout::_getGlyphTransformMatrix(), Gear::_involute(), Geom::SVGEllipticalArc::allNearestPoints(), Geom::EllipticalArc::allNearestPoints(), Geom::Ray::angle(), Geom::Line::angle(), arc2path(), ArcAnglesAndCenter(), Geom::SVGEllipticalArc::boundsExact(), Geom::EllipticalArc::boundsExact(), lwpolyline::bulge_end_angle(), polyline::bulge_end_angle(), lwpolyline::bulge_start_angle(), polyline::bulge_start_angle(), Geom::SVGEllipticalArc::calculate_center_and_extreme_angles(), Geom::EllipticalArc::calculate_center_and_extreme_angles(), clonetiler_get_transform(), Inkscape::LivePathEffect::LPETextLabel::doEffect_pwd2(), Inkscape::LivePathEffect::LPEDynastroke::doEffect_pwd2(), get_snap_vector(), Geom::Circle::getPath(), Geom::Ellipse::implicit_form_coefficients(), integrate_spiro(), Inkscape::Filters::DistantLight::light_vector(), Shape::MakeTweak(), Avoid::Router::markConnectors(), Geom::SVGEllipticalArc::pointAtAngle(), Geom::EllipticalArc::pointAtAngle(), Geom::Point::polar(), Inkscape::Text::Layout::queryCursorShape(), Inkscape::Filters::FilterColorMatrix::render(), Geom::SVGEllipticalArc::roots(), Geom::EllipticalArc::roots(), org::w3c::dom::svg::SVGMatrix::rotate(), rotate_degrees(), org::w3c::dom::svg::SVGMatrix::rotateFromVector(), Geom::Ellipse::set(), Proj::TransfMat3x4::set_infinite_direction(), set_pos_and_anchor(), Inkscape::LivePathEffect::TextParam::setPosAndAnchor(), sp_arc_get_xy(), sp_color_wheel_paint(), sp_color_wheel_process_in_triangle(), sp_color_wheel_recalc_triangle(), sp_dyna_draw_apply(), sp_eraser_apply(), sp_genericellipse_set_shape(), sp_genericellipse_snappoints(), sp_spiral_get_tangent(), sp_spiral_get_xy(), sp_spray_recursive(), sp_star_get_xy(), sp_te_get_cursor_coords(), sp_tweak_dilate_recursive(), spdc_endpoint_snap_rotation(), spiro_seg_to_bpath(), tan2(), Path::TangentOnArcAt(), NrRotateTest::testCtorsCompares(), DeltaTest::testSine(), text2text(), Geom::SVGEllipticalArc::toSBasis(), Geom::EllipticalArc::toSBasis(), Geom::Ellipse::transformed(), Geom::SVGEllipticalArc::valueAtAngle(), and Geom::EllipticalArc::valueAtAngle().
| std::vector< std::complex< double > > Geom::solve | ( | Poly const & | pp | ) |
| std::vector< double > Geom::solve_reals | ( | Poly const & | p | ) |
Referenced by Geom::SVGEllipticalArc::allNearestPoints(), and Geom::EllipticalArc::allNearestPoints().
| void Geom::sort_crossings | ( | Crossings & | cr, | |
| unsigned | ix | |||
| ) | [inline] |
Definition at line 141 of file crossing.h.
Referenced by Geom::Crosser< Path >::crossings().
{ std::sort(cr.begin(), cr.end(), CrossingOrder(ix)); }
| void Geom::split | ( | vector< Point > const & | p, | |
| double | t, | |||
| vector< Point > & | left, | |||
| vector< Point > & | right | |||
| ) |
Definition at line 64 of file basic-intersection.cpp.
References Barcode::Code39Ext::i, and lerp().
{
const unsigned sz = p.size();
Geom::Point Vtemp[sz][sz];
/* Copy control points */
std::copy(p.begin(), p.end(), Vtemp[0]);
/* Triangle computation */
for (unsigned i = 1; i < sz; i++) {
for (unsigned j = 0; j < sz - i; j++) {
Vtemp[i][j] = lerp(t, Vtemp[i-1][j], Vtemp[i-1][j+1]);
}
}
left.resize(sz);
right.resize(sz);
for (unsigned j = 0; j < sz; j++)
left[j] = Vtemp[j][0];
for (unsigned j = 0; j < sz; j++)
right[j] = Vtemp[sz-1-j][j];
}
| std::vector<Geom::Piecewise<Geom::D2<Geom::SBasis> > > Geom::split_at_discontinuities | ( | Geom::Piecewise< Geom::D2< Geom::SBasis > > const & | pwsbin, | |
| double | tol | |||
| ) |
Definition at line 168 of file d2-sbasis.cpp.
References Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, L2(), and Geom::Piecewise< T >::segs.
Referenced by Inkscape::LivePathEffect::LPESketch::doEffect_pwd2(), Inkscape::LivePathEffect::LPERecursiveSkeleton::doEffect_pwd2(), and Inkscape::LivePathEffect::LPEPatternAlongPath::doEffect_pwd2().
{
using namespace Geom;
std::vector<Piecewise<D2<SBasis> > > ret;
unsigned piece_start = 0;
for (unsigned i=0; i<pwsbin.segs.size(); i++){
if (i==(pwsbin.segs.size()-1) || L2(pwsbin.segs[i].at1()- pwsbin.segs[i+1].at0()) > tol){
Piecewise<D2<SBasis> > piece;
piece.cuts.push_back(pwsbin.cuts[piece_start]);
for (unsigned j = piece_start; j<i+1; j++){
piece.segs.push_back(pwsbin.segs[j]);
piece.cuts.push_back(pwsbin.cuts[j+1]);
}
ret.push_back(piece);
piece_start = i+1;
}
}
return ret;
}
| std::vector<std::vector<Rect> > Geom::split_bounds | ( | std::vector< Path > const & | p, | |
| std::vector< std::vector< double > > | splits | |||
| ) |
Processes the bounds for a list of paths and a list of splits on them, yielding a list of rects for each.
Each entry i corresponds to path i of the input. The number of rects in each entry is guaranteed to be the number of splits for that path, subtracted by one.
Definition at line 520 of file path-intersection.cpp.
References Barcode::Code39Ext::i, and pointAt().
Referenced by Geom::MonoCrosser::crossings().
| T Geom::sqr | ( | const T & | x | ) | [inline] |
Definition at line 50 of file utils.h.
Referenced by Inkscape::Filters::_make_kernel(), Inkscape::Filters::calcFilter(), Inkscape::Filters::calcTriggsSdikaM(), and Geom::Ellipse::set().
| SBasis2d Geom::sqrt | ( | SBasis2d const & | a, | |
| int | k | |||
| ) |
Referenced by Inkscape::Filters::Filter::_filter_resolution(), add_cap(), Geom::SVGEllipticalArc::allNearestPoints(), Geom::EllipticalArc::allNearestPoints(), ArcAnglesAndCenter(), arcLengthSb(), box3d_set_transform(), lwpolyline::bulge_end_angle(), polyline::bulge_end_angle(), lwpolyline::bulge_r(), polyline::bulge_r(), lwpolyline::bulge_start_angle(), polyline::bulge_start_angle(), Inkscape::Filters::calcFilter(), Inkscape::Extension::Internal::SingularValueDecomposition::calculate(), Geom::SVGEllipticalArc::calculate_center_and_extreme_angles(), circle_circle_intersection(), compute_max_error_ratio(), Inkscape::LineSnapper::constrainedSnap(), cubic_bbox(), cubics_fitting_curvature(), ddist(), NR::Matrix::descrim(), Geom::Matrix::descrim(), org::siox::CieLab::diff(), Avoid::dist(), distance(), distance(), NR::distance(), distance_to_segment(), Inkscape::LivePathEffect::LPESketch::doEffect_pwd2(), Inkscape::LivePathEffect::LPEDynastroke::doEffect_pwd2(), cola::dummy_var_euclidean_dist(), NR::Eigen::Eigen(), Geom::Eigen::Eigen(), cola::ConstrainedMajorizationLayout::euclidean_distance(), NR::expansion(), Geom::Matrix::expansionX(), Geom::Matrix::expansionY(), find_bounds_for_lambda0(), geom_cubic_bbox_wind_distance(), geom_line_wind_distance(), Inkscape::Filters::FilterUnits::get_matrix_units2pb(), get_path_force(), get_scale_transform_with_stroke(), get_visual_bbox(), Shape::initialiseEdgeData(), Gear::involute_intersect_angle(), Gear::involute_swath_angle(), L2(), lwpline2svg(), Shape::MakeOffset(), Shape::MakeTweak(), NormalDistribution(), Geom::Point::normalize(), NR::Point::normalize(), opti_penalty(), Geom::detail::bezier_clipping::orientation_line(), pattern2dasharray(), penalty3(), pline2svg(), pointslope(), render_curveto(), Geom::SVGEllipticalArc::roots(), Geom::EllipticalArc::roots(), sb_length_integrating(), Geom::Ellipse::set(), Geom::Circle::set(), sp_ctrl_build_cache(), sp_dyna_draw_apply(), sp_dyna_draw_brush(), sp_eraser_apply(), sp_eraser_brush(), sp_genericellipse_update(), sp_offset_distance_to_original(), sp_rect_set_transform(), sp_tweak_dilate(), sp_tweak_dilate_recursive(), sqrt_internal(), Inkscape::Extension::Internal::svd_hypot(), tangent(), Path::TangentOnArcAt(), Inkscape::UI::Dialog::TileDialog::TileDialog(), Inkscape::Filters::FilterTurbulence::TurbulenceInit(), and Inkscape::UI::Dialog::TileDialog::updateSelection().
| SBasis Geom::sqrt | ( | SBasis const & | a, | |
| int | k | |||
| ) |
Compute the sqrt of a.
- Parameters:
-
a sbasis functions
- Returns:
- sbasis
It is recommended to use the piecewise version unless you have good reason. TODO: convert int k to unsigned k, and remove cast
Compute the sqrt of a function.
- Parameters:
-
f function
Compute the sqrt of a function.
- Parameters:
-
f function
Definition at line 139 of file sbasis-math.cpp.
References Geom::SBasis::at0(), Geom::SBasis::at1(), compose(), Geom::Piecewise< T >::concat(), err, Barcode::Code39Ext::i, Geom::SBasis::isZero(), multiply(), polyhedron_3d::r, Geom::SBasis::resize(), Geom::Piecewise< T >::setDomain(), shift(), Geom::SBasis::size(), sqrt(), Geom::SBasis::tailError(), and Geom::SBasis::truncate().
{
SBasis sqrtf;
if(f.isZero() || order == 0){
return Piecewise<SBasis>(sqrtf);
}
if (f.at0()<-tol*tol && f.at1()<-tol*tol){
return sqrt_internal(-f,tol,order);
}else if (f.at0()>tol*tol && f.at1()>tol*tol){
sqrtf.resize(order+1, Linear(0,0));
sqrtf[0] = Linear(std::sqrt(f[0][0]), std::sqrt(f[0][1]));
SBasis r = f - multiply(sqrtf, sqrtf); // remainder
for(unsigned i = 1; int(i) <= order && i<r.size(); i++) {
Linear ci(r[i][0]/(2*sqrtf[0][0]), r[i][1]/(2*sqrtf[0][1]));
SBasis cisi = shift(ci, i);
r -= multiply(shift((sqrtf*2 + cisi), i), SBasis(ci));
r.truncate(order+1);
sqrtf[i] = ci;
if(r.tailError(i) == 0) // if exact
break;
}
}else{
sqrtf = Linear(std::sqrt(fabs(f.at0())), std::sqrt(fabs(f.at1())));
}
double err = (f - multiply(sqrtf, sqrtf)).tailError(0);
if (err<tol){
return Piecewise<SBasis>(sqrtf);
}
Piecewise<SBasis> sqrtf0,sqrtf1;
sqrtf0 = sqrt_internal(compose(f,Linear(0.,.5)),tol,order);
sqrtf1 = sqrt_internal(compose(f,Linear(.5,1.)),tol,order);
sqrtf0.setDomain(Interval(0.,.5));
sqrtf1.setDomain(Interval(.5,1.));
sqrtf0.concat(sqrtf1);
return sqrtf0;
}
| Shape Geom::stopgap_cleaner | ( | std::vector< Path > const & | ps | ) |
| void Geom::subdiv_sbasis | ( | SBasis const & | s, | |
| std::vector< double > & | roots, | |||
| double | left, | |||
| double | right | |||
| ) |
Definition at line 332 of file sbasis-roots.cpp.
References bounds_fast(), compose(), addnodes::e, Geom::SBasis::push_back(), and Geom::SBasis::tailError().
{
OptInterval bs = bounds_fast(s);
if(!bs || bs->min() > 0 || bs->max() < 0)
return; // no roots here
if(s.tailError(1) < 1e-7) {
double t = s[0][0] / (s[0][0] - s[0][1]);
roots.push_back(left*(1-t) + t*right);
return;
}
double middle = (left + right)/2;
subdiv_sbasis(compose(s, Linear(0, 0.5)), roots, left, middle);
subdiv_sbasis(compose(s, Linear(0.5, 1.)), roots, middle, right);
}
| Coord Geom::subdivideArr | ( | Coord | t, | |
| Coord const * | v, | |||
| Coord * | left, | |||
| Coord * | right, | |||
| unsigned | order | |||
| ) | [inline] |
Definition at line 46 of file bezier.h.
References Barcode::Code39Ext::i, and N.
Referenced by portion(), and Geom::Bezier::subdivide().
{
/*
* Bernstein :
* Evaluate a Bernstein function at a particular parameter value
* Fill in control points for resulting sub-curves.
*
*/
unsigned N = order+1;
std::valarray<Coord> row(N);
for (unsigned i = 0; i < N; i++)
row[i] = v[i];
// Triangle computation
const double omt = (1-t);
if(left)
left[0] = row[0];
if(right)
right[order] = row[order];
for (unsigned i = 1; i < N; i++) {
for (unsigned j = 0; j < N - i; j++) {
row[j] = omt*row[j] + t*row[j+1];
}
if(left)
left[i] = row[0];
if(right)
right[order-i] = row[order-i];
}
return (row[0]);
/*
Coord vtemp[order+1][order+1];
// Copy control points
std::copy(v, v+order+1, vtemp[0]);
// Triangle computation
for (unsigned i = 1; i <= order; i++) {
for (unsigned j = 0; j <= order - i; j++) {
vtemp[i][j] = lerp(t, vtemp[i-1][j], vtemp[i-1][j+1]);
}
}
if(left != NULL)
for (unsigned j = 0; j <= order; j++)
left[j] = vtemp[j][0];
if(right != NULL)
for (unsigned j = 0; j <= order; j++)
right[j] = vtemp[order-j][j];
return (vtemp[order][0]);*/
}
| std::vector< std::vector< unsigned > > Geom::sweep_bounds | ( | std::vector< Rect > | rs, | |
| Dim2 | d | |||
| ) |
Make a list of pairs of self intersections in a list of Rects.
- Parameters:
-
rs,: vector of Rect. d,: dimension to sweep along
[(A = rs[i], B = rs[j]) for i,J in enumerate(pairs) for j in J] then A.left <= B.left
Referenced by Geom::Shape::containment_list(), Geom::MonoCrosser::crossings(), Geom::Crosser< Path >::crossings(), and curve_sweep().
| std::vector< std::vector< unsigned > > Geom::sweep_bounds | ( | std::vector< Rect > | a, | |
| std::vector< Rect > | b, | |||
| Dim2 | d | |||
| ) |
Make a list of pairs of red-blue intersections between two lists of Rects.
- Parameters:
-
a,: vector of Rect. b,: vector of Rect. d,: dimension to scan along
[(A = rs[i], B = rs[j]) for i,J in enumerate(pairs) for j in J] then A.left <= B.left, A in a, B in b
| ConvexHull Geom::sweepline_intersection | ( | ConvexHull const & | a, | |
| ConvexHull const & | b | |||
| ) |
| double Geom::tail_error | ( | D2< SBasis > const & | a, | |
| unsigned | tail | |||
| ) |
| D2< Piecewise< SBasis > > Geom::tan2 | ( | Piecewise< SBasis > const & | angle, | |
| double | tol = .01, |
|||
| unsigned | order = 3 | |||
| ) |
tan2 is the pseudo-inverse of atan2.
It takes an angle and returns a unit_vector that points in the direction of angle.
- Parameters:
-
angle a piecewise function of angle wrt t. tol the maximum error allowed. order the maximum degree to use for approximation
Definition at line 210 of file sbasis-geometric.cpp.
{
return D2<Piecewise<SBasis> >(cos(angle, tol, order), sin(angle, tol, order));
}
tan2 is the pseudo-inverse of atan2.
It takes an angle and returns a unit_vector that points in the direction of angle.
- Parameters:
-
angle a piecewise function of angle wrt t. tol the maximum error allowed. order the maximum degree to use for approximation
Definition at line 199 of file sbasis-geometric.cpp.
{
return tan2(Piecewise<SBasis>(angle), tol, order);
}
| bool Geom::transform_equalp | ( | Geom::Matrix const & | m0, | |
| Geom::Matrix const & | m1, | |||
| Geom::Coord const | epsilon | |||
| ) |
| bool Geom::translate_equalp | ( | Geom::Matrix const & | m0, | |
| Geom::Matrix const & | m1, | |||
| Geom::Coord const | epsilon | |||
| ) |
| SBasis2d Geom::truncate | ( | SBasis2d const & | a, | |
| unsigned | terms | |||
| ) |
| SBasis Geom::truncate | ( | SBasis const & | a, | |
| unsigned | terms | |||
| ) | [inline] |
| void Geom::truncateResult | ( | Piecewise< SBasis > & | f, | |
| int | order | |||
| ) |
Definition at line 275 of file sbasis-math.cpp.
References Geom::Piecewise< T >::segs.
| OptRect Geom::unify | ( | OptRect const & | a, | |
| OptRect const & | b | |||
| ) | [inline] |
| Rect Geom::unify | ( | const Rect & | a, | |
| const Rect & | b | |||
| ) | [inline] |
| Interval Geom::unify | ( | const Interval & | a, | |
| const Interval & | b | |||
| ) | [inline] |
Definition at line 223 of file interval.h.
References Geom::Interval::max(), max, Geom::Interval::min(), and min.
Referenced by Geom::RectHull::add(), Inkscape::Selection::bounds(), enclose_items(), sp_desktop_widget_update_scrollbars(), sp_item_invoke_bbox_full(), unify(), and Inkscape::UI::View::EditWidget::updateScrollbars().
| Rect Geom::union_list | ( | std::vector< Rect > const & | r | ) | [inline] |
Definition at line 155 of file rect.h.
References Barcode::Code39Ext::i, and Geom::D2< Interval >::unionWith().
Referenced by Geom::MonoCrosser::crossings().
Returns a version of a scaled to be a unit vector (within rounding error).
The current version tries to handle infinite coordinates gracefully, but it's not clear that any callers need that.
- Precondition:
- a != Point(0, 0).
- Neither coordinate is NaN.
- Postcondition:
- L2(ret) very near 1.0.
Referenced by Inkscape::ObjectSnapper::_snapPathsConstrained(), Inkscape::UI::Node::_updateAutoHandles(), Inkscape::UI::PathManipulator::_updateOutline(), darray_right_tangent(), Inkscape::UI::direction(), Inkscape::LivePathEffect::LPECurveStitch::doEffect_path(), Inkscape::LivePathEffect::LPEAngleBisector::doEffect_path(), Inkscape::LivePathEffect::LPETextLabel::doEffect_pwd2(), Inkscape::LivePathEffect::LPETangentToCurve::doEffect_pwd2(), Inkscape::LivePathEffect::LPERuler::doEffect_pwd2(), Inkscape::LivePathEffect::LPERoughHatches::doEffect_pwd2(), Inkscape::LivePathEffect::LPEPerpBisector::doEffect_pwd2(), Inkscape::LivePathEffect::LPEParallel::doEffect_pwd2(), Inkscape::LivePathEffect::LPECopyRotate::doEffect_pwd2(), Inkscape::LivePathEffect::LPEParallel::doOnApply(), Inkscape::LivePathEffect::LPECopyRotate::doOnApply(), Inkscape::UI::Handle::dragged(), Geom::Eigen::Eigen(), Inkscape::LivePathEffect::findShadowedTime(), fit_and_split(), generate_bezier(), interpolate(), Geom::detail::ellipse_equation::normal(), Path::OutlineJoin(), Gear::path(), Inkscape::UI::Node::pickBestType(), Box3D::Line::point_from_lambda(), Inkscape::UI::PathManipulator::scaleHandle(), set_pos_and_anchor(), Inkscape::UI::Handle::setDirection(), Inkscape::UI::Handle::setLength(), Inkscape::LivePathEffect::TextParam::setPosAndAnchor(), Inkscape::UI::Node::setType(), sketch_interpolate(), unclump_pull(), unclump_push(), and unitVector().
| Piecewise< D2< SBasis > > Geom::unitVector | ( | Piecewise< D2< SBasis > > const & | V, | |
| double | tol = .01, |
|||
| unsigned | order = 3 | |||
| ) |
Return a Piecewise<D2<SBasis> > which points in the same direction as V_in, but has unit_length.
- Parameters:
-
V_in the original path. tol the maximum error allowed. order the maximum degree to use for approximation
unitVector(x,y) is computed as (b,-a) where a and b are solutions of: ax+by=0 (eqn1) and a^2+b^2=1 (eqn2)
Definition at line 301 of file sbasis-geometric.cpp.
References Geom::Piecewise< T >::concat(), cutAtRoots(), Geom::Piecewise< T >::cuts, Barcode::Code39Ext::i, org::w3c::dom::svg::result, Geom::Piecewise< T >::segs, Geom::Piecewise< T >::setDomain(), Geom::Piecewise< T >::size(), and unitVector().
{
Piecewise<D2<SBasis> > result;
Piecewise<D2<SBasis> > VV = cutAtRoots(V);
result.cuts.push_back(VV.cuts.front());
for (unsigned i=0; i<VV.size(); i++){
Piecewise<D2<SBasis> > unit_seg;
unit_seg = unitVector(VV.segs[i],tol, order);
unit_seg.setDomain(Interval(VV.cuts[i],VV.cuts[i+1]));
result.concat(unit_seg);
}
return result;
}
| Piecewise< D2< SBasis > > Geom::unitVector | ( | D2< SBasis > const & | V_in, | |
| double | tol = .01, |
|||
| unsigned | order = 3 | |||
| ) |
Return a Piecewise<D2<SBasis> > which points in the same direction as V_in, but has unit_length.
- Parameters:
-
V_in the original path. tol the maximum error allowed. order the maximum degree to use for approximation
unitVector(x,y) is computed as (b,-a) where a and b are solutions of: ax+by=0 (eqn1) and a^2+b^2=1 (eqn2)
Definition at line 223 of file sbasis-geometric.cpp.
References org::w3c::dom::svg::a, Geom::SBasis::at(), Geom::Linear::at0(), Geom::D2< T >::at0(), Geom::Linear::at1(), Geom::D2< T >::at1(), b, compose(), Geom::Piecewise< T >::concat(), dot(), max, max(), RescaleForNonVanishingEnds(), org::w3c::dom::svg::result, Geom::Piecewise< T >::setDomain(), Geom::SBasis::size(), Geom::SBasis::tailError(), unit_vector(), voronoi::x, and voronoi::y.
Referenced by curvature(), Inkscape::LivePathEffect::LPEOffset::doEffect_pwd2(), Inkscape::LivePathEffect::LPEDynastroke::doEffect_pwd2(), and unitVector().
{
//TODO: Handle vanishing vectors...
// -This approach is numerically bad. Find a stable way to rescale V_in to have non vanishing ends.
// -This done, unitVector will have jumps at zeros: fill the gaps with arcs of circles.
D2<SBasis> V = RescaleForNonVanishingEnds(V_in);
if (V[0].empty() && V[1].empty())
return Piecewise<D2<SBasis> >(D2<SBasis>(Linear(1),SBasis()));
SBasis x = V[0], y = V[1];
SBasis r_eqn1, r_eqn2;
Point v0 = unit_vector(V.at0());
Point v1 = unit_vector(V.at1());
SBasis a = SBasis(order+1, Linear(0.));
a[0] = Linear(-v0[1],-v1[1]);
SBasis b = SBasis(order+1, Linear(0.));
b[0] = Linear( v0[0], v1[0]);
r_eqn1 = -(a*x+b*y);
r_eqn2 = Linear(1.)-(a*a+b*b);
for (unsigned k=1; k<=order; k++){
double r0 = (k<r_eqn1.size())? r_eqn1.at(k).at0() : 0;
double r1 = (k<r_eqn1.size())? r_eqn1.at(k).at1() : 0;
double rr0 = (k<r_eqn2.size())? r_eqn2.at(k).at0() : 0;
double rr1 = (k<r_eqn2.size())? r_eqn2.at(k).at1() : 0;
double a0,a1,b0,b1;// coeffs in a[k] and b[k]
//the equations to solve at this point are:
// a0*x(0)+b0*y(0)=r0 & 2*a0*a(0)+2*b0*b(0)=rr0
//and
// a1*x(1)+b1*y(1)=r1 & 2*a1*a(1)+2*b1*b(1)=rr1
a0 = r0/dot(v0,V.at0())*v0[0]-rr0/2*v0[1];
b0 = r0/dot(v0,V.at0())*v0[1]+rr0/2*v0[0];
a1 = r1/dot(v1,V.at1())*v1[0]-rr1/2*v1[1];
b1 = r1/dot(v1,V.at1())*v1[1]+rr1/2*v1[0];
a[k] = Linear(a0,a1);
b[k] = Linear(b0,b1);
//TODO: use "incremental" rather than explicit formulas.
r_eqn1 = -(a*x+b*y);
r_eqn2 = Linear(1)-(a*a+b*b);
}
//our candidate is:
D2<SBasis> unitV;
unitV[0] = b;
unitV[1] = -a;
//is it good?
double rel_tol = std::max(1.,std::max(V_in[0].tailError(0),V_in[1].tailError(0)))*tol;
if (r_eqn1.tailError(order)>rel_tol || r_eqn2.tailError(order)>tol){
//if not: subdivide and concat results.
Piecewise<D2<SBasis> > unitV0, unitV1;
unitV0 = unitVector(compose(V,Linear(0,.5)),tol,order);
unitV1 = unitVector(compose(V,Linear(.5,1)),tol,order);
unitV0.setDomain(Interval(0.,.5));
unitV1.setDomain(Interval(.5,1.));
unitV0.concat(unitV1);
return(unitV0);
}else{
//if yes: return it as pw.
Piecewise<D2<SBasis> > result;
result=(Piecewise<D2<SBasis> >)unitV;
return result;
}
}
| static int Geom::upper_level | ( | vector< double > const & | levels, | |
| double | x, | |||
| double | tol = 0. | |||
| ) | [static] |
Definition at line 174 of file sbasis-roots.cpp.
Referenced by multi_roots_internal().
{
return(upper_bound(levels.begin(),levels.end(),x-tol)-levels.begin());
}
| unsigned Geom::valuation | ( | SBasis const & | a, | |
| double | tol = 0 | |||
| ) | [inline] |
Returns the degree of the first non zero coefficient.
- Parameters:
-
a sbasis function tol largest abs val considered 0
- Returns:
- first non zero coefficient
Definition at line 318 of file sbasis.h.
References tol, and dxf_input::val.
| unsigned Geom::wangs_theorem | ( | OldBezier | a | ) |
Definition at line 320 of file recursive-bezier-intersection.cpp.
References INV_EPS, Lmax(), log4(), max(), and Geom::OldBezier::p.
Referenced by find_intersections_bezier_recursive().
{
return 6; // seems a good approximation!
double la1 = Lmax( ( a.p[2] - a.p[1] ) - (a.p[1] - a.p[0]) );
double la2 = Lmax( ( a.p[3] - a.p[2] ) - (a.p[2] - a.p[1]) );
double l0 = std::max(la1, la2);
unsigned ra;
if( l0 * 0.75 * M_SQRT2 + 1.0 == 1.0 )
ra = 0;
else
ra = (unsigned)ceil( log4( M_SQRT2 * 6.0 / 8.0 * INV_EPS * l0 ) );
//std::cout << ra << std::endl;
return ra;
}
This function computes the winding of the path, given a reference point.
Positive values correspond to counter-clockwise in the mathematical coordinate system, and clockwise in screen coordinates. This particular implementation casts a ray in the positive x direction. It iterates the path, checking for intersection with the bounding boxes. If an intersection is found, the initial/final Y value of the curve is used to derive a delta on the winding value. If the point is within the bounding box, the curve specific winding function is called.
Referenced by contains(), inner_winding(), and paths_winding().
Variable Documentation
| const double Geom::BEPSILON = ldexp(1.0,(-MAXDEPTH-1)) |
Definition at line 18 of file solve-bezier-one-d.cpp.
Referenced by control_poly_flat_enough(), and Geom::Bernsteins::control_poly_flat_enough().
| const Coord Geom::EPSILON = 1e-5 |
Definition at line 49 of file coord.h.
Referenced by Inkscape::UI::bezier_length(), and cubic_bbox().
| const double Geom::INV_EPS = (1L<<14) |
Definition at line 75 of file recursive-bezier-intersection.cpp.
Referenced by wangs_theorem().
| const unsigned Geom::MAXDEPTH = 23 |
Definition at line 16 of file solve-bezier-one-d.cpp.
Referenced by Geom::Bernsteins::find_bernstein_roots().
| const double Geom::SECANT_EPSILON = 1e-13 |
Definition at line 19 of file solve-bezier-one-d.cpp.
| unsigned Geom::total_steps |
Definition at line 35 of file solve-bezier-parametric.cpp.
| unsigned Geom::total_subs |
Definition at line 35 of file solve-bezier-parametric.cpp.
Point const Geom::unconstrained_tangent(0, 0) [static] |
