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
Snippets
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
Dmitri Naumov
ogs
Commits
015f4da3
Commit
015f4da3
authored
11 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Added weighted point class and a test.
parent
3fac3fa6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MathLib/TemplateWeightedPoint.h
+45
-0
45 additions, 0 deletions
MathLib/TemplateWeightedPoint.h
Tests/MathLib/WeightedPoint.cpp
+50
-0
50 additions, 0 deletions
Tests/MathLib/WeightedPoint.cpp
with
95 additions
and
0 deletions
MathLib/TemplateWeightedPoint.h
0 → 100644
+
45
−
0
View file @
015f4da3
/**
* @file TemplateWeightedPoint.h
* @date Sep 3, 2013
* @brief Weighted point class.
*
* @copyright
* Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/LICENSE.txt
*/
#ifndef TEMPLATEWEIGHTEDPOINT_H_
#define TEMPLATEWEIGHTEDPOINT_H_
#include
"TemplatePoint.h"
namespace
MathLib
{
template
<
typename
FP_T
,
typename
W_T
,
std
::
size_t
DIM
>
class
TemplateWeightedPoint
:
public
TemplatePoint
<
FP_T
,
DIM
>
{
public:
TemplateWeightedPoint
(
std
::
initializer_list
<
FP_T
>
const
&
list
,
W_T
weight
)
:
TemplatePoint
<
FP_T
,
DIM
>
(
list
),
_weight
(
weight
)
{}
W_T
getWeight
()
const
{
return
_weight
;
}
private
:
W_T
_weight
;
};
typedef
TemplateWeightedPoint
<
double
,
double
,
1
>
WeightedPoint1D
;
typedef
TemplateWeightedPoint
<
double
,
double
,
2
>
WeightedPoint2D
;
typedef
TemplateWeightedPoint
<
double
,
double
,
3
>
WeightedPoint3D
;
}
// end namespace MathLib
#endif
/* TEMPLATEWEIGHTEDPOINT_H_ */
This diff is collapsed.
Click to expand it.
Tests/MathLib/WeightedPoint.cpp
0 → 100644
+
50
−
0
View file @
015f4da3
/**
* @file WeightedPoint.cpp
* @author Thomas Fischer
* @date Sep 4, 2013
* @brief
*
* @copyright
* Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/LICENSE.txt
*/
// google test
#include
"gtest/gtest.h"
#include
"TemplateWeightedPoint.h"
TEST
(
MathLib
,
WeightedPoint1D
)
{
double
pnt
=
0.5
;
double
w
=
100.0
;
MathLib
::
WeightedPoint1D
wpnt_1d
({
pnt
},
w
);
ASSERT_NEAR
(
wpnt_1d
[
0
],
pnt
,
std
::
numeric_limits
<
double
>::
min
());
ASSERT_NEAR
(
wpnt_1d
.
getWeight
(),
w
,
std
::
numeric_limits
<
double
>::
min
());
}
TEST
(
MathLib
,
WeightedPoint2D
)
{
double
pnt
[
2
]
=
{
0.1
,
0.2
};
double
w
=
200.0
;
MathLib
::
WeightedPoint2D
wpnt_2d
({
pnt
[
0
],
pnt
[
1
]},
w
);
ASSERT_NEAR
(
wpnt_2d
[
0
],
pnt
[
0
],
std
::
numeric_limits
<
double
>::
min
());
ASSERT_NEAR
(
wpnt_2d
[
1
],
pnt
[
1
],
std
::
numeric_limits
<
double
>::
min
());
ASSERT_NEAR
(
wpnt_2d
.
getWeight
(),
w
,
std
::
numeric_limits
<
double
>::
min
());
}
TEST
(
MathLib
,
WeightedPoint3D
)
{
double
pnt
[
3
]
=
{
0.1
,
0.2
,
0.3
};
double
w
=
300.0
;
MathLib
::
WeightedPoint3D
wpnt_3d
({
pnt
[
0
],
pnt
[
1
],
pnt
[
2
]},
w
);
ASSERT_NEAR
(
wpnt_3d
[
0
],
pnt
[
0
],
std
::
numeric_limits
<
double
>::
min
());
ASSERT_NEAR
(
wpnt_3d
[
1
],
pnt
[
1
],
std
::
numeric_limits
<
double
>::
min
());
ASSERT_NEAR
(
wpnt_3d
[
2
],
pnt
[
2
],
std
::
numeric_limits
<
double
>::
min
());
ASSERT_NEAR
(
wpnt_3d
.
getWeight
(),
w
,
std
::
numeric_limits
<
double
>::
min
());
}
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