Anonymous user
Angles (geometric), normalization and conversion: Difference between revisions
Angles (geometric), normalization and conversion (view source)
Revision as of 14:28, 16 October 2020
, 3 years ago→{{header|C++}}: new formatting
(→{{header|C++}}: Boost used) |
(→{{header|C++}}: new formatting) |
||
Line 434:
double r2m(double a) { return m2m(a * 3200 / M_PI); }
void print(const std::vector<double> &values, const char *s
using namespace std;
ostringstream out;
out << "┌─────────────────┬───────────────────┐\n";
out << "│ value
out << "├─────────────────┼───────────────────┤\n";
for (double i : values) {
out << "│ " << setw(15);
out << fixed << i << defaultfloat << " │ " << setw(
out << defaultfloat << " │\n";
}
out << "└─────────────────┴───────────────────┘\n";
auto str = out.str();
boost::algorithm::replace_all(str, ".000000", " ");
Line 453:
int main() {
std::vector<double> values = { -2, -1, 0, 1, 2, 6.2831853, 16, 57.2957795, 359, 399, 6399, 1000000 };
print(values, "normalized
print(values, "normalized
print(values, "normalized
print(values, "normalized
print(values
print(values
print(values
print(values
print(values
print(values
print(values
print(values
print(values
print(values
print(values
print(values
return 0;
}</lang>
{{out}}
<pre>┌─────────────────┬───────────────────┐
│ value │ normalized
├─────────────────┼───────────────────┤
│ -2 │
│ -1 │
│ 0 │
│ 1 │
│ 2 │
│ 6.283185 │
│ 16 │
│ 57.295780 │
│ 359 │
│ 399 │
│ 6399 │
│ 1000000 │
└─────────────────┴───────────────────┘
...
┌─────────────────┬───────────────────┐
│ value │
├─────────────────┼───────────────────┤
│ -2 │
│ -1 │
│ 0 │
│ 1 │
│ 2 │
│ 6.283185 │
│ 16 │
│ 57.295780 │
│ 359 │
│ 399 │
│ 6399 │
│ 1000000 │
└─────────────────┴───────────────────┘</pre>
=={{header|Common Lisp}}==
|