Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Virtual Sensing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SPAH
IN-NOVA
Virtual Sensing
Commits
7fdd2bf3
Commit
7fdd2bf3
authored
10 months ago
by
Achilles Kappis
Browse files
Options
Downloads
Patches
Plain Diff
Add the first Julia implementations of some of the utility functions
parent
add4b241
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Utilities/Generic/Julia/Utils.jl
+188
-0
188 additions, 0 deletions
Utilities/Generic/Julia/Utils.jl
with
188 additions
and
0 deletions
Utilities/Generic/Julia/Utils.jl
0 → 100644
+
188
−
0
View file @
7fdd2bf3
"""
This is the module with the Julia implementations of the generic utilities of the IN-NOVA project.
--------------------------------------------------
Author: Achilles Kappis
e-mail: axilleaz@protonmail.com
Date: 10/08/2024 (DD/MM/YYYY)
Copyright: MIT
--------------------------------------------------
# Functions included
- stepFunc
- isEven
- isOdd
- rotMat3d
--------------------------------------------------
"""
module
Utils
"""
Numerical (simple) Heaviside function
--------------------------------------------------
Author: Achilles Kappis
e-mail: axilleaz@protonmail.com
Date: 10/08/2024 (DD/MM/YYYY)
Copyright: MIT
--------------------------------------------------
Functionality: A Heaviside numerical (step) function
--------------------------------------------------
# Input
x::Real: The argument of the function.
zeroHalf::Bool (Optional): The way x = 0 is treated. If this argument is true, the returned value is 0.5 when x = 0, otherwise it is 1. [Default: false].
--------------------------------------------------
# Output
result::Float64: Either 0 or 1 based on whether the argument of the function is greater or equal to zero.
--------------------------------------------------
# Notes
--------------------------------------------------
"""
function
stepFunc
(
x
::
Real
;
zeroHalf
::
Bool
=
false
)
if
zeroHalf
&&
x
==
0
result
=
0.5
else
result
=
x
>=
0
end
return
convert
(
Float64
,
result
)
end
"""
Determine whether a number is even
--------------------------------------------------
Author: Achilles Kappis
e-mail: axilleaz@protonmail.com
Date: 10/08/2024 (DD/MM/YYYY)
Copyright: MIT
--------------------------------------------------
Functionality: Function to check if a real integer is even.
--------------------------------------------------
# Input arguments
num::Integer: The number to check.
--------------------------------------------------
# Output arguments
result::Bool: True if the number is even, False else.
--------------------------------------------------
# Notes
--------------------------------------------------
"""
function
isEven
(
num
::
Integer
)
return
mod
(
num
,
2
)
==
0
end
"""
Determine whether a number is odd
--------------------------------------------------
Author: Achilles Kappis
e-mail: axilleaz@protonmail.com
Date: 10/08/2024 (DD/MM/YYYY)
Copyright: MIT
--------------------------------------------------
Functionality: Function to check if a real integer is odd.
--------------------------------------------------
# Input arguments
num::Integer: The number to check.
--------------------------------------------------
# Output arguments
result::Bool: True if the number is even, False else.
--------------------------------------------------
# Notes
--------------------------------------------------
"""
function
isOdd
(
num
::
Integer
)
return
mod
(
num
,
2
)
!=
0
end
"""
Calculate a 3D rotation matrix
--------------------------------------------------
Author: Achilles Kappis
e-mail: axilleaz@protonmail.com
Date: 10/08/2024 (DD/MM/YYYY)
Copyright: MIT
--------------------------------------------------
Functionality: Calculate a 3D rotation matrix.
--------------------------------------------------
# Input
xAng::Real: Rotation angle around the x-axis.
yAng::Real (Optional): Rotation angle around the y-axis. [Default: 0].
zAng::Real (Optional): Rotation angle around the z-axis. [Default: 0].
deg::Bool (Optional) [keyword]: This value declares if the provided angles are in degrees or not. If not, radians are assumed. [Default: false].
--------------------------------------------------
# Output
rotMat::Matrix{Real}: A 3x3 matrix which applies the rotation.
xRotMat::Matrix{Real}: A 3x3 matrix which applies the rotation around the x-axis.
yRotMat::Matrix{Real}: A 3x3 matrix which applies the rotation around the y-axis.
zRotMat::Matrix: A 3x3 matrix which applies the rotation around the z-axis.
--------------------------------------------------
# Notes
--------------------------------------------------
"""
function
rotMat3d
(
xAng
::
Real
,
yAng
::
Real
=
0
,
zAng
::
Real
=
0
;
deg
::
Bool
=
false
)
# Check for units of the angles
if
deg
xAng
=
deg2rad
(
xAng
)
yAng
=
deg2rad
(
yAng
)
zAng
=
deg2rad
(
zAng
)
end
# Generate the respective matrices
xRotMat
=
[
1
0
0
;
0
cos
(
xAng
)
-
sin
(
xAng
);
0
sin
(
xAng
)
cos
(
xAng
)]
yRotMat
=
[
cos
(
yAng
)
0
sin
(
yAng
);
0
1
0
;
-
sin
(
yAng
)
0
cos
(
yAng
)]
zRotMat
=
[
cos
(
zAng
)
-
sin
(
zAng
)
0
;
sin
(
zAng
)
cos
(
zAng
)
0
;
0
0
1
]
# Calculate the "total" matrix
rotMat
=
xRotMat
*
yRotMat
*
zRotMat
# Return
return
rotMat
,
xRotMat
,
yRotMat
,
zRotMat
end
end
# Module end
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