diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-12-20 18:36:16 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-12-20 18:36:16 +0100 |
| commit | 396d56d14503e27bbda5238b6115c82b22f0b7c6 (patch) | |
| tree | b6a0d5f9c24b1d5b1bbdbed1a10a4ee9544df2e0 | |
| parent | e99dd261a1f89acf5ad77effeb85f1efeae202b7 (diff) | |
| download | forstio-forstio-396d56d14503e27bbda5238b6115c82b22f0b7c6.tar.gz | |
| -rw-r--r-- | modules/codec/c++/math.hpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/modules/codec/c++/math.hpp b/modules/codec/c++/math.hpp index a8bbba1..6e1ec8b 100644 --- a/modules/codec/c++/math.hpp +++ b/modules/codec/c++/math.hpp @@ -81,5 +81,31 @@ data<schema::Vector<T,M>, Encoding> multiply(const data<schema::Matrix<T,M,N>, E return lr; } + +template<typename T, typename Encoding = FORSTIO_DEFAULT_DATA_ENCODING> +data<schema::Vector<T,3u>, Encoding> cross( + const data<schema::Vector<T,3u>, Encoding> lh, + const data<schema::Vector<T,3u>, Encoding> rh +){ + data<schema::Vector<T,3u>, Encoding> cross_prod; + + cross_prod.at({{0u}}) = lh.at({{1u}}) * rh.at({{2u}}) - lh.at({{2u}}) * rh.at({{1u}}); + cross_prod.at({{1u}}) = lh.at({{2u}}) * rh.at({{0u}}) - lh.at({{0u}}) * rh.at({{2u}}); + cross_prod.at({{2u}}) = lh.at({{0u}}) * rh.at({{1u}}) - lh.at({{1u}}) * rh.at({{0u}}); + + return cross_prod; +} + +template<typename T, typename Encoding = FORSTIO_DEFAULT_DATA_ENCODING> +data<T,Encoding> cross( + const data<schema::Vector<T,2u>, Encoding> lh, + const data<schema::Vector<T,2u>, Encoding> rh +){ + data<T, Encoding> cross_prod; + + cross_prod = lh.at({{0u}}) * rh.at({{1u}}) - lh.at({{1u}}) * rh.at({{0u}}); + + return cross_prod; +} } } |
