🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.misc
Article #107

Re: ¿IRREGULAR AREA?

#107
From: Rich Pasco
Date: Tue, 20 Oct 1998 00:00
27 lines
1842 bytes
[Please note that cross-posting is a breach of netiquette.  You should
ask your question in just one, most-relevant, newsgroup.]

Arnaud Fietzke <arnaud.fietzke@provi.de> wrote

> How can i find out wether a point is in an irregular area?  I'm making an
> object which has an irregular area and it must determine if it was clicked
> by the mouse.

If you define the area as a polygon, then the point is "in" the area
if it is on the correct side of each of the sides of the polygon, e.g.

FUNCTION inside(x,y): BOOLEAN;
  BEGIN
    inside = (a*x + b*y < c) AND
             (d*x + e*y > d) AND
             (f*x + g*y < h) AND ...
  END;

The example above has three sides (a triangle).

You can get fancy and allow a polygon to have an arbitrary number of
sides by building a linked-list (or array) of "side descriptors" and a
procedure which steps through the list, checking against each side,
rejecting if it finds any that fail, declaring success if all succeed.

     - Rich
Technical Details
Message-ID: <362C91A2.7F40@best.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <70g4og$cp2$1@news.hamburg.pop.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10c950,b2af222be2a1216e
X-Google-Attributes: gid10c950,public
X-Google-Thread: 111659,b2af222be2a1216e
X-Google-Attributes: gid111659,public
X-Google-Thread: 10261c,b2af222be2a1216e
X-Google-Attributes: gid10261c,public
X-Google-Thread: 108ebd,b2af222be2a1216e
X-Google-Attributes: gid108ebd,public
From: Rich Pasco <pasco@best.com>
Subject: Re: ¿IRREGULAR AREA?
Date: 1998/10/20
Message-ID: <362C91A2.7F40@best.com>
X-Deja-AN: 403198564
Content-Transfer-Encoding: 7bit
References: <70g4og$cp2$1@news.hamburg.pop.de>
Content-Type: text/plain; charset=us-ascii
X-Trace: 908894135 12419 (none) 209.157.114.250
MIME-Version: 1.0
Newsgroups: comp.lang.pascal.misc,borland.public.turbopascal,comp.lang.pascal.ansi-iso,comp.lang.pascal.borland