Refactored file layout because platformio failed to find things
This commit is contained in:
14
library.json
14
library.json
@@ -16,17 +16,5 @@
|
||||
],
|
||||
"license": "None Yet",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
"build": {
|
||||
"srcDir": "src",
|
||||
"flags": [
|
||||
"-std=c++17",
|
||||
"-I src/Vector3D",
|
||||
"-I src/Matrix",
|
||||
"-I src/Quaternion"
|
||||
],
|
||||
"srcFilter": [
|
||||
"-<*/unit-tests/>"
|
||||
]
|
||||
}
|
||||
"platforms": "*"
|
||||
}
|
||||
@@ -1,4 +1,59 @@
|
||||
add_subdirectory(Matrix)
|
||||
add_subdirectory(Quaternion)
|
||||
add_subdirectory(Vector3D)
|
||||
# Quaternion Interface
|
||||
add_library(vector-3d-intf
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
target_include_directories(vector-3d-intf
|
||||
INTERFACE
|
||||
.
|
||||
)
|
||||
|
||||
target_link_libraries(vector-3d-intf
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
# Quaternion
|
||||
add_library(quaternion
|
||||
STATIC
|
||||
Quaternion.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(quaternion
|
||||
PUBLIC
|
||||
vector-3d-intf
|
||||
PRIVATE
|
||||
)
|
||||
|
||||
set_target_properties(quaternion
|
||||
PROPERTIES
|
||||
LINKER_LANGUAGE CXX
|
||||
)
|
||||
|
||||
# Vector3d
|
||||
add_library(vector-3d
|
||||
STATIC
|
||||
Vector3D.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(vector-3d
|
||||
PUBLIC
|
||||
vector-3d-intf
|
||||
PRIVATE
|
||||
)
|
||||
|
||||
# Matrix
|
||||
add_library(matrix
|
||||
STATIC
|
||||
Matrix.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(matrix
|
||||
PUBLIC
|
||||
vector-3d-intf
|
||||
PRIVATE
|
||||
)
|
||||
|
||||
set_target_properties(matrix
|
||||
PROPERTIES
|
||||
LINKER_LANGUAGE CXX
|
||||
)
|
||||
@@ -1,35 +0,0 @@
|
||||
# Matrix Interface
|
||||
add_library(matrix-intf
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
target_include_directories(matrix-intf
|
||||
INTERFACE
|
||||
.
|
||||
)
|
||||
|
||||
# Matrix
|
||||
add_library(matrix
|
||||
STATIC
|
||||
Matrix.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(matrix
|
||||
PUBLIC
|
||||
matrix-intf
|
||||
PRIVATE
|
||||
)
|
||||
|
||||
set_target_properties(matrix
|
||||
PROPERTIES
|
||||
LINKER_LANGUAGE CXX
|
||||
)
|
||||
|
||||
# matrix tests
|
||||
add_executable(matrix-tests unit-tests/matrix-tests.cpp)
|
||||
|
||||
target_link_libraries(matrix-tests
|
||||
PRIVATE
|
||||
matrix-intf
|
||||
Catch2::Catch2WithMain
|
||||
)
|
||||
@@ -49,7 +49,7 @@ Quaternion Quaternion::operator*(float scalar) const
|
||||
|
||||
Quaternion Quaternion::operator+(const Quaternion &other) const
|
||||
{
|
||||
return Quaternion{this->w * other.w, this->v1 * other.v1, this->v2 * other.v2, this->v3 * other.v3};
|
||||
return Quaternion{this->w + other.w, this->v1 + other.v1, this->v2 + other.v2, this->v3 + other.v3};
|
||||
}
|
||||
|
||||
Quaternion &
|
||||
@@ -81,6 +81,10 @@ Quaternion &Quaternion::Rotate(Quaternion &other, Quaternion &buffer) const
|
||||
void Quaternion::Normalize()
|
||||
{
|
||||
float magnitude = sqrt(this->v1 * this->v1 + this->v2 * this->v2 + this->v3 * this->v3 + this->w * this->w);
|
||||
if (magnitude == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this->v1 /= magnitude;
|
||||
this->v2 /= magnitude;
|
||||
this->v3 /= magnitude;
|
||||
@@ -2,7 +2,6 @@
|
||||
#define QUATERNION_H_
|
||||
|
||||
#include "Matrix.hpp"
|
||||
|
||||
class Quaternion : public Matrix<1, 4>
|
||||
{
|
||||
public:
|
||||
@@ -1,40 +0,0 @@
|
||||
# Quaternion Interface
|
||||
add_library(quaternion-intf
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
target_include_directories(quaternion-intf
|
||||
INTERFACE
|
||||
.
|
||||
)
|
||||
|
||||
target_link_libraries(quaternion-intf
|
||||
INTERFACE
|
||||
matrix-intf
|
||||
)
|
||||
|
||||
# Quaternion
|
||||
add_library(quaternion
|
||||
STATIC
|
||||
Quaternion.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(quaternion
|
||||
PUBLIC
|
||||
quaternion-intf
|
||||
PRIVATE
|
||||
)
|
||||
|
||||
set_target_properties(quaternion
|
||||
PROPERTIES
|
||||
LINKER_LANGUAGE CXX
|
||||
)
|
||||
|
||||
# Quaternion tests
|
||||
add_executable(quaternion-tests unit-tests/quaternion-tests.cpp)
|
||||
|
||||
target_link_libraries(quaternion-tests
|
||||
PRIVATE
|
||||
quaternion
|
||||
Catch2::Catch2WithMain
|
||||
)
|
||||
@@ -1,31 +0,0 @@
|
||||
# Vector 3D Interface
|
||||
add_library(vector-3d-intf
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
target_include_directories(vector-3d-intf
|
||||
INTERFACE
|
||||
.
|
||||
)
|
||||
|
||||
# Vector3d
|
||||
add_library(vector-3d
|
||||
STATIC
|
||||
Vector3D.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(vector-3d
|
||||
PUBLIC
|
||||
vector-3d-intf
|
||||
PRIVATE
|
||||
)
|
||||
|
||||
# vector tests
|
||||
add_executable(vector-tests unit-tests/vector-tests.cpp)
|
||||
|
||||
target_link_libraries(vector-tests
|
||||
PRIVATE
|
||||
matrix-intf
|
||||
vector-3d-intf
|
||||
Catch2::Catch2WithMain
|
||||
)
|
||||
26
unit-tests/CMakeLists.txt
Normal file
26
unit-tests/CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
# Quaternion tests
|
||||
add_executable(quaternion-tests unit-tests/quaternion-tests.cpp)
|
||||
|
||||
target_link_libraries(quaternion-tests
|
||||
PRIVATE
|
||||
vector-3d-intf
|
||||
Catch2::Catch2WithMain
|
||||
)
|
||||
|
||||
# matrix tests
|
||||
add_executable(matrix-tests unit-tests/matrix-tests.cpp)
|
||||
|
||||
target_link_libraries(matrix-tests
|
||||
PRIVATE
|
||||
vector-3d-intf
|
||||
Catch2::Catch2WithMain
|
||||
)
|
||||
|
||||
# Vector 3D Tests
|
||||
add_executable(vector-3d-tests unit-tests/vector-tests.cpp)
|
||||
|
||||
target_link_libraries(vector-3d-tests
|
||||
PRIVATE
|
||||
vector-3d-intf
|
||||
Catch2::Catch2WithMain
|
||||
)
|
||||
Reference in New Issue
Block a user