Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Evan Edmond
fslpy
Commits
1ac96c1a
Commit
1ac96c1a
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
New transformNormal function, for transforming normal vectors.
parent
aba4d605
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/transform.py
+13
-3
13 additions, 3 deletions
fsl/utils/transform.py
with
13 additions
and
3 deletions
fsl/utils/transform.py
+
13
−
3
View file @
1ac96c1a
...
@@ -11,6 +11,7 @@ spaces. The following functions are provided:
...
@@ -11,6 +11,7 @@ spaces. The following functions are provided:
:nosignatures:
:nosignatures:
transform
transform
transformNormal
scaleOffsetXform
scaleOffsetXform
invert
invert
concat
concat
...
@@ -437,8 +438,8 @@ def transform(p, xform, axes=None, vector=False):
...
@@ -437,8 +438,8 @@ def transform(p, xform, axes=None, vector=False):
:arg p: A sequence or array of points of shape :math:`N
\\
times 3`.
:arg p: A sequence or array of points of shape :math:`N
\\
times 3`.
:arg xform: A
n
affine transformation matrix with which to
transform the
:arg xform: A
``(4, 4)``
affine transformation matrix with which to
points in ``p``.
transform the
points in ``p``.
:arg axes: If you are only interested in one or two axes, and the source
:arg axes: If you are only interested in one or two axes, and the source
axes are orthogonal to the target axes (see the note below),
axes are orthogonal to the target axes (see the note below),
...
@@ -448,7 +449,8 @@ def transform(p, xform, axes=None, vector=False):
...
@@ -448,7 +449,8 @@ def transform(p, xform, axes=None, vector=False):
:arg vector: Defaults to ``False``. If ``True``, the points are treated
:arg vector: Defaults to ``False``. If ``True``, the points are treated
as vectors - the translation component of the transformation
as vectors - the translation component of the transformation
is not applied.
is not applied. If you set this flag, you pass in a ``(3, 3)``
transformation matrix.
:returns: The points in ``p``, transformed by ``xform``, as a ``numpy``
:returns: The points in ``p``, transformed by ``xform``, as a ``numpy``
array with the same data type as the input.
array with the same data type as the input.
...
@@ -476,6 +478,14 @@ def transform(p, xform, axes=None, vector=False):
...
@@ -476,6 +478,14 @@ def transform(p, xform, axes=None, vector=False):
else
:
return
t
else
:
return
t
def
transformNormal
(
p
,
xform
,
axes
=
None
):
"""
Transforms the given point(s), under the assumption that they
are normal vectors. In this case, the points are transformed by
``invert(xform[:3, :3]).T``.
"""
return
transform
(
p
,
invert
(
xform
[:
3
,
:
3
]).
T
,
axes
,
vector
=
True
)
def
_fillPoints
(
p
,
axes
):
def
_fillPoints
(
p
,
axes
):
"""
Used by the :func:`transform` function. Turns the given array p into
"""
Used by the :func:`transform` function. Turns the given array p into
a ``N*3`` array of ``x,y,z`` coordinates. The array p may be a 1D array,
a ``N*3`` array of ``x,y,z`` coordinates. The array p may be a 1D array,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment