Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
4dca7467
Commit
4dca7467
authored
10 years ago
by
Van Dung Nguyen
Browse files
Options
Downloads
Patches
Plain Diff
No commit message
No commit message
parent
edc46692
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
Geo/SVector3.h
+24
-10
24 additions, 10 deletions
Geo/SVector3.h
with
24 additions
and
10 deletions
Geo/SVector3.h
+
24
−
10
View file @
4dca7467
...
...
@@ -30,9 +30,9 @@ class SVector3 {
inline
double
z
(
void
)
const
{
return
P
.
z
();
}
inline
double
norm
()
const
{
return
sqrt
(
P
[
0
]
*
P
[
0
]
+
P
[
1
]
*
P
[
1
]
+
P
[
2
]
*
P
[
2
]);
}
inline
double
normSq
()
const
{
return
(
P
[
0
]
*
P
[
0
]
+
P
[
1
]
*
P
[
1
]
+
P
[
2
]
*
P
[
2
]);
}
// Beware that " w = v.normalize() " produces the vector
// Beware that " w = v.normalize() " produces the vector
// w = (v.norm(), v.norm(), v.norm()), which is NOT a unit vector!
// Use " w = v.unit() " to affect to "w" the unit vector parallel to "v".
// Use " w = v.unit() " to affect to "w" the unit vector parallel to "v".
double
normalize
(){
double
n
=
norm
();
if
(
n
){
P
[
0
]
/=
n
;
P
[
1
]
/=
n
;
P
[
2
]
/=
n
;
}
return
n
;
...
...
@@ -75,6 +75,20 @@ class SVector3 {
// Needed to allow the initialization of a SPoint3 from a SPoint3, a distance and a direction
SPoint3
point
()
const
{
return
P
;}
int
getMaxValue
(
double
&
val
)
const
{
if
((
P
[
0
]
>=
P
[
1
])
&&
(
P
[
0
]
>=
P
[
2
])){
val
=
P
[
0
];
return
0
;
}
else
if
((
P
[
1
]
>=
P
[
0
])
&&
(
P
[
1
]
>=
P
[
2
])){
val
=
P
[
1
];
return
1
;
}
else
{
val
=
P
[
2
];
return
2
;
}
}
};
...
...
@@ -95,7 +109,7 @@ inline SVector3 crossprod(const SVector3 &a, const SVector3 &b)
inline
double
angle
(
const
SVector3
&
a
,
const
SVector3
&
b
){
double
cosTheta
=
dot
(
a
,
b
);
double
sinTheta
=
norm
(
crossprod
(
a
,
b
));
return
atan2
(
sinTheta
,
cosTheta
);
return
atan2
(
sinTheta
,
cosTheta
);
}
...
...
@@ -146,7 +160,7 @@ inline void buildOrthoBasis_naive(SVector3 &dir, SVector3 &dir1, SVector3 &dir2)
Msg
::
Error
(
"Problem with computing orthoBasis"
);
Msg
::
Exit
(
1
);
}
// printf("XYZ =%g %g %g r=%g dir0 = %g %g %g dir1 = %g %g %g dir2 =%g %g %g\n",
// printf("XYZ =%g %g %g r=%g dir0 = %g %g %g dir1 = %g %g %g dir2 =%g %g %g\n",
// x,y,z,d, dir[0], dir[1], dir[2], dir1[0], dir1[1], dir1[2], dir2[0], dir2[1], dir2[2] );
// printf("0x1 =%g 1x2=%g 2x1=%g \n", dot(dir, dir1), dot(dir1,dir2), dot(dir2,dir));
dir1
.
normalize
();
...
...
@@ -166,12 +180,12 @@ inline void buildOrthoBasis(SVector3 &normal, SVector3 &tangent, SVector3 &binor
//build a binormal from tangent and normal:
binormal
=
crossprod
(
tangent
,
normal
);
double
t1
=
binormal
.
normalize
();
//and correct the tangent from the binormal and the normal.
tangent
=
crossprod
(
normal
,
binormal
);
double
t2
=
tangent
.
normalize
();
if
(
t1
==
0.0
||
t2
==
0.0
)
if
(
t1
==
0.0
||
t2
==
0.0
)
buildOrthoBasis_naive
(
normal
,
tangent
,
binormal
);
}
...
...
@@ -186,12 +200,12 @@ inline void buildOrthoBasis2(SVector3 &normal, SVector3 &tangent, SVector3 &bino
//build a binormal from tangent and normal:
binormal
=
crossprod
(
tangent
,
normal
);
double
t1
=
binormal
.
normalize
();
//and correct the tangent from the binormal and the normal.
tangent
=
crossprod
(
normal
,
binormal
);
double
t2
=
tangent
.
normalize
();
if
(
t1
==
0.0
||
t2
==
0.0
)
if
(
t1
==
0.0
||
t2
==
0.0
)
buildOrthoBasis_naive
(
normal
,
tangent
,
binormal
);
}
...
...
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