PostgreSQL diagonal() Function
The PostgreSQL diagonal()
function extracts the diagonal of the specified rectangle and returns it as a line segment.
diagonal()
Syntax
This is the syntax of the PostgreSQL diagonal()
function:
diagonal(box) -> lseg
This function is diagonal(box)
equivalent to the lseg(box)
function.
Parameters
box
-
Required. a rectangle. E.g:
box '(1,1),(-1,-1)'
Return value
The PostgreSQL diagonal()
function returns a line segment, which is the diagonal of the specified rectangle.
diagonal()
Examples
The following statement shows how to use the PostgreSQL diagonal()
function to return box '(1,1),(-1,-1)'
the diagonal of a rectangle.
SELECT diagonal(box '(1,1),(-1,-1)');
diagonal
-----------------
[(1,1),(-1,-1)]
This statement is equivalent to the following statement using the lseg()
function:
SELECT lseg(box '(1,1),(-1,-1)');
diagonal
-----------------
[(1,1),(-1,-1)]