ASPL User Guide v 1.00
© 2025 Bassem W. Jamaleddine


22. 2
   GEO Random Polygons in Two 2D Planes

 

Find the intersecting polygons in two 2D planes

ELEMENTS-GROUPING-CLASS: GEOPLANES

Sample workspace: POLY2PLANES

GG-function: ggRPI2Pov()

geometric set intersection

      f& P1 P2       where P1 P2 are set variables

geometric set difference

      f\ P1 P2

GEO Random Polygons in Two 2D Planes

●  GEO Random Polygons in Two 2D Planes

The element-grouping-class GEOPLANES contains the metadata describing the coordinates of polygons to be drawn in 2D planes. The sample workspace POLY2PLANES has the grouping class GEOPLANES. ASPL will treat the set operations f& and f\ as geometric set operations on the set variables of POLY2PLANES.

 

GEO Random Polygons in Two 2D Planes

The sample workspace POLY2PLANES shows how to use ASPL operators to do contextual set operations on geometric data. This workspace's element grouping class is GEOPLANES, therefore ASPL switches the set operators f& and f\ to do contextual set intersection and set difference according to contextual routines, here they are the GEOmetric routines.

In this example we will call the GG function ggRPI2Pov() to create 90 random polygons, namely triangles, in two 2D planes. The result is assigned to P12_90, and the labeling of the planes are P1 and P2. We also supply an optional named file (nmfl) using the same name as the variable P12_90 to have the function emit the code to draw P12_90.

 

GEO Random Polygons in Two 2D Planes

On the UNIX prompt start ASPL by loading the sample workspace POLY2PLANES:

aspl -wsname POLY2PLANES -groupingclass GEOPLANES

At the ASPL prompt issue the following commands:

①  aspl> ks x1 y1 x2 y2 x3 y3
    (set the ks vector to shorten the displayed data)

②  aspl> P12_90 = ggRPI2Pov(N,90,glb1,P1,glb2,P2,nmfl,P12_90)
    (get random polygons in two 2D planes also generate named data in ~tmp)

③  aspl> split P12_90 into P1 P2
    (split the variable P12_90 for the two planes)

④  aspl> f& P1 P2
    (intersect the two planes)

⑤  aspl> f\ P1 P2
    (get the difference between 1st plane and the 2nd plane, the result is pushed on the stack)

⑥  aspl> f\ P2 P1
    (get the difference between 2nd plane and the 1st plane, the result is pushed on the stack)

⑦  aspl> ans
    (print the answer stack)

⑧  aspl> pop P2_1
    (pop the stack result into variable P2_1 as the difference f\ P2 P1)

⑨  aspl> pop P1_2
    (pop the stack result into variable P1_2 as the difference f\ P1 P2)

⑩  aspl> pop P12
    (pop the stack result into variable P12 as the intersection f& P1 P2)

⑪  aspl> ans
    (print the answer stack)

⑫  aspl> v
    (print the symbol table)

⑬  aspl> dumpgad P12;dumpgad P1_2;dumpgad P2_1;aspl> dumpgad P12_90
    (dump GADg of P12 P1_2 P2_1 P12_90 writing them to files in ~tmp directory)

This example is shown in the following terminal.

viewme

 -TC- Display. 22.2.1   [RANDOM POLYGONS IN TWO 2D PLANES]
Terminal showing RANDOM POLYGONS IN TWO 2D PLANES

The processing of 90 random triangles in each 2D plane result in 180 triangles total in both planes.

To draw the data, at the UNIX prompt, change to your ASPL ~tmp directory, and invoke the script drawgeogad on the dumped GAD data:

cd `asplcmd ~tmp`
    shortcut command to change to your ASPL's tmp directory

drawgeogad P1_2-gad-aspl.tobj
    Generate the drawing data from the GADg for f\ P1 P2

drawgeogad P2_1-gad-aspl.tobj
    Generate the drawing data from the GADg for f\ P2 P1

drawgeogad P12-gad-aspl.tobj
    Generate the drawing data from the GADg for f& P1 P2

The following figures show the various graphical results of the geometric set operations performed on the random triangles in the two 2D planes.

THE FOLLOWING ARE THE DRAWING COMMANDS USED TO CAPTURE THE FIGURES:

gpdata3 P12_90_o1.dat,1:2wlp P12_90_o1.dat,1:2wp P12_90_o2.dat,1:2wlp P12_90_o2.dat,1:2wp -title "ASPL GEO-INTERSECTION SHOWING THE OVERLAPPING TRIANGLES IN TWO 2D PLANES"

gpdata3 P12_90_1.dat,1:2wl P12_90_o1.dat,1:2wp P12_90_2.dat,1:2wl P12_90_o2.dat,1:2wp -title "RANDOM TRIANGLES IN TWO 2D PLANES"

gpdata3 P1_2_P1.dat,1:2wl P2_1_P2.dat,1:2wl-rgb-blue P12_90_o1.dat,1:2wl-rgb-green P12_90_o2.dat,1:2wl-rgb-yellow -title "RANDOM TRIANGLES AND THEIR INTERSECTIONS HIGHLIGHTED"

gpdata3 P12_90_1.dat,1:2wl-rgb-red P12_90_2.dat,1:2wl-rgb-blue P12_90_o1.dat,1:2wp-ot-4-ps-1.7-rgb-red P12_90_o2.dat,1:2wp-pt-4-ps-1.7-rgb-blue -title "ASPL GEO-INTERSECTION CONTRASTED WITH SQUARE POINTS FOR THE RANDOM TRIANGLES OVERLAPPING IN THE TWO 2D PLANES"

gpdata3 P1_2_P1.dat,1:2wl P2_1_P2.dat,1:2wl-rgb-blue P12_90_o1.dat,1:2wl-rgb-green P12_90_o2.dat,1:2wl-rgb-yellow -title "RANDOM TRIANGLES AND THEIR INTERSECTIONS HIGHLIGHTED"

gpdata3 P1_2_P1.dat,1:2wl P2_1_P2.dat,1:2wl-rgb-blue -title "DISJOINTNESS OF THE TWO PLANES -- EXCLUDING THE INTERSECTING TRIANGLES"

gpdata3 P1_2_P1.dat,1:2wl P2_1_P2.dat,1:2wl-rgb-blue -title "ASPL GEO-DIFFERENCE SHOWING THE DISJOINTNESS OF THE TWO PLANES -- EXCLUDING THE INTERSECTING TRIANGLES"

gpdata3 P12_90_1.dat,1:2wl P12_90_o1.dat,1:2wp -every wp ::0::3 P12_90_2.dat,1:2wl P12_90_o2.dat,1:2wp -every wp ::0::3 -title "RANDOM TRIANGLES IN TWO 2D PLANES SHOWING THE OVERLAPPING TRIANGLES"

gpdata3 P12_90_1.dat,1:2wl P12_90_o1.dat,1:2wp P12_90_2.dat,1:2wl P12_90_o2.dat,1:2wp -title "RANDOM TRIANGLES IN TWO 2D PLANES SHOWING THEIR OVERLAPPING TRIANGLES"

gpdata3 P12_90_1.dat,1:2wl P12_90_o1.dat,1:2wp -every wp ::0::3 P12_90_2.dat,1:2wl P12_90_o2.dat,1:2wp -every wp ::0::3 -title "RANDOM TRIANGLES IN TWO 2D PLANES SHOWING THEIR OVERLAPPING TRIANGLES"

full view

Image File

 -FG- Fig. 22.2.1   [Figure RANDOM TRIANGLES IN TWO 2D PLANES]
ASPL (C) 2025 Bassem Jamaleddine

The following figure shows the random triangles intersection processed through ASPL f& P1 P2 command:

full view

Image File

 -FG- Fig. 22.2.2   [Figure ASPL GEO-INTERSECTION FOR RANDOM TRIANGLES WITH HIGHLIGHTED OVERLAPPING TRIANGLES IN THE TWO 2D PLANES]
ASPL (C) 2025 Bassem Jamaleddine

The following figure shows the random triangles along their intersection (that is the overlapping polygons):

full view

Image File

 -FG- Fig. 22.2.3   [Figure ASPL GEO-INTERSECTION CONTRASTED WITH SQUARE POINTS FOR THE RANDOM TRIANGLES OVERLAPPING IN THE TWO 2D PLANES]
ASPL (C) 2025 Bassem Jamaleddine

The following figure shows the random triangles along their intersection (that is the overlapping polygons):

full view

Image File

 -FG- Fig. 22.2.4   [Figure ASPL GEO-INTERSECTION FOR RANDOM TRIANGLES WITH HIGHLIGHTED OVERLAPPING TRIANGLES IN THE TWO 2D PLANES]
ASPL (C) 2025 Bassem Jamaleddine

The following figure shows the random triangles union of their differences derived from ASPL ASPL f\ P1 P2 and f\ P2 P1 commands:

full view

Image File

 -FG- Fig. 22.2.5   [Figure ASPL GEO-DIFFERENCE SHOWING THE DISJOINTNESS OF THE TWO PLANES -- EXCLUDING THE INTERSECTING TRIANGLES]
ASPL (C) 2025 Bassem Jamaleddine