## 9.11. 几何函数和操作符

`geometric_type` `+` `point``geometric_type`

`box '(1,1),(0,0)' + point '(2,0)'``(3,1),(2,0)`

`path` `+` `path``path`

`path '[(0,0),(1,1)]' + path '[(2,2),(3,3),(4,4)]'``[(0,0),(1,1),(2,2),(3,3),(4,4)]`

`geometric_type` `-` `point``geometric_type`

`box '(1,1),(0,0)' - point '(2,0)'``(-1,1),(-2,0)`

`geometric_type` `*` `point``geometric_type`

`path '((0,0),(1,0),(1,1))' * point '(3.0,0)'``((0,0),(3,0),(3,3))`

`path '((0,0),(1,0),(1,1))' * point(cosd(45), sind(45))``((0,0),​(0.7071067811865475,0.7071067811865475),​(0,1.414213562373095))`

`geometric_type` `/` `point``geometric_type`

`path '((0,0),(1,0),(1,1))' / point '(2.0,0)'``((0,0),(0.5,0),(0.5,0.5))`

`path '((0,0),(1,0),(1,1))' / point(cosd(45), sind(45))``((0,0),​(0.7071067811865476,-0.7071067811865476),​(1.4142135623730951,0))`

`@-@` `geometric_type``double precision`

`@-@ path '[(0,0),(1,0),(1,1)]'``2`

`@@` `geometric_type``point`

`@@ box '(2,2),(0,0)'``(1,1)`

`#` `geometric_type``integer`

`# path '((1,0),(0,1),(-1,0))'``3`

`geometric_type` `#` `geometric_type``point`

`lseg '[(0,0),(1,1)]' # lseg '[(1,0),(0,1)]'``(0.5,0.5)`

`box` `#` `box``box`

`box '(2,2),(-1,-1)' # box '(1,1),(-2,-2)'``(1,1),(-1,-1)`

`geometric_type` `##` `geometric_type``point`

`point '(0,0)' ## lseg '[(2,0),(0,2)]'``(1,1)`

`geometric_type` `<->` `geometric_type``double precision`

`circle '<(0,0),1>' <-> circle '<(5,0),1>'``3`

`geometric_type` `@>` `geometric_type``boolean`

`circle '<(0,0),2>' @> point '(1,1)'``t`

`geometric_type` `<@` `geometric_type``boolean`

`point '(1,1)' <@ circle '<(0,0),2>'``t`

`geometric_type` `&&` `geometric_type``boolean`

`box '(1,1),(0,0)' && box '(2,2),(0,0)'``t`

`geometric_type` `<<` `geometric_type``boolean`

`circle '<(0,0),1>' << circle '<(5,0),1>'``t`

`geometric_type` `>>` `geometric_type``boolean`

`circle '<(5,0),1>' >> circle '<(0,0),1>'``t`

`geometric_type` `&<` `geometric_type``boolean`

`box '(1,1),(0,0)' &< box '(2,2),(0,0)'``t`

`geometric_type` `&>` `geometric_type``boolean`

`box '(3,3),(0,0)' &> box '(2,2),(0,0)'``t`

`geometric_type` `<<|` `geometric_type``boolean`

`box '(3,3),(0,0)' <<| box '(5,5),(3,4)'``t`

`geometric_type` `|>>` `geometric_type``boolean`

`box '(5,5),(3,4)' |>> box '(3,3),(0,0)'``t`

`geometric_type` `&<|` `geometric_type``boolean`

`box '(1,1),(0,0)' &<| box '(2,2),(0,0)'``t`

`geometric_type` `|&>` `geometric_type``boolean`

`box '(3,3),(0,0)' |&> box '(2,2),(0,0)'``t`

`box` `<^` `box``boolean`

`box '((1,1),(0,0))' <^ box '((2,2),(1,1))'``t`

`box` `>^` `box``boolean`

`box '((2,2),(1,1))' >^ box '((1,1),(0,0))'``t`

`geometric_type` `?#` `geometric_type``boolean`

`lseg '[(-1,0),(1,0)]' ?# box '(2,2),(-2,-2)'``t`

`?-` `line``boolean`

`?-` `lseg``boolean`

`?- lseg '[(-1,0),(1,0)]'``t`

`point` `?-` `point``boolean`

`point '(1,0)' ?- point '(0,0)'``t`

`?|` `line``boolean`

`?|` `lseg``boolean`

`?| lseg '[(-1,0),(1,0)]'``f`

`point` `?|` `point``boolean`

`point '(0,1)' ?| point '(0,0)'``t`

`line` `?-|` `line``boolean`

`lseg` `?-|` `lseg``boolean`

`lseg '[(0,0),(0,1)]' ?-| lseg '[(0,0),(1,0)]'``t`

`line` `?||` `line``boolean`

`lseg` `?||` `lseg``boolean`

`lseg '[(-1,0),(1,0)]' ?|| lseg '[(-1,2),(1,2)]'``t`

`geometric_type` `~=` `geometric_type``boolean`

`polygon '((0,0),(1,1))' ~= polygon '((1,1),(0,0))'``t`

[a] Rotating 用这些操作符“旋转”一个盒子，只会移动它的角点:这个盒子仍然被认为有平行于轴的边。 因此，盒子的大小并没有像真正的旋转那样得到保留。

### 注意

PostgreSQL14之前， 该点严格低于/高于比较操作符 `point` `<<|` `point``point` `|>>` `point` 分别被称为 `<^``>^`。 这些名字仍然可以使用，但是已被弃用并且最终将被移除。

`area` ( `geometric_type` ) → `double precision`

`area(box '(2,2),(0,0)')``4`

`center` ( `geometric_type` ) → `point`

`center(box '(1,2),(0,0)')``(0.5,1)`

`diagonal` ( `box` ) → `lseg`

`diagonal(box '(1,2),(0,0)')``[(1,2),(0,0)]`

`diameter` ( `circle` ) → `double precision`

`diameter(circle '<(0,0),2>')``4`

`height` ( `box` ) → `double precision`

`height(box '(1,2),(0,0)')``2`

`isclosed` ( `path` ) → `boolean`

`isclosed(path '((0,0),(1,1),(2,0))')``t`

`isopen` ( `path` ) → `boolean`

`isopen(path '[(0,0),(1,1),(2,0)]')``t`

`length` ( `geometric_type` ) → `double precision`

`length(path '((-1,0),(1,0))')``4`

`npoints` ( `geometric_type` ) → `integer`

`npoints(path '[(0,0),(1,1),(2,0)]')``3`

`pclose` ( `path` ) → `path`

`pclose(path '[(0,0),(1,1),(2,0)]')``((0,0),(1,1),(2,0))`

`popen` ( `path` ) → `path`

`popen(path '((0,0),(1,1),(2,0))')``[(0,0),(1,1),(2,0)]`

`radius` ( `circle` ) → `double precision`

`radius(circle '<(0,0),2>')``2`

`slope` ( `point`, `point` ) → `double precision`

`slope(point '(0,0)', point '(2,1)')``0.5`

`width` ( `box` ) → `double precision`

`width(box '(1,2),(0,0)')``1`

`box` ( `circle` ) → `box`

`box(circle '<(0,0),2>')``(1.414213562373095,1.414213562373095),​(-1.414213562373095,-1.414213562373095)`

`box` ( `point` ) → `box`

`box(point '(1,0)')``(1,0),(1,0)`

`box` ( `point`, `point` ) → `box`

`box(point '(0,1)', point '(1,0)')``(1,1),(0,0)`

`box` ( `polygon` ) → `box`

`box(polygon '((0,0),(1,1),(2,0))')``(2,1),(0,0)`

`bound_box` ( `box`, `box` ) → `box`

`bound_box(box '(1,1),(0,0)', box '(4,4),(3,3)')``(4,4),(0,0)`

`circle` ( `box` ) → `circle`

`circle(box '(1,1),(0,0)')``<(0.5,0.5),0.7071067811865476>`

`circle` ( `point`, `double precision` ) → `circle`

`circle(point '(0,0)', 2.0)``<(0,0),2>`

`circle` ( `polygon` ) → `circle`

`circle(polygon '((0,0),(1,3),(2,0))')``<(1,1),1.6094757082487299>`

`line` ( `point`, `point` ) → `line`

`line(point '(-1,0)', point '(1,0)')``{0,-1,0}`

`lseg` ( `box` ) → `lseg`

`lseg(box '(1,0),(-1,0)')``[(1,0),(-1,0)]`

`lseg` ( `point`, `point` ) → `lseg`

`lseg(point '(-1,0)', point '(1,0)')``[(-1,0),(1,0)]`

`path` ( `polygon` ) → `path`

`path(polygon '((0,0),(1,1),(2,0))')``((0,0),(1,1),(2,0))`

`point` ( `double precision`, `double precision` ) → `point`

`point(23.4, -44.5)``(23.4,-44.5)`

`point` ( `box` ) → `point`

`point(box '(1,0),(-1,0)')``(0,0)`

`point` ( `circle` ) → `point`

`point(circle '<(0,0),2>')``(0,0)`

`point` ( `lseg` ) → `point`

`point(lseg '[(-1,0),(1,0)]')``(0,0)`

`point` ( `polygon` ) → `point`

`point(polygon '((0,0),(1,1),(2,0))')``(1,0.3333333333333333)`

`polygon` ( `box` ) → `polygon`

`polygon(box '(1,1),(0,0)')``((0,0),(0,1),(1,1),(1,0))`

`polygon` ( `circle` ) → `polygon`

`polygon(circle '<(0,0),2>')``((-2,0),​(-1.7320508075688774,0.9999999999999999),​(-1.0000000000000002,1.7320508075688772),​(-1.2246063538223773e-16,2),​(0.9999999999999996,1.7320508075688774),​(1.732050807568877,1.0000000000000007),​(2,2.4492127076447545e-16),​(1.7320508075688776,-0.9999999999999994),​(1.0000000000000009,-1.7320508075688767),​(3.673819061467132e-16,-2),​(-0.9999999999999987,-1.732050807568878),​(-1.7320508075688767,-1.0000000000000009))`

`polygon` ( `integer`, `circle` ) → `polygon`

`polygon(4, circle '<(3,0),1>')``((2,0),​(3,1),​(4,1.2246063538223773e-16),​(3,-1))`

`polygon` ( `path` ) → `polygon`

`polygon(path '((0,0),(1,1),(2,0))')``((0,0),(1,1),(2,0))`