Назва

ST_Affine — Застосувати афінне перетворення 3D до геометрії.

Короткий огляд

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);

Опис

Застосовує 3D афінне перетворення до геометрії, щоб виконати такі дії, як перенесення, обертання, масштабування за один крок.

Версія 1: Виклик

Code
ST_Affine(geom, a, b, c, d, e, f, g, h, i, xoff, yoff, zoff) 

представляє матрицю перетворення

Code
/ a  b  c  xoff \
| d  e  f  yoff |
| g  h  i  zoff |
\ 0  0  0     1 /

і вершини перетворюються наступним чином:

Code
x' = a*x + b*y + c*z + xoff
y' = d*x + e*y + f*z + yoff
z' = g*x + h*y + i*z + zoff

Всі функції перетворення/масштабування, наведені нижче, виражаються за допомогою такого афінного перетворення.

Версія 2: Застосовує 2D афінне перетворення до геометрії. Виклик

Code
ST_Affine(geom, a, b, d, e, xoff, yoff)

представляє матрицю перетворення.

Code
/  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  /

і вершини трансформуються наступним чином:

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

Цей метод є підвидом вищезазначеного 3D-методу.

Покращено: 2.0.0 додано підтримку багатогранних поверхонь, трикутників і TIN.

Доступність: 1.1.2. Назва змінена з Affine на ST_Affine у версії 1.2.2

[Примітка]

До версії 1.3.4 ця функція виходила з ладу при використанні з геометріями, що містять КРИВІ. Ця проблема вирішена у версії 1.3.4+

This function supports Polyhedral surfaces.

This function supports Triangles and Triangulated Irregular Network Surfaces (TIN).

This function supports 3d and will not drop the z-index.

This method supports Circular Strings and Curves.

Приклади

Rotate a 3D line 180 degrees about the z axis. Note this is long-hand for doing ST_Rotate();

Code
SELECT ST_Affine(geom, cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), 0, 0, 0, 1, 0, 0, 0) As using_affine,
    ST_Rotate(geom, pi()) As using_rotate
   FROM (SELECT 'LINESTRING(1 2 3,1 4 3)'::geometry As geom) As foo;
Вивід растрових зображень
using_affine         |        using_rotate
-----------------------------+-----------------------------
 LINESTRING(-1 -2 3,-1 -4 3) | LINESTRING(-1 -2 3,-1 -4 3)
(1 row)
Figure
Geometry figure for visual-st-affine-01

Rotate a 3D line 180 degrees in both the x and z axis.

Code
SELECT ST_Affine(geom, cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), 0, 0, 0)
    FROM (SELECT 'LINESTRING(1 2 3,1 4 3)'::geometry As geom) As foo;
Вивід растрових зображень
LINESTRING(-1 -2 -3,-1 -4 -3)
Figure
Geometry figure for visual-st-affine-02