https://cppfx.xyz
This program creates a random triangle, and calculate the distance of every two vertices of it.
#include <utxcpp/core.hpp> #include <utxcpp/phoenix.hpp> #include <boost/phoenix.hpp> using phx::arg_names::arg1; using phx::local_names::_x; int main() { // Declare a 3D triangle. std::array<std::array<utx::f32,3>,3> triangle; // Nested Range Algorithm (aka std::ranges::for_each and utx::random/uphx::random) std::ranges::for_each( triangle, uphx::random(arg1) ); // Nested For Each std::ranges::for_each( triangle, phx::for_each(arg1, phx::lambda[arg1=uphx::cbrt(arg1)]) ); utx::print("triangle:"); std::ranges::for_each(triangle, uphx::print_all(arg1)); utx::print(); auto distance = [] (auto & p1, auto & p2) { return utx::sqrt( utx::pown(p1[0]-p2[0], 2) + utx::pown(p1[1]-p2[1], 2) + utx::pown(p1[2]-p2[2], 2) ); }; utx::print("triangle vertex distances =>\n", distance(triangle[0], triangle[1]), distance(triangle[1], triangle[2]), distance(triangle[2], triangle[0])); }
triangle: 5.678462 -3.314425 9.974591 -5.722333 -7.336027 -9.926257 8.361337 4.314020 6.393945 triangle vertex distances => 23.285084 24.503517 8.843756
Utxcpp is a simple and easy to use
library for cpp/c++, which requires
c++20/c++23, boost libraries and b2 build.
fxcmdutils -
Some commandline programs
to let us more easily and quickly
to use some features.