Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
miscmaths
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
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
FSL
miscmaths
Commits
0530e66c
Commit
0530e66c
authored
18 years ago
by
Saad Jbabdi
Browse files
Options
Downloads
Patches
Plain Diff
SJ changes for Cfdt
parent
64840388
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
miscmaths.cc
+45
-1
45 additions, 1 deletion
miscmaths.cc
with
45 additions
and
1 deletion
miscmaths.cc
+
45
−
1
View file @
0530e66c
...
@@ -1109,7 +1109,12 @@ float median(const ColumnVector& x)
...
@@ -1109,7 +1109,12 @@ float median(const ColumnVector& x)
return
m
;
return
m
;
}
}
void
sph2cart
(
const
ColumnVector
&
dir
,
float
&
th
,
float
&
ph
)
{
dir
(
1
)
=
cos
(
ph
)
*
sin
(
th
);
dir
(
2
)
=
sin
(
ph
)
*
sin
(
th
);
dir
(
3
)
=
cos
(
th
);
}
void
cart2sph
(
const
ColumnVector
&
dir
,
float
&
th
,
float
&
ph
)
void
cart2sph
(
const
ColumnVector
&
dir
,
float
&
th
,
float
&
ph
)
...
@@ -1166,6 +1171,45 @@ void cart2sph(const Matrix& dir,ColumnVector& th,ColumnVector& ph)
...
@@ -1166,6 +1171,45 @@ void cart2sph(const Matrix& dir,ColumnVector& th,ColumnVector& ph)
}
}
}
}
// added by SJ
void
cart2sph
(
const
vector
<
ColumnVector
>&
dir
,
ColumnVector
&
th
,
ColumnVector
&
ph
)
{
if
(
th
.
Nrows
()
!=
dir
.
size
()){
th
.
ReSize
(
dir
.
size
());
}
if
(
ph
.
Nrows
()
!=
dir
.
size
()){
ph
.
ReSize
(
dir
.
size
());
}
//double _2pi=2*M_PI;
double
_pi2
=
M_PI
/
2
;
int
j
=
1
;
for
(
unsigned
int
i
=
0
;
i
<
dir
.
size
();
i
++
)
{
float
mag
=
std
::
sqrt
(
dir
[
i
](
1
)
*
dir
[
i
](
1
)
+
dir
[
i
](
2
)
*
dir
[
i
](
2
)
+
dir
[
i
](
3
)
*
dir
[
i
](
3
));
if
(
mag
==
0
){
ph
(
j
)
=
_pi2
;
th
(
j
)
=
_pi2
;
}
else
{
if
(
dir
[
i
](
1
)
==
0
&&
dir
[
i
](
2
)
>=
0
)
ph
(
j
)
=
_pi2
;
else
if
(
dir
[
i
](
1
)
==
0
&&
dir
[
i
](
2
)
<
0
)
ph
(
j
)
=-
_pi2
;
else
if
(
dir
[
i
](
1
)
>
0
)
ph
(
j
)
=
std
::
atan
(
dir
[
i
](
2
)
/
dir
[
i
](
1
));
else
if
(
dir
[
i
](
2
)
>
0
)
ph
(
j
)
=
std
::
atan
(
dir
[
i
](
2
)
/
dir
[
i
](
1
))
+
M_PI
;
else
ph
(
j
)
=
std
::
atan
(
dir
[
i
](
2
)
/
dir
[
i
](
1
))
-
M_PI
;
//ph(j)=fmod(ph(j),_2pi);
if
(
dir
[
i
](
3
)
==
0
)
th
(
j
)
=
_pi2
;
else
if
(
dir
[
i
](
3
)
>
0
)
th
(
j
)
=
std
::
atan
(
std
::
sqrt
(
dir
[
i
](
1
)
*
dir
[
i
](
1
)
+
dir
[
i
](
2
)
*
dir
[
i
](
2
))
/
dir
[
i
](
3
));
else
th
(
j
)
=
std
::
atan
(
std
::
sqrt
(
dir
[
i
](
1
)
*
dir
[
i
](
1
)
+
dir
[
i
](
2
)
*
dir
[
i
](
2
))
/
dir
[
i
](
3
))
+
M_PI
;
//th(j)=fmod(th(j),M_PI);
}
j
++
;
}
}
// Added by CFB --- Matlab style Matrix functions
// Added by CFB --- Matlab style Matrix functions
...
...
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