~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/2geom/curve.h

  • Committer: Ted Gould
  • Date: 2008-11-21 05:24:08 UTC
  • Revision ID: ted@canonical.com-20081121052408-tilucis2pjrrpzxx
MergeĀ fromĀ fe-moved

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
 
75
75
  virtual Curve *duplicate() const = 0;
76
76
 
77
 
  virtual Rect boundsFast() const = 0;
78
 
  virtual Rect boundsExact() const = 0;
79
 
  virtual Rect boundsLocal(Interval i, unsigned deg) const = 0;
80
 
  Rect boundsLocal(Interval i) const { return boundsLocal(i, 0); }
 
77
  virtual OptRect boundsFast() const = 0;
 
78
  virtual OptRect boundsExact() const = 0;
 
79
  virtual OptRect boundsLocal(OptInterval i, unsigned deg) const = 0;
 
80
  OptRect boundsLocal(OptInterval i) const { return boundsLocal(i, 0); }
81
81
 
82
82
  virtual std::vector<double> roots(double v, Dim2 d) const = 0;
83
83
 
133
133
   */
134
134
  virtual Point unitTangentAt(Coord t, unsigned n = 3) const
135
135
  {
136
 
    for (unsigned deriv_n = 1; deriv_n <= n; deriv_n++) {
137
 
      Point deriv = pointAndDerivatives(t, deriv_n)[deriv_n];
138
 
      Coord length = deriv.length();
 
136
        std::vector<Point> derivs = pointAndDerivatives(t, n);
 
137
        for (unsigned deriv_n = 1; deriv_n < derivs.size(); deriv_n++) {
 
138
      Coord length = derivs[deriv_n].length();
139
139
      if ( ! are_near(length, 0) ) {
140
140
         // length of derivative is non-zero, so return unit vector
141
 
         return deriv / length;
 
141
          derivs[deriv_n] / length;
142
142
      }
143
143
    }
144
144
    return Point (0,0);