summaryrefslogtreecommitdiff
path: root/modules/codec
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2025-09-25 11:00:53 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2025-09-25 11:00:53 +0200
commite69e3cb018619b51f35004284056af383eab0bd7 (patch)
treec87f283fb215044e25736715a2421d3a6e9b8d07 /modules/codec
parent5b822e1422ed808de9144da8ed38037b17dd0b65 (diff)
downloadforstio-forstio-e69e3cb018619b51f35004284056af383eab0bd7.tar.gz
Check if vector would be 0
Diffstat (limited to 'modules/codec')
-rw-r--r--modules/codec/c++/math.hpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/codec/c++/math.hpp b/modules/codec/c++/math.hpp
index ec051df..090005c 100644
--- a/modules/codec/c++/math.hpp
+++ b/modules/codec/c++/math.hpp
@@ -32,6 +32,9 @@ data<schema::Scalar<T>,Encoding> sqrt(const data<schema::Scalar<T>,Encoding>& in
template<typename T, uint64_t D, typename Encoding = encode::Native>
data<schema::Vector<T,D>, Encoding> normalize(const data<schema::Vector<T,D>>& input ) {
auto inp_dot = dot<T,D,Encoding>(input,input);
+ if(inp_dot.at({}).get() <= 0){
+ return input;
+ }
auto sqrt_inp_dot = sqrt<T>(inp_dot);
saw::data<schema::Vector<T,D>, Encoding> out;