Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into gdal-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Jun 24, 2021
2 parents f3897e8 + e71e355 commit 07d7e2c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion doc/stages/filters.optimalneighborhood.rst
Expand Up @@ -44,4 +44,4 @@ min_k

max_k
The maximum number of k nearest neighbors to consider for optimal
neighborhood selection. [Default: 100]
neighborhood selection. [Default: 14]
14 changes: 6 additions & 8 deletions doc/stages/filters.transformation.rst
Expand Up @@ -3,12 +3,9 @@
filters.transformation
======================

The transformation filter applies an arbitrary rotation+translation
The transformation filter applies an arbitrary homography
transformation, represented as a 4x4 matrix_, to each xyz triplet.

The filter does *no* checking to ensure the matrix is a valid affine
transformation.

.. note::

The transformation filter does not apply or consider any spatial
Expand Down Expand Up @@ -59,10 +56,11 @@ A full tutorial about transformation matrices is beyond the scope of this
documentation. Instead, we will provide a few pointers to introduce core
concepts, especially as pertains to PDAL's handling of the ``matrix`` argument.

Transformations in a 3-dimensional coordinate system can be represented as an
affine transformation using homogeneous coordinates. This 4x4 matrix can
represent transformations describing operations like translation, rotation, and
scaling of coordinates.
Transformations in a 3-dimensional coordinate system can be represented
as a homography transformation using homogeneous coordinates. This 4x4
matrix can represent affine transformations describing operations like
translation, rotation, and scaling of coordinates. In addition it can
represent perspective transformations modeling a pinhole camera.

The transformation filter's ``matrix`` argument is a space delimited, 16
element string. This string is simply a row-major representation of the 4x4
Expand Down
7 changes: 4 additions & 3 deletions filters/TransformationFilter.cpp
Expand Up @@ -190,15 +190,16 @@ bool TransformationFilter::processOne(PointRef& point)
double x = point.getFieldAs<double>(Dimension::Id::X);
double y = point.getFieldAs<double>(Dimension::Id::Y);
double z = point.getFieldAs<double>(Dimension::Id::Z);
double s = x * matrix[12] + y * matrix[13] + z * matrix[14] + matrix[15];

point.setField(Dimension::Id::X,
x * matrix[0] + y * matrix[1] + z * matrix[2] + matrix[3]);
(x * matrix[0] + y * matrix[1] + z * matrix[2] + matrix[3]) / s);

point.setField(Dimension::Id::Y,
x * matrix[4] + y * matrix[5] + z * matrix[6] + matrix[7]);
(x * matrix[4] + y * matrix[5] + z * matrix[6] + matrix[7]) / s);

point.setField(Dimension::Id::Z,
x * matrix[8] + y * matrix[9] + z * matrix[10] + matrix[11]);
(x * matrix[8] + y * matrix[9] + z * matrix[10] + matrix[11]) / s);
return true;
}

Expand Down

0 comments on commit 07d7e2c

Please sign in to comment.