-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into drop_mwf_pimpl
- Loading branch information
Showing
10 changed files
with
1,757 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (C) 2022 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
//! [complete] | ||
#include <iostream> | ||
#include <ignition/math/Interval.hh> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
std::cout << std::boolalpha; | ||
|
||
const ignition::math::Intervald defaultInterval; | ||
// A default constructed interval should be empty. | ||
std::cout << "The " << defaultInterval << " interval is empty: " | ||
<< defaultInterval.Empty() << std::endl; | ||
|
||
const ignition::math::Intervald openInterval = | ||
ignition::math::Intervald::Open(-1., 1.); | ||
// An open interval should exclude its endpoints. | ||
std::cout << "The " << openInterval << " interval contains its endpoints: " | ||
<< (openInterval.Contains(openInterval.LeftValue()) || | ||
openInterval.Contains(openInterval.RightValue())) | ||
<< std::endl; | ||
|
||
const ignition::math::Intervald closedInterval = | ||
ignition::math::Intervald::Closed(0., 1.); | ||
|
||
// A closed interval should include its endpoints. | ||
std::cout << "The " << closedInterval << " interval contains its endpoints: " | ||
<< (closedInterval.Contains(closedInterval.LeftValue()) || | ||
closedInterval.Contains(closedInterval.RightValue())) | ||
<< std::endl; | ||
|
||
// Closed and open intervals may intersect. | ||
std::cout << "Intervals " << closedInterval << " and " << openInterval | ||
<< " intersect: " << closedInterval.Intersects(openInterval) | ||
<< std::endl; | ||
|
||
// The unbounded interval should include all non-empty intervals. | ||
std::cout << "The " << ignition::math::Intervald::Unbounded | ||
<< " interval contains all previous non-empty intervals: " | ||
<< (ignition::math::Intervald::Unbounded.Contains(openInterval) || | ||
ignition::math::Intervald::Unbounded.Contains(closedInterval)) | ||
<< std::endl; | ||
|
||
} | ||
//! [complete] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2022 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
//! [complete] | ||
#include <iostream> | ||
#include <ignition/math/Polynomial3.hh> | ||
#include <ignition/math/Vector4.hh> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
// A default constructed polynomial should have zero coefficients. | ||
std::cout << "A default constructed polynomial is always: " | ||
<< ignition::math::Polynomial3d() << std::endl; | ||
|
||
// A constant polynomial only has an independent term. | ||
std::cout << "A constant polynomial only has an independent term: " | ||
<< ignition::math::Polynomial3d::Constant(-1.) << std::endl; | ||
|
||
// A cubic polynomial may be incomplete. | ||
const ignition::math::Polynomial3d p( | ||
ignition::math::Vector4d(1., 0., -1., 2.)); | ||
std::cout << "A cubic polynomial may be incomplete: " << p << std::endl; | ||
|
||
// A polynomial can be evaluated. | ||
const double x = 0.5; | ||
std::cout << "Evaluating " << p << " at " << x | ||
<< " yields " << p(x) << std::endl; | ||
|
||
// A polynomial can be queried for its minimum in a given interval, | ||
// as well as for its global minimum (which may not always be finite). | ||
const ignition::math::Intervald interval = | ||
ignition::math::Intervald::Closed(-1, 1.); | ||
std::cout << "The minimum of " << p << " in the " << interval | ||
<< " interval is " << p.Minimum(interval) << std::endl; | ||
std::cout << "The global minimum of " << p | ||
<< " is " << p.Minimum() << std::endl; | ||
|
||
const ignition::math::Polynomial3d q( | ||
ignition::math::Vector4d(0., 1., 2., 1.)); | ||
std::cout << "The minimum of " << q << " in the " << interval | ||
<< " interval is " << q.Minimum(interval) << std::endl; | ||
std::cout << "The global minimum of " << q | ||
<< " is " << q.Minimum() << std::endl; | ||
|
||
} | ||
//! [complete] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (C) 2022 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
//! [complete] | ||
#include <iostream> | ||
#include <ignition/math/Region3.hh> | ||
#include <ignition/math/Vector3.hh> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
std::cout << std::boolalpha; | ||
|
||
const ignition::math::Region3d defaultRegion; | ||
// A default constructed region should be empty. | ||
std::cout << "The " << defaultRegion << " region is empty: " | ||
<< defaultRegion.Empty() << std::endl; | ||
|
||
const ignition::math::Region3d openRegion = | ||
ignition::math::Region3d::Open(-1., -1., -1., 1., 1., 1.); | ||
// An open region should exclude points on its boundary. | ||
std::cout << "The " << openRegion << " region contains the " | ||
<< ignition::math::Vector3d::UnitX << " point: " | ||
<< openRegion.Contains(ignition::math::Vector3d::UnitX) | ||
<< std::endl; | ||
|
||
const ignition::math::Region3d closedRegion = | ||
ignition::math::Region3d::Closed(0., 0., 0., 1., 1., 1.); | ||
|
||
// A closed region should include points on its boundary. | ||
std::cout << "The " << closedRegion << " region contains the " | ||
<< ignition::math::Vector3d::UnitX << " point: " | ||
<< closedRegion.Contains(ignition::math::Vector3d::UnitX) | ||
<< std::endl; | ||
|
||
// Closed and open regions may intersect. | ||
std::cout << "Regions " << closedRegion << " and " << openRegion | ||
<< " intersect: " << closedRegion.Intersects(openRegion) | ||
<< std::endl; | ||
|
||
// The unbounded region should include all non-empty regions. | ||
std::cout << "The " << ignition::math::Region3d::Unbounded | ||
<< " region contains all previous non-empty intervals: " | ||
<< (ignition::math::Region3d::Unbounded.Contains(openRegion) || | ||
ignition::math::Region3d::Unbounded.Contains(closedRegion)) | ||
<< std::endl; | ||
|
||
} | ||
//! [complete] |
Oops, something went wrong.