Fonctions et opérateurs géométriques

Les types géométriques point, box, lseg, line, path, polygon, et circle possèdent un ensemble important de fonctions natives.

Table 18. Opérateurs géométriques

OpérateurDescriptionUtilisation
+ Translationbox '((0,0),(1,1))' + point '(2.0,0)'
- Translationbox '((0,0),(1,1))' - point '(2.0,0)'
* Scaling/rotationbox '((0,0),(1,1))' * point '(2.0,0)'
/ Scaling/rotationbox '((0,0),(2,2))' / point '(2.0,0)'
# Intersection'((1,-1),(-1,1))' # '((1,1),(-1,-1))'
# Number of points in polygon# '((1,0),(0,1),(-1,0))'
## Point of closest proximitypoint '(0,0)' ## lseg '((2,0),(0,2))'
&& Overlaps?box '((0,0),(1,1))' && box '((0,0),(2,2))'
&< Overlaps to left?box '((0,0),(1,1))' &< box '((0,0),(2,2))'
&> Overlaps to right?box '((0,0),(3,3))' &> box '((0,0),(2,2))'
<-> Distance betweencircle '((0,0),1)' <-> circle '((5,0),1)'
<< Left of?circle '((0,0),1)' << circle '((5,0),1)'
<^ Is below?circle '((0,0),1)' <^ circle '((0,5),1)'
>> Is right of?circle '((5,0),1)' >> circle '((0,0),1)'
>^ Is above?circle '((0,5),1)' >^ circle '((0,0),1)'
?# Intersects or overlapslseg '((-1,0),(1,0))' ?# box '((-2,-2),(2,2))'
?- Is horizontal?point '(1,0)' ?- point '(0,0)'
?-| Is perpendicular?lseg '((0,0),(0,1))' ?-| lseg '((0,0),(1,0))'
@-@ Length or circumference@-@ path '((0,0),(1,0))'
?| Is vertical?point '(0,1)' ?| point '(0,0)'
?|| Is parallel?lseg '((-1,0),(1,0))' ?|| lseg '((-1,2),(1,2))'
@ Contained or onpoint '(1,1)' @ circle '((0,0),2)'
@@ Center of@@ circle '((0,0),10)'
~= Same aspolygon '((0,0),(1,1))' ~= polygon '((1,1),(0,0))'

Table 19. Fonctions géométriques

FonctionRetourDescriptionExemple
area(object)double precisionarea of itemarea(box '((0,0),(1,1))')
box(box, box)boxintersection boxbox(box '((0,0),(1,1))',box '((0.5,0.5),(2,2))')
center(object)pointcenter of itemcenter(box '((0,0),(1,2))')
diameter(circle)double precisiondiameter of circlediameter(circle '((0,0),2.0)')
height(box)double precisionvertical size of boxheight(box '((0,0),(1,1))')
isclosed(path)booleana closed path?isclosed(path '((0,0),(1,1),(2,0))')
isopen(path)booleanan open path?isopen(path '[(0,0),(1,1),(2,0)]')
length(object)double precisionlength of itemlength(path '((-1,0),(1,0))')
pclose(path)pathconvert path to closedpopen(path '[(0,0),(1,1),(2,0)]')
npoint(path)integernumber of pointsnpoints(path '[(0,0),(1,1),(2,0)]')
popen(path)pathconvert path to open pathpopen(path '((0,0),(1,1),(2,0))')
radius(circle)double precisionradius of circleradius(circle '((0,0),2.0)')
width(box)double precisionhorizontal sizewidth(box '((0,0),(1,1))')

Table 20. Fonctions de conversion de type géométrique

FonctionRetourDescriptionExemple
box(circle)boxcircle to boxbox(circle '((0,0),2.0)')
box(point, point)boxpoints to boxbox(point '(0,0)', point '(1,1)')
box(polygon)boxpolygon to boxbox(polygon '((0,0),(1,1),(2,0))')
circle(box)circleto circlecircle(box '((0,0),(1,1))')
circle(point, double precision)circlepoint to circlecircle(point '(0,0)', 2.0)
lseg(box)lsegbox diagonal to lseglseg(box '((-1,0),(1,0))')
lseg(point, point)lsegpoints to lseglseg(point '(-1,0)', point '(1,0)')
path(polygon)pointpolygon to pathpath(polygon '((0,0),(1,1),(2,0))')
point(circle)pointcenterpoint(circle '((0,0),2.0)')
point(lseg, lseg)pointintersectionpoint(lseg '((-1,0),(1,0))', lseg '((-2,-2),(2,2))')
point(polygon)pointcenterpoint(polygon '((0,0),(1,1),(2,0))')
polygon(box)polygon12 point polygonpolygon(box '((0,0),(1,1))')
polygon(circle)polygon12-point polygonpolygon(circle '((0,0),2.0)')
polygon(npts, circle)polygonnpts polygonpolygon(12, circle '((0,0),2.0)')
polygon(path)polygonpath to polygonpolygon(path '((0,0),(1,1),(2,0))')