Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Never ascribe to malice that which is caused by greed and ignorance." -- Cal Keegan


devel / comp.lang.postscript / The intersect function

SubjectAuthor
o The intersect functionluser droog

1
The intersect function

<2ce10882-a3bb-44da-b921-30a41b2492d7n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=131&group=comp.lang.postscript#131

  copy link   Newsgroups: comp.lang.postscript
X-Received: by 2002:a37:9d4e:: with SMTP id g75mr6834775qke.747.1643046347309;
Mon, 24 Jan 2022 09:45:47 -0800 (PST)
X-Received: by 2002:aca:bd04:: with SMTP id n4mr2454912oif.142.1643046347078;
Mon, 24 Jan 2022 09:45:47 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.postscript
Date: Mon, 24 Jan 2022 09:45:46 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=97.87.183.68; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
NNTP-Posting-Host: 97.87.183.68
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2ce10882-a3bb-44da-b921-30a41b2492d7n@googlegroups.com>
Subject: The intersect function
From: luser.droog@gmail.com (luser droog)
Injection-Date: Mon, 24 Jan 2022 17:45:47 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 20
 by: luser droog - Mon, 24 Jan 2022 17:45 UTC

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 }

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor