Nom

ST_Affine — Appliquer une transformation affine 3D à une géométrie.

Synopsis

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

Description

Applique une transformation affine 3D à la géométrie pour effectuer des opérations telles que la translation, la rotation et la mise à l'échelle en une seule étape.

Version 1: L'appel

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

représente la matrice de transformation

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

et les sommets sont transformés comme suit :

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

Toutes les fonctions de translation / mise à l'échelle ci-dessous sont exprimées par une telle transformation affine.

Version 2: Applique une transformation affine 2d à la géométrie. L'appel

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

représente la matrice de transformation

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  /

et les sommets sont transformés comme suit :

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

Cette méthode est un sous-cas de la méthode 3D ci-dessus.

Amélioration : 2.0.0 introduction du support TIN, Triangles et surfaces polyédriques.

Disponibilité : 1.1.2. Le nom a été changé de Affine à ST_Affine dans la version 1.2.2

[Note]

Avant la version 1.3.4, cette fonction se bloquait si elle était utilisée avec des géométries contenant des CURVES. Ce problème est corrigé dans la version 1.3.4+

Cette fonction prend en charge les surfaces Polyhedral.

Cette fonction prend en charge les triangles et les réseaux irréguliers triangulés (TIN).

Cette fonction prend en charge la 3D et ne supprime pas l'indice z.

Cette méthode prend en charge les types Circular String et Curve.

Exemples

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;
Export de raster
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;
Export de raster
LINESTRING(-1 -2 -3,-1 -4 -3)
Figure
Geometry figure for visual-st-affine-02