Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume below a plane #219

Merged
merged 88 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
56b214e
Add volume below primitives
arjo129 Aug 3, 2021
008aa1b
fix tests
arjo129 Aug 5, 2021
0e40a5f
nearly there for boxes
arjo129 Aug 5, 2021
c18b735
Fix boxes
arjo129 Aug 6, 2021
40fa5b3
use convex hull algo
arjo129 Aug 9, 2021
e275ff8
Add overlap method
arjo129 Aug 10, 2021
dfec15c
Finally `Box::VolumeBelow()` works :tada:
arjo129 Aug 11, 2021
13f0ade
signed volume
arjo129 Aug 12, 2021
5cfe42c
codecheck
arjo129 Aug 12, 2021
d82a6ba
Add center of volume recalculation
arjo129 Aug 14, 2021
27287dc
Add center of volume functions
arjo129 Aug 14, 2021
f241019
codecheck
arjo129 Aug 14, 2021
61258cd
Trying to get windows CI to pass
arjo129 Aug 14, 2021
69af275
Add preliminary cylinder logic.
arjo129 Aug 16, 2021
3095359
Add plane transformation
arjo129 Aug 19, 2021
37b3842
fix function return value
arjo129 Aug 26, 2021
bbed807
fix types
arjo129 Aug 26, 2021
c6c7e00
Preliminary work for cylinders
arjo129 Aug 29, 2021
278dc07
remove unessecary include
arjo129 Aug 30, 2021
f4e70c7
remove more useless logging
arjo129 Aug 30, 2021
11180ee
remove unused transform function.
arjo129 Aug 30, 2021
6521336
style fixes
arjo129 Aug 30, 2021
532775b
:facepalm: compilation error
arjo129 Aug 30, 2021
a90d11a
more style fixes.
arjo129 Aug 30, 2021
a30d0db
Merge branch 'ign-math6' into arjo/volume_below
arjo129 Aug 30, 2021
4d6675d
Fix docstring
arjo129 Aug 30, 2021
2578996
Revert changes to cylinder since those are not ready yet.
arjo129 Aug 30, 2021
482f582
more cleanups
arjo129 Aug 30, 2021
4888d99
Add triangle test
arjo129 Aug 30, 2021
e1985b3
Remove redundant function
arjo129 Aug 30, 2021
7f204d4
>.< Doh stray include
arjo129 Aug 30, 2021
99589e4
remove unused include
arjo129 Aug 30, 2021
5ee6f3b
typesafe-ify
arjo129 Aug 31, 2021
1c896fa
silence warning
arjo129 Sep 1, 2021
646595f
Codecheck
arjo129 Sep 1, 2021
e8fd7a2
Flip sign... :facepalm:
arjo129 Sep 1, 2021
6f82675
Merge branch 'ign-math6' into arjo/volume_below
arjo129 Sep 2, 2021
43fd3e3
Merge branch 'ign-math6' into arjo/volume_below
chapulina Sep 14, 2021
16289b0
Rename `Box::GetIntersections`.
arjo129 Sep 15, 2021
9ed6254
Merge branch 'arjo/volume_below' of github.com:ignitionrobotics/ign-m…
arjo129 Sep 15, 2021
1257aca
Revert *all* changes to cylinder
arjo129 Sep 15, 2021
7f1f1c8
fix docs and signature
arjo129 Sep 15, 2021
6ff1b49
Add line test
arjo129 Sep 15, 2021
753b49d
style fix
arjo129 Sep 15, 2021
633dfee
Documentation
arjo129 Sep 15, 2021
165a724
Fix compiler :warning:
arjo129 Sep 15, 2021
f5a45fa
Added test for `Vector3d::Project()`
arjo129 Sep 16, 2021
e7eaad6
Add test for CenterOfVolumeBelow()
arjo129 Sep 16, 2021
9739419
Add Vector(2|3|4)<T>::NaN to easily create invalid vectors (#222)
chapulina Sep 15, 2021
9fef0d9
style
arjo129 Sep 16, 2021
5a20d68
update intersections test
arjo129 Sep 16, 2021
e6e6e65
Removed `GetPointOnPlane` as its unessescary
arjo129 Sep 16, 2021
7189fe0
fix :warning: about signess
arjo129 Sep 16, 2021
d98acb7
Update include/ignition/math/Box.hh
arjo129 Sep 16, 2021
8cfbb7d
Rename intersections
arjo129 Sep 17, 2021
cf438da
Rename Vector projection
arjo129 Sep 17, 2021
aed0c6b
Add tolerance argument
arjo129 Sep 17, 2021
c835aee
Update line to point distance to support points projected beyond the …
chapulina Sep 16, 2021
b1a172f
Suggestions to #219
chapulina Sep 16, 2021
9979f83
🌐 Spherical coordinates: bug fix, docs and sanity checks (#235)
chapulina Sep 16, 2021
5c9343f
Adds python interface to Quaternion, Pose3, Matrix3 and Matrix4 (#221)
LolaSegura Sep 17, 2021
495583d
fixes
arjo129 Sep 20, 2021
305d4d4
Rigorous tests and bugfixes
arjo129 Sep 20, 2021
aba72c1
Style
arjo129 Sep 20, 2021
0b8c218
more fixes
arjo129 Sep 20, 2021
acacbb9
fix compile issues caused by merge
arjo129 Sep 20, 2021
b1a36c0
More comprehensive tests and bugfixes for box
arjo129 Sep 20, 2021
d8bae9a
Merge branch 'ign-math6' into arjo/volume_below
arjo129 Sep 20, 2021
8e75628
fix windows warning (I think)
arjo129 Sep 20, 2021
9a66163
Add plane intersection in bounds
arjo129 Sep 20, 2021
4bf9cfb
style
arjo129 Sep 20, 2021
d0c605d
style
arjo129 Sep 20, 2021
d4968df
More suggestions to #219
chapulina Sep 21, 2021
9a659fe
abs, include
chapulina Sep 21, 2021
70aa913
Merge pull request #243 from ignitionrobotics/chapulina/volume_below_2
arjo129 Sep 21, 2021
f8d1a7a
Merge branch 'ign-math6' into arjo/volume_below
arjo129 Sep 21, 2021
95cd4ee
Fixed header
arjo129 Sep 21, 2021
20d66b1
Workaround. Hopefully will make windows happy.
arjo129 Sep 21, 2021
1492375
Address @scpeter 's feedback
arjo129 Sep 21, 2021
72d7779
Address @scpeters feedback about Line3
arjo129 Sep 21, 2021
e356258
Reverting, because the dividee by zero will never occur
arjo129 Sep 21, 2021
b06b483
Added comment
arjo129 Sep 21, 2021
91a6b43
Add test cases and assert
arjo129 Sep 21, 2021
f547e71
Whelps compile error.
arjo129 Sep 21, 2021
69b0448
Add docs
arjo129 Sep 21, 2021
bacd9f9
whitespaces
arjo129 Sep 21, 2021
4c0bd02
More docs fixes
arjo129 Sep 21, 2021
b4f9ddc
update scalar value
arjo129 Sep 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/ignition/math/Plane.hh
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ namespace ignition
Vector3<T> rotatedXAxis = rotation * Vector3<T>::UnitX;
Vector3<T> rotatedYAxis = rotation * Vector3<T>::UnitY;

auto xBasis = rotatedXAxis.VectorProjectionLength(intersection);
auto yBasis = rotatedYAxis.VectorProjectionLength(intersection);
auto xBasis = rotatedXAxis.Dot(intersection);
auto yBasis = rotatedYAxis.Dot(intersection);
chapulina marked this conversation as resolved.
Show resolved Hide resolved

if (std::abs(xBasis) < this->Size().X() / 2 &&
std::abs(yBasis) < this->Size().Y() / 2)
Expand Down
9 changes: 0 additions & 9 deletions include/ignition/math/Vector3.hh
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,6 @@ namespace ignition
return n.Normalize();
}

/// \brief Get Length of a Vector Projection of another onto this vector
/// \param[in] _v the vector
/// \return the projection. Note: If the length of the current vector is
/// zero this method will return a NaN
public: T VectorProjectionLength(const Vector3<T> &_v) const
{
return this->Dot(_v) / this->Length();
}

/// \brief Get distance to an infinite line defined by 2 points.
/// \param[in] _pt1 first point on the line
/// \param[in] _pt2 second point on the line
Expand Down
18 changes: 11 additions & 7 deletions include/ignition/math/detail/Box.hh
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ std::vector<std::pair<Triangle3<T>, T>> TrianglesInPlane(
{
std::vector<std::pair<Triangle3<T>, T>> triangles;
std::vector<Vector3<T>> pointsInPlane;

Vector3<T> centroid;
for (const auto &pt : _vertices)
{
Expand All @@ -154,11 +155,14 @@ std::vector<std::pair<Triangle3<T>, T>> TrianglesInPlane(
auto aDisplacement = _a - centroid;
auto bDisplacement = _b - centroid;

auto aX = axis1.VectorProjectionLength(aDisplacement);
auto aY = axis2.VectorProjectionLength(aDisplacement);
// project line onto the new basis vectors
// The axis length will never be zero as we have three different points
// and the centroid will be different.
auto aX = axis1.Dot(aDisplacement) / axis1.Length();
auto aY = axis2.Dot(aDisplacement) / axis2.Length();

auto bX = axis1.VectorProjectionLength(bDisplacement);
auto bY = axis2.VectorProjectionLength(bDisplacement);
auto bX = axis1.Dot(bDisplacement) / axis1.Length();
auto bY = axis2.Dot(bDisplacement) / axis2.Length();

return atan2(aY, aX) < atan2(bY, bX);
});
Expand All @@ -178,7 +182,7 @@ template<typename T>
T Box<T>::VolumeBelow(const Plane<T> &_plane) const
{
auto verticesBelow = this->VerticesBelow(_plane);
if (verticesBelow.size() == 0)
if (verticesBelow.empty())
return 0;

auto intersections = this->Intersections(_plane);
Expand Down Expand Up @@ -225,7 +229,7 @@ std::optional<Vector3<T>>
Box<T>::CenterOfVolumeBelow(const Plane<T> &_plane) const
{
auto verticesBelow = this->VerticesBelow(_plane);
if (verticesBelow.size() == 0)
if (verticesBelow.empty())
return std::nullopt;

auto intersections = this->Intersections(_plane);
Expand Down Expand Up @@ -314,7 +318,7 @@ IntersectionPoints<T> Box<T>::Intersections(
Vector3<T>{-this->size.X()/2, this->size.Y()/2, this->size.Z()/2}
};

// Axises
// Axes
std::vector<Vector3<T>> axes
{
Vector3<T>{1, 0, 0},
Expand Down
12 changes: 0 additions & 12 deletions src/Vector3_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -435,18 +435,6 @@ TEST(Vector3dTest, Multiply)
EXPECT_EQ(v*v, math::Vector3d(0.01, 0.04, 0.09));
}

/////////////////////////////////////////////////
TEST(Vector3dTest, Projection)
{
math::Vector3d v1(0, 0, 2);
math::Vector3d v2(0, 1, 0);
math::Vector3d v3(2, 3, 2);

EXPECT_NEAR(v1.VectorProjectionLength(v3), 2, 1e-15);
EXPECT_NEAR(v2.VectorProjectionLength(v3), 3, 1e-15);
EXPECT_NEAR(v1.VectorProjectionLength(v2), 0, 1e-15);
}

/////////////////////////////////////////////////
TEST(Vector3dTest, NotEqual)
{
Expand Down