From: Nathan H. <nj...@nj...> - 2012-09-30 22:52:56
|
On Sun, Sep 30, 2012 at 05:12:27PM -0500, Susan Spencer wrote: > Hi developers, > > Here are some examples of current output using > the tmtp library <https://github.com/sconklin/tmtp.git> for pattern design. > > https://docs.google.com/open?id=0BxsnjDIHW4yvNGZEMGlNSGpzblk > https://docs.google.com/open?id=0BxsnjDIHW4yvTVFndHIyYnBoZjA > https://docs.google.com/open?id=0BxsnjDIHW4yvck9iMGVVTWFXMFU freaken awesome. I just spent several hours reverse engineering a teeshirt pattern I liked: this would have been very handy! Something I would like is a way of tracing the support lines from body measurements and using them to adjust the pattern. I have no idea how to do this :) > It would improve the tmtp project to replace functions like > pointOnCurveAtLength() and lengthOnCurveAtPoint() > with calls to cy2geom/lib2geom code. > > The data structures are very simple, > a point is a python object with x & y values. > Point A is A.x, A.y, and A.name = 'A' > Curve paths are python lists where a cubic curve P0 c1 c2 P1 > is stored as curve[0],curve[1],curve[2],curve[3] > Longer curves P0 c11 c12 P1 c21 c22 P2 are stored as > curve[0],curve[1],curve[2],curve[3], curve[4],curve[5],curve[6] > where the shared points (eg P1 in example) are not repeated. > > Can anyone give me examples for: > 1.) returning a point at a known length on a curve, There are two ways to go about this, depending on how many points you want. If you just want a single point then you could do it with a root find on length, but if you want it for many values it would be more efficient to use arc_length_parametrization(D2<SBasis> const &M, unsigned order=3, double tol=.01); which returns a new path which 't' is in length. > 2.) returning the length at a known or interpolated point on a > curve, double length(path.portion(0,t)); should do that. > 3.) the point at an intersection of a line and a curve, > 4.) the point at an intersection of two curves 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); will find the intersection of two bezier curves (including lines) > 5.) interpolating a curve. What do you mean by this? the simplest interpolation would be to just Lerp the control points. If you want something like the stretchy rubber mat transforms in the toys/2dsb2d you are actually composing curves. If you want something like path-along-path you are composing with a 2d arc length parameterisation. For patterns I think the solution is somewhere in the middle of these approaches: it's not an affine scaling transform because people aren't all the same shape and you are actually also ensuring that both sides of seam are the same length. I will think about it for a bit. > I have very simple code for these functions in tmtp, > but I need to improve accuracy. Jan is the expert on the cy2geom bindings and I'm sure he'll be able to give example code for these better than me. > Bonus points if anyone can produce an example for Bend Path!!! > I obviously don't have code for this - see the 2nd file in list > above. yeah, I think it's a variant of path-along-path. njh |