Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loadbalancing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
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
SLMS
loadbalancing
Commits
d1ed975c
Commit
d1ed975c
authored
3 years ago
by
Stephan Schulz
Committed by
Rene Halver
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix point distance calculation
parent
d69ed0df
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!21
Fix point distance calculation
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.rst
+7
-0
7 additions, 0 deletions
CHANGELOG.rst
include/ALL_Point.hpp
+19
-22
19 additions, 22 deletions
include/ALL_Point.hpp
tests/unit/point_arithmetic.cpp
+15
-0
15 additions, 0 deletions
tests/unit/point_arithmetic.cpp
with
41 additions
and
22 deletions
CHANGELOG.rst
+
7
−
0
View file @
d1ed975c
...
@@ -11,6 +11,13 @@ Version 1.0.0
...
@@ -11,6 +11,13 @@ Version 1.0.0
Version 0.9
Version 0.9
-----------
-----------
Version 0.9.3
*************
- Bug: ALL::Point.dist_plane(..) had a type bug. This manifestes with a cuda
compiler even without explicit usage of the function. Fixed and added
corresponding test.
Version 0.9.2
Version 0.9.2
*************
*************
...
...
This diff is collapsed.
Click to expand it.
include/ALL_Point.hpp
+
19
−
22
View file @
d1ed975c
...
@@ -220,31 +220,17 @@ public:
...
@@ -220,31 +220,17 @@ public:
throw
PointDimensionMissmatchException
(
__FILE__
,
__func__
,
__LINE__
);
throw
PointDimensionMissmatchException
(
__FILE__
,
__func__
,
__LINE__
);
// vectors spanning the plane from vertex 'a'
// vectors spanning the plane from vertex 'a'
T
vb
[
3
];
Point
<
T
>
vb
=
B
-
A
;
T
vc
[
3
];
Point
<
T
>
vc
=
C
-
A
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
vb
[
i
]
=
B
[
i
]
-
A
[
i
];
vc
[
i
]
=
C
[
i
]
-
A
[
i
];
}
// normal vector of plane
// normal vector of plane
T
n
[
3
];
Point
<
T
>
n
=
vb
.
cross
(
vc
);
n
=
n
/
n
.
norm
();
n
[
0
]
=
vb
[
1
]
*
vc
[
2
]
-
vb
[
2
]
*
vc
[
1
];
n
[
1
]
=
vb
[
2
]
*
vc
[
0
]
-
vb
[
0
]
*
vc
[
2
];
n
[
2
]
=
vb
[
0
]
*
vc
[
1
]
-
vb
[
1
]
*
vc
[
0
];
// length of normal vector
T
dn
=
n
.
norm
();
// distance from origin
// return r.n - A.n = (r-A).n as distance from plane to r
T
d
=
n
*
A
;
return
std
::
abs
(
(
coordinates
.
at
(
0
)
-
A
[
0
])
*
n
[
0
]
+
(
coordinates
.
at
(
1
)
-
A
[
1
])
*
n
[
1
]
+
// compute distance of test vertex to plane
(
coordinates
.
at
(
2
)
-
A
[
2
])
*
n
[
2
]
);
return
std
::
abs
((
n
[
0
]
*
coordinates
.
at
(
0
)
+
n
[
1
]
*
coordinates
.
at
(
1
)
+
n
[
2
]
*
coordinates
.
at
(
2
)
-
d
)
/
dn
);
}
}
/// operator for the addition of two point objects
/// operator for the addition of two point objects
...
@@ -301,6 +287,17 @@ public:
...
@@ -301,6 +287,17 @@ public:
return
result
;
return
result
;
}
}
/// operator to scale the local point object by a provided factor
/// @param rhs scaling factor
/// @return scaled point object
Point
<
T
>
operator
/
(
const
T
&
rhs
)
const
{
Point
<
T
>
result
(
dimension
);
for
(
int
d
=
0
;
d
<
dimension
;
++
d
)
{
result
[
d
]
=
coordinates
.
at
(
d
)
/
rhs
;
}
return
result
;
}
/// operator to compute the cross product between two point objects
/// operator to compute the cross product between two point objects
/// @param rhs point object to compute the cross product with
/// @param rhs point object to compute the cross product with
/// @return cross product between the two point objects
/// @return cross product between the two point objects
...
...
This diff is collapsed.
Click to expand it.
tests/unit/point_arithmetic.cpp
+
15
−
0
View file @
d1ed975c
...
@@ -172,5 +172,20 @@ BOOST_AUTO_TEST_CASE(point_scale_long_double) {
...
@@ -172,5 +172,20 @@ BOOST_AUTO_TEST_CASE(point_scale_long_double) {
BOOST_CHECK_CLOSE
(
C2
[
2
],
4.4
l
,
1e-14
);
BOOST_CHECK_CLOSE
(
C2
[
2
],
4.4
l
,
1e-14
);
}
}
BOOST_AUTO_TEST_CASE
(
point_dist_plane
)
{
std
::
vector
<
double
>
A_data
=
{
1.
,
0.
,
0.
};
std
::
vector
<
double
>
B_data
=
{
0.
,
1.
,
0.
};
std
::
vector
<
double
>
C_data
=
{
0.
,
0.
,
1.
};
std
::
vector
<
double
>
p_data
=
{
0.5
,
0.5
,
0.5
};
ALL
::
Point
<
double
>
A
(
A_data
);
ALL
::
Point
<
double
>
B
(
B_data
);
ALL
::
Point
<
double
>
C
(
C_data
);
ALL
::
Point
<
double
>
p
(
p_data
);
double
dist
=
p
.
dist_plane
(
A
,
B
,
C
);
BOOST_CHECK_CLOSE
(
dist
,
0.28867513459481292
,
1e-14
);
}
BOOST_AUTO_TEST_SUITE_END
()
BOOST_AUTO_TEST_SUITE_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