Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Yuhao Liu
ogs
Commits
bf3af686
Commit
bf3af686
authored
11 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[MathLib] For readability: Vector::length() -> Vector3::getLength().
parent
f78a141f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GeoLib/AnalyticalGeometry.cpp
+3
-3
3 additions, 3 deletions
GeoLib/AnalyticalGeometry.cpp
MathLib/Vector3.h
+9
-10
9 additions, 10 deletions
MathLib/Vector3.h
Tests/MathLib/TestVector3.cpp
+1
-1
1 addition, 1 deletion
Tests/MathLib/TestVector3.cpp
with
13 additions
and
14 deletions
GeoLib/AnalyticalGeometry.cpp
+
3
−
3
View file @
bf3af686
...
@@ -58,10 +58,10 @@ Orientation getOrientation(const GeoLib::Point* p0, const GeoLib::Point* p1,
...
@@ -58,10 +58,10 @@ Orientation getOrientation(const GeoLib::Point* p0, const GeoLib::Point* p1,
bool
parallel
(
MathLib
::
Vector3
v
,
MathLib
::
Vector3
w
)
bool
parallel
(
MathLib
::
Vector3
v
,
MathLib
::
Vector3
w
)
{
{
// check degenerated cases
// check degenerated cases
if
(
v
.
l
ength
()
<
std
::
numeric_limits
<
double
>::
min
())
if
(
v
.
getL
ength
()
<
std
::
numeric_limits
<
double
>::
min
())
return
false
;
return
false
;
if
(
w
.
l
ength
()
<
std
::
numeric_limits
<
double
>::
min
())
if
(
w
.
getL
ength
()
<
std
::
numeric_limits
<
double
>::
min
())
return
false
;
return
false
;
v
.
normalize
();
v
.
normalize
();
...
@@ -269,7 +269,7 @@ void getNewellPlane(const std::vector<GeoLib::Point*>& pnts, MathLib::Vector3 &p
...
@@ -269,7 +269,7 @@ void getNewellPlane(const std::vector<GeoLib::Point*>& pnts, MathLib::Vector3 &p
centroid
+=
*
(
pnts
[
j
]);
centroid
+=
*
(
pnts
[
j
]);
}
}
plane_normal
*=
1.0
/
plane_normal
.
l
ength
();
plane_normal
*=
1.0
/
plane_normal
.
getL
ength
();
d
=
MathLib
::
scalarProduct
(
centroid
,
plane_normal
)
/
n_pnts
;
d
=
MathLib
::
scalarProduct
(
centroid
,
plane_normal
)
/
n_pnts
;
}
}
...
...
This diff is collapsed.
Click to expand it.
MathLib/Vector3.h
+
9
−
10
View file @
bf3af686
...
@@ -124,15 +124,21 @@ public:
...
@@ -124,15 +124,21 @@ public:
*/
*/
void
normalize
()
void
normalize
()
{
{
const
double
s
(
1
/
l
ength
());
const
double
s
(
1
/
getL
ength
());
for
(
std
::
size_t
i
(
0
);
i
<
3
;
i
++
)
for
(
std
::
size_t
i
(
0
);
i
<
3
;
i
++
)
this
->
_x
[
i
]
*=
s
;
this
->
_x
[
i
]
*=
s
;
}
}
/// Returns the squared length
double
getSqrLength
(
void
)
const
{
return
this
->
_x
[
0
]
*
this
->
_x
[
0
]
+
this
->
_x
[
1
]
*
this
->
_x
[
1
]
+
this
->
_x
[
2
]
*
this
->
_x
[
2
];
}
/// Returns the length
/// Returns the length
double
l
ength
(
void
)
const
double
getL
ength
(
void
)
const
{
{
return
sqrt
(
s
qrLength
());
return
sqrt
(
getS
qrLength
());
}
}
/** scalarProduct, implementation of scalar product,
/** scalarProduct, implementation of scalar product,
...
@@ -158,13 +164,6 @@ public:
...
@@ -158,13 +164,6 @@ public:
friend
TemplateVector3
<
T1
>
operator
*
(
friend
TemplateVector3
<
T1
>
operator
*
(
double
s
,
double
s
,
TemplateVector3
<
T1
>
const
&
v
);
TemplateVector3
<
T1
>
const
&
v
);
private
:
/// Returns the squared length
double
sqrLength
(
void
)
const
{
return
this
->
_x
[
0
]
*
this
->
_x
[
0
]
+
this
->
_x
[
1
]
*
this
->
_x
[
1
]
+
this
->
_x
[
2
]
*
this
->
_x
[
2
];
}
};
};
template
<
typename
T
>
template
<
typename
T
>
...
...
This diff is collapsed.
Click to expand it.
Tests/MathLib/TestVector3.cpp
+
1
−
1
View file @
bf3af686
...
@@ -158,7 +158,7 @@ TEST(MathLib, TestVector3Multiplications)
...
@@ -158,7 +158,7 @@ TEST(MathLib, TestVector3Multiplications)
// test normalisation
// test normalisation
v
.
normalize
();
v
.
normalize
();
ASSERT_NEAR
(
1.0
,
v
.
l
ength
(),
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_NEAR
(
1.0
,
v
.
getL
ength
(),
std
::
numeric_limits
<
double
>::
epsilon
());
}
}
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