2024-07-31 04:24 AM
Hi,
recently I detected "complex.h" and the float complex data type for C++ project files. Since then dealing with complex numbers got very easy.
I would appreciate the same ease of use for 3D float vectors, i.e. I need a float vector data type and the vector operators.
Is there a comparable include for 3D vectors?
THX
Cheers
Detlef
Solved! Go to Solution.
2024-07-31 05:46 AM
Fixed length arrays are implemented in <array> in C++.
#include <array>
std::array<float, 3> vector;
2024-07-31 04:28 AM - edited 2024-07-31 04:29 AM
I would think this would be generic C++ - not specific to STM32 or CubeIDE ?
What does your favourite internet search engine say?
Have you tried a search on GitHub ?
2024-07-31 04:53 AM
Hi,
the very first lines of the code in github
#include <iostream>
#include <cmath>
using namespace std;
show errors on CubeIDE.
I'm good in C but a C++ newbie. Fixed length vectors are not integrated in C++, as far as I know. Reportedly there are some 3D vector implementations out in the wild. I have the hope this is already included in the compiler for CubeIDE !?
Cheers
Detlef
2024-07-31 05:46 AM
Fixed length arrays are implemented in <array> in C++.
#include <array>
std::array<float, 3> vector;
2024-07-31 06:26 AM
Yes,
it works.
The pitfall: 'target language C++' is chosen, but you have to rename main.c to main.cpp manually. For main.c gcc throws an error, g++ for main.cpp ist working fine.
THX
Cheers
Detlef
2024-07-31 06:34 AM