-
Notifications
You must be signed in to change notification settings - Fork 67
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 static-constexpr
- Loading branch information
Showing
68 changed files
with
7,322 additions
and
54 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
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,57 @@ | ||
/* | ||
* Copyright (C) 2021 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/Color.hh> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
|
||
//! [Create a color] | ||
ignition::math::Color a = ignition::math::Color(0.3, 0.4, 0.5); | ||
//! [Create a color] | ||
// The channel order is R, G, B, A and the default alpha value of a should be 1.0 | ||
std::cout << "The alpha value of a should be 1: " << a.A() << std::endl; | ||
|
||
|
||
//! [Set a new color value] | ||
a.ignition::math::Color::Set(0.6, 0.7, 0.8, 1.0); | ||
//! [Set a new color value] | ||
std::cout << "The RGBA value of a: " << a << std::endl; | ||
|
||
//! [Set value from BGRA] | ||
// 0xFF0000FF is blue in BGRA. Convert it to RGBA. | ||
ignition::math::Color::BGRA blue = 0xFF0000FF; | ||
a.ignition::math::Color::SetFromBGRA(blue); | ||
//! [Set value from BGRA] | ||
|
||
//! [Math operator] | ||
std::cout << "Check if a is Blue: " << (a == ignition::math::Color::Blue) << std::endl; | ||
std::cout << "The RGB value of a should be (0, 0, 1): " << a[0] << ", " | ||
<< a[1] << ", " | ||
<< a[2] << std::endl; | ||
//! [Math operator] | ||
|
||
//! [Set value from HSV] | ||
// Initialize with HSV. (240, 1.0, 1.0) is blue in HSV. | ||
a.ignition::math::Color::SetFromHSV(240.0, 1.0, 1.0); | ||
std::cout << "The HSV value of a: " << a.HSV() << std::endl; | ||
std::cout << "The RGBA value of a should be (0, 0, 1, 1): " << a << std::endl; | ||
//! [Set value from HSV] | ||
|
||
} | ||
//! [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
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,54 @@ | ||
/* | ||
* Copyright (C) 2021 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/Rand.hh> | ||
|
||
// You can plot the data generated by this program by following these | ||
// steps. | ||
// | ||
// 1. Run this program and save the output to a file: | ||
// ./rand_example normal > normal.data | ||
// ./rand_example uniform > uniform.data | ||
// | ||
// 2. Use gnuplot to create a plot: | ||
// gnuplot -c rand_view_normal.gp > normal.jpg | ||
// gnuplot -c rand_view_uniform.gp > uniform.jpg | ||
int main(int argc, char **argv) | ||
{ | ||
if (argc < 2) | ||
{ | ||
std::cout << "./rand_example [normal, uniform]" << '\n'; | ||
return -1; | ||
} | ||
for (int i = 0; i < 100000; ++i) | ||
{ | ||
double value; | ||
if (std::string(argv[1]) == "normal") | ||
{ | ||
value = ignition::math::Rand::DblNormal(0, 100); | ||
} | ||
else if (std::string(argv[1]) == "uniform") | ||
{ | ||
value = ignition::math::Rand::DblUniform(0, 1000); | ||
} | ||
std::cout << value << std::endl; | ||
} | ||
|
||
return 0; | ||
} | ||
//! [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,37 @@ | ||
# Copyright (C) 2021 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. | ||
|
||
# You can plot the data generated by this program by following these | ||
# steps. | ||
# | ||
# 1. Run this program and save the output to a file: | ||
# ./rand_example normal > normal.data | ||
# ./rand_example uniform > uniform.data | ||
# | ||
# 2. Use gnuplot to create a plot: | ||
# gnuplot -c rand_view_normal.gp > normal.jpg | ||
# gnuplot -c rand_view_uniform.gp > uniform.jpg | ||
from ignition.math import Rand | ||
import sys | ||
|
||
if (len(sys.argv) < 2): | ||
print("python rand_example [normal, uniform]") | ||
else: | ||
for i in range(100000): | ||
value = 0 | ||
if (sys.argv[1] == "uniform"): | ||
value = Rand.dbl_uniform(0, 1000); | ||
elif (sys.argv[1] == "normal"): | ||
value = Rand.dbl_normal(0, 100); | ||
print(value) |
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,12 @@ | ||
set terminal jpeg | ||
binwidth = 5 | ||
bin(x,width)=width*floor(x/width) | ||
|
||
set tics out nomirror | ||
set style fill transparent solid 0.5 border lt -1 | ||
set xrange [-1000:1000] | ||
set xtics binwidth | ||
set boxwidth binwidth | ||
set yrange [0:2500] | ||
|
||
plot "normal.data" u (bin($1,binwidth)):(1.0) smooth freq with boxes notitle |
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,12 @@ | ||
set terminal jpeg | ||
binwidth = 50 | ||
bin(x,width)=width*floor(x/width) | ||
|
||
set tics out nomirror | ||
set style fill transparent solid 0.5 border lt -1 | ||
set xrange [0:1000] | ||
set xtics binwidth | ||
set boxwidth binwidth | ||
set yrange [0:10000] | ||
|
||
plot "uniform.data" u (bin($1,binwidth)):(1.0) smooth freq with boxes notitle |
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
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
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
Oops, something went wrong.