• The intersect function

    From luser droog@21:1/5 to All on Mon Jan 24 09:45:46 2022
    I kinda buried the lead in the star drawing program. After years of struggling to write this function in many clumsy ways. Finally, a super short implementation that's truly mind boggling. I only made some syntax changes.

    It takes 4 points `a b c d` (each a 2 element array) and yields
    a 2 element array of the intersection point (a->b)x(c->d). The source
    mentions some cases where the function fails. Presumably this
    is when one of the 3 intermediate matrices is not invertible (like if
    they don't intersect, maybe?).

    % intersect adapted from https://www.ntg.nl/maps/18/23.pdf
    /intersect { aload pop
    1 dict begin {d c b a}{exch def}forall
    1 1
    1 1 [a _x b _x a _y b _y 0 0] itransform % A B
    1 1 [c _x d _x c _y d _y 0 0] itransform % A B C D
    0 0 6 array astore
    itransform 2 array astore
    end }
    /_x { 0 get }
    /_y { 1 get }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)