Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
YAPSUT
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
Michele Maris
YAPSUT
Commits
478f4469
Commit
478f4469
authored
1 year ago
by
Michele Maris
Browse files
Options
Downloads
Patches
Plain Diff
u
parent
b3f2564c
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/yapsut/geometry.py
+2
-0
2 additions, 0 deletions
src/yapsut/geometry.py
src/yapsut/roto_translation.py
+48
-0
48 additions, 0 deletions
src/yapsut/roto_translation.py
src/yapsut/vectorized_elemental_rotations.py
+91
-0
91 additions, 0 deletions
src/yapsut/vectorized_elemental_rotations.py
with
141 additions
and
0 deletions
src/yapsut/geometry.py
+
2
−
0
View file @
478f4469
import
numpy
as
np
from
.roto_translation
import
transform
,
roto_trans_matrix
from
.vectorized_elemental_rotations
import
vERotX
,
vERotY
,
vERotZ
,
vAX3D
,
vAY3D
,
vAZ3D
class
ElipsoidTriangulation
:
"""
creates an elipsoid triangulated
"""
@property
...
...
This diff is collapsed.
Click to expand it.
src/yapsut/roto_translation.py
0 → 100644
+
48
−
0
View file @
478f4469
__DESCRIPTION__
=
"""
not vectorized rototranslation library
M.Maris - V0.0 - 2018 May 03 -
"""
import
numpy
as
np
def
transform
(
point
,
TransformArray
):
"""
apply a transformation to a 4d point
"""
p
=
np
.
array
([
0
,
0
,
0
,
1
])
for
i
in
range
(
0
,
len
(
point
)
-
1
):
p
[
i
]
=
point
[
i
]
p
=
np
.
dot
(
TransformArray
,
np
.
transpose
(
p
))
for
i
in
range
(
0
,
len
(
point
)
-
1
):
point
[
i
]
=
p
[
i
]
return
point
def
roto_trans_matrix
(
rotation
,
translation
):
"""
returns a rototranslation matrix
"""
xC
,
xS
=
trig
(
rotation
[
0
])
yC
,
yS
=
trig
(
rotation
[
1
])
zC
,
zS
=
trig
(
rotation
[
2
])
dX
=
translation
[
0
]
dY
=
translation
[
1
]
dZ
=
translation
[
2
]
Translate_matrix
=
np
.
array
([[
1
,
0
,
0
,
dX
],
[
0
,
1
,
0
,
dY
],
[
0
,
0
,
1
,
dZ
],
[
0
,
0
,
0
,
1
]])
Rotate_X_matrix
=
np
.
array
([[
1
,
0
,
0
,
0
],
[
0
,
xC
,
-
xS
,
0
],
[
0
,
xS
,
xC
,
0
],
[
0
,
0
,
0
,
1
]])
Rotate_Y_matrix
=
np
.
array
([[
yC
,
0
,
yS
,
0
],
[
0
,
1
,
0
,
0
],
[
-
yS
,
0
,
yC
,
0
],
[
0
,
0
,
0
,
1
]])
Rotate_Z_matrix
=
np
.
array
([[
zC
,
-
zS
,
0
,
0
],
[
zS
,
zC
,
0
,
0
],
[
0
,
0
,
1
,
0
],
[
0
,
0
,
0
,
1
]])
return
np
.
dot
(
Rotate_Z_matrix
,
np
.
dot
(
Rotate_Y_matrix
,
np
.
dot
(
Rotate_X_matrix
,
Translate_matrix
)))
This diff is collapsed.
Click to expand it.
src/yapsut/vectorized_elemental_rotations.py
0 → 100644
+
91
−
0
View file @
478f4469
__DESCRIPTION__
=
"""
vectorized elemental rotations
M.Maris - V0.0 - 2023 Aug 05 -
"""
import
numpy
as
np
# 3D versors X, Y, Z
vAX3D
=
np
.
array
([
1
,
0
,
0
])
vAY3D
=
np
.
array
([
0
,
1
,
0
])
vAZ3D
=
np
.
array
([
0
,
0
,
1
])
def
_vectorized_rotation_base_matrix
(
self
,
Angle
)
:
"""
commodity function to define a base for a vectorized rotation matrix, returns the components
I, c, s of a list of elemental 3D rotation matrices with
I.shape=(N,3,3),
c.shape=N,
s.shape=N.
with N = 1 is Angle is scalar, otherwise N=len(Angle)
Parameters
----------
:Angle: scalar or array of rotation angle(s) in radiants
"""
_angle
=
np
.
array
([
Angle
])
if
np
.
isscalar
(
Angle
)
else
Angle
c
=
np
.
cos
(
_angle
)
s
=
np
.
sin
(
_angle
)
I
=
np
.
zeros
([
len
(
_angle
),
3
,
3
])
I
[:,
0
,
0
]
=
1
I
[:,
1
,
1
]
=
1
I
[:,
2
,
2
]
=
1
return
I
,
c
,
s
def
vERotX
(
Angle
)
:
"""
Vectorized elemental rotations about X axis
returns a list of elemental 3D rotation matrices with shape (N,3,3)
with N = 1 if Angle is scalar, otherwise N=len(Angle)
Parameters
----------
:Angle: scalar or array of rotation angle(s) in radiants
"""
R
,
c
,
s
=
_vectorized_rotation_base_matrix
(
Angle
)
R
[:,
1
,
1
]
=
c
R
[:,
1
,
2
]
=-
s
R
[:,
2
,
1
]
=
s
R
[:,
2
,
2
]
=
c
return
R
def
vERotY
(
Angle
)
:
"""
Vectorized elemental rotations about Y axis
returns a list of elemental 3D rotation matrices with shape (N,3,3)
with N = 1 if Angle is scalar, otherwise N=len(Angle)
Parameters
----------
:Angle: scalar or array of rotation angle(s) in radiants
"""
R
,
c
,
s
=
_vectorized_rotation_base_matrix
(
Angle
)
R
[:,
0
,
0
]
=
c
R
[:,
0
,
2
]
=
s
R
[:,
2
,
0
]
=-
s
R
[:,
2
,
2
]
=
c
return
R
def
vERotZ
(
Angle
)
:
"""
Vectorized elemental rotations about Z axis
returns a list of elemental 3D rotation matrices with shape (N,3,3)
with N = 1 if Angle is scalar, otherwise N=len(Angle)
Parameters
----------
:Angle: scalar or array of rotation angle(s) in radiants
"""
R
,
c
,
s
=
_vectorized_rotation_base_matrix
(
Angle
)
R
[:,
0
,
0
]
=
c
R
[:,
0
,
1
]
=-
s
R
[:,
1
,
0
]
=
s
R
[:,
1
,
1
]
=
c
return
R
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