全部產品
Search
文件中心

ApsaraDB RDS:ST_Affine

更新時間:Feb 28, 2024

對目標Geometry對象執行三維仿射變換,可同時完成平移、旋轉、縮放等操作。

文法

geometry ST_Affine(geometry geomA , float a , float b , float c , float d , float e , float f , float g , float h , float i , float xoff , float yoff , float zoff);
geometry ST_Affine(geometry geomA , float a , float b , float d , float e , float xoff , float yoff);

參數

參數名稱

描述

geomA

目標Geometry對象。

a

仿射變換參數。

b

仿射變換參數。

c

仿射變換參數。

d

仿射變換參數。

e

仿射變換參數。

f

仿射變換參數。

g

仿射變換參數。

h

仿射變換參數。

i

仿射變換參數。

xoff

仿射變換參數。

yoff

仿射變換參數。

zoff

仿射變換參數。

描述

  • 對於ST_Affine(geom, a, b, c, d, e, f, g, h, i, xoff, yoff, zoff)形式,代表如下變換矩陣:

    / a  b  c  xoff \
    | d  e  f  yoff |
    | g  h  i  zoff |
    \ 0  0  0     1 /
  • 頂點座標的變換如下(所有的轉換和縮放函數都通過這樣的仿射變換來表示):

    x' = a*x + b*y + c*z + xoff
    y' = d*x + e*y + f*z + yoff
    z' = g*x + h*y + i*z + zoff
  • 對於ST_Affine(geom, a, b, d, e, xoff, yoff)形式,代表如下變換矩陣:

    /  a  b  0  xoff  \       /  a  b  xoff  \
    |  d  e  0  yoff  | rsp.  |  d  e  yoff  |
    |  0  0  1     0  |       \  0  0     1  /
    \  0  0  0     1  /
  • 頂點座標的變換如下:

    x' = a*x + b*y + xoff
    y' = d*x + e*y + yoff
    z' = z

    本形式是3D模式的子模式。

  • 該函數支援Circular Strings、Curves、Polyhedral surfaces、Triangles、Triangulated Irregular Network Surfaces(TIN)和3D對象。

樣本

在X軸,Y軸,Z軸同時180度翻轉一個點:

SELECT ST_AsEWKT(ST_Affine(ST_GeomFromEWKT('POINT(1 2 3)'),
                           cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), 0, 0, 0));
    st_asewkt
-----------------
 POINT(-1 -2 -3)
(1 row)