Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #3435

Re: Snipping the ears

Newsgroups comp.lang.postscript
Date 2019-08-13 16:03 -0700
References (4 earlier) <87blxjdg7o.fsf@ixod.org> <1b955bab-1d49-4739-adf1-88c02606af56@googlegroups.com> <5d20eeef-c249-4765-b5b4-b3dcdceee704@googlegroups.com> <45fef125-5d35-4535-8380-8eab9294e449@googlegroups.com> <098c541d-5c74-40c5-9865-0bd028aee3aa@googlegroups.com>
Message-ID <395bcb26-aab8-46e4-9173-e28c8fc1af98@googlegroups.com> (permalink)
Subject Re: Snipping the ears
From luser droog <luser.droog@gmail.com>

Show all headers | View raw


On Sunday, August 11, 2019 at 3:33:38 PM UTC-5, luser droog wrote:
> On Thursday, August 8, 2019 at 2:22:52 AM UTC-5, luser droog wrote:
> > On Wednesday, August 7, 2019 at 12:05:51 AM UTC-5, luser droog wrote:

> > > At long last I've implemented all of these ideas without errors this time.
> > > And it still makes ears. But I think this is good progress. 
> > > 
> > > I found some code in Don Lancaster's pages to measure the length of a curve. 
> > > I think I can use that to determine if my new offset curve is bigger or 
> > > smaller than the original. And that should tell me whether we're inside or 
> > > outside of a bend. 
> > > 
> > > But a numerical/conceptual problem keeps cropping up. Whenever I try to
> > > run through a series of line segments to get the angular change, I don't
> > > know how to bound the output to be 0-360. My modular arithmetic skills
> > > keep crapping out. Maybe pen and paper are the tool for that too.
> > > This problem of getting a usable figure for angular change is exactly
> > > what I need to solve to find out how "tight" the bend is in the curve.
> > > 
> [snip]
> 
> Using this output was enough to isolate that bad corner. This is the 
> bottom left corner of the '9' where it turns from about 90 degrees
> (North) to about 342 degrees (ENE). I translated and scaled and got
> some smaller numbers, then copied them 3 places in my notebook and
> plotted the points by hand. And then, I found something.
> 
> The shapes of the control polygons of the curves in the input curve
> are all disjoint and "normal". But each of these maps to a strange
> shape and several of them overlap each other. One of them is "twisted"
> where the incoming tangent vector intersects the outgoing one. Two of
> them look like a "thorny triangle", where the vector from the first 
> control point to the second is almost perpendicular to the vector from
> the start point the final point. And one of them is "inverted", where
> the vector from the first control point to the second is much longer
> than the vector from the start point to the final point.
> 
> So, the new strategy is: run through the original curve and the new
> generated curve and discover where a "normal, disjoint" curve maps
> to a "strange, overlapping" curve, and replace sequences of these
> with a new curve built from the incoming tangent vector of the first
> curve and the outgoing tangent of the last curve. Checking for overlap
> is going to be a little painful, so hopefully I can get away with
> just checking for strangeness. This involves computing an intersection
> for the "twisted" case, but for the other cases it's simple vector 
> operations.
> 
> I'm thinking about using a PostScript trick to keep all this data
> organized. I have a path array of subpath arrays of element arrays of 
> coordinates. I can make associations between the element arrays and
> other useful data by making definitions in a dictionary, using the 
> element arrays as keys. Then I can use simple 'forall' loops and load
> associated data back out of the dict, having the element to hand.
> 
> This should help clean up a lot of the crazy loops, I think. I just
> need one crazy loop to collect all of the contextual vectors, then
> just 'forall' loops after that.

Mostly there. Everything works. Ear detection seems to be working just
by checking two vectors from each curve, the "control vector" that goes
from the first control point to the second, and the "transit vector"
that goes straight from the first point to the final point. If the 
control vector is bigger than the transit vector, that's an "inverted
curve" by my definition. And if the angular difference between the 
control vector and the transit vector is more than about 80 degrees,
then that's either a thorny triangle or a twisted curve if it's even
bigger, closer to 180 degrees. 

When drawing an offset curve 10 points away, I get 2 ears which matches
the visual results. At 5 points away, I get this "ear report":

  [(00000000000000011000000000000000000000000) (000000000000000)]

which matches the visual results. At only 2 points away, no ears are 
found, which also looks right.

So, now for the chore of actually snipping the ears. I think the same
PostScript trick of using a dict as an associative array will help.
I can associate each string of the ear report with the subpath array
it belongs to. Then I can use a plain 'forall' loop instead of a weird
'for' loop to access parallel arrays.

I expect to have some pretty output soon. Wish me luck!

droog

Back to comp.lang.postscript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Snipping the ears luser droog <luser.droog@gmail.com> - 2019-07-20 13:18 -0700
  Re: Snipping the ears luser droog <luser.droog@gmail.com> - 2019-07-20 16:51 -0700
    Re: Snipping the ears luser droog <luser.droog@gmail.com> - 2019-07-22 00:47 -0700
      Re: Snipping the ears luser droog <luser.droog@gmail.com> - 2019-07-24 00:38 -0700
        Re: Snipping the ears Mark Carroll <mtbc@bcs.org> - 2019-07-24 08:50 +0100
          Re: Snipping the ears luser droog <luser.droog@gmail.com> - 2019-07-29 23:18 -0700
            Re: Snipping the ears luser droog <luser.droog@gmail.com> - 2019-08-06 22:05 -0700
              Re: Snipping the ears luser droog <luser.droog@gmail.com> - 2019-08-08 00:22 -0700
                Re: Snipping the ears luser droog <luser.droog@gmail.com> - 2019-08-11 13:33 -0700
                Re: Snipping the ears luser droog <luser.droog@gmail.com> - 2019-08-13 16:03 -0700
                Re: Snipping the ears luser droog <luser.droog@gmail.com> - 2019-08-19 22:46 -0700
                Re: Snipping the ears luser droog <luser.droog@gmail.com> - 2019-08-21 23:44 -0700
  Re: Snipping the ears jdaw1 <jdawiseman@gmail.com> - 2019-10-10 15:07 -0700
    Re: Snipping the ears jdaw1 <jdawiseman@gmail.com> - 2019-10-10 15:09 -0700
    Re: Snipping the ears luser droog <luser.droog@gmail.com> - 2019-10-13 01:39 -0700
      Re: Snipping the ears luser droog <luser.droog@gmail.com> - 2019-10-13 01:51 -0700
        Re: Snipping the ears jdaw1 <jdawiseman@gmail.com> - 2020-06-04 03:15 -0700
          Re: Snipping the ears luser droog <luser.droog@gmail.com> - 2020-07-09 10:31 -0700
          Re: Snipping the ears jdaw1 <jdawiseman@gmail.com> - 2021-02-13 09:51 -0800

csiph-web