Browse Source

Merge branch 'rc-2023-1-0' of public/ls-math into master

patrick-christopher.mattulat 11 months ago
parent
commit
429437a788

+ 70 - 0
.clang-format

@@ -0,0 +1,70 @@
+# Generated from CLion C/C++ Code Style settings
+BasedOnStyle: LLVM
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: None
+AlignOperands: Align
+AllowAllArgumentsOnNextLine: false
+AllowAllConstructorInitializersOnNextLine: false
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortBlocksOnASingleLine: Always
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLambdasOnASingleLine: All
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterReturnType: None
+AlwaysBreakTemplateDeclarations: Yes
+BreakBeforeBraces: Custom
+BraceWrapping:
+  AfterCaseLabel: true
+  AfterClass: true
+  AfterControlStatement: Always
+  AfterEnum: true
+  AfterFunction: true
+  AfterNamespace: true
+  AfterStruct: true
+  AfterUnion: true
+  BeforeCatch: true
+  BeforeElse: true
+  IndentBraces: false
+  SplitEmptyFunction: false
+  SplitEmptyRecord: true
+BreakBeforeBinaryOperators: None
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: BeforeColon
+BreakInheritanceList: BeforeColon
+ColumnLimit: 700
+CompactNamespaces: true
+ContinuationIndentWidth: 4
+EmptyLineAfterAccessModifier: Always
+FixNamespaceComments: false
+IndentAccessModifiers: true
+IndentCaseLabels: true
+IndentPPDirectives: BeforeHash
+IndentWidth: 2
+KeepEmptyLinesAtTheStartOfBlocks: true
+MaxEmptyLinesToKeep: 2
+NamespaceIndentation: All
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PointerAlignment: Right
+ReflowComments: false
+SortIncludes: CaseSensitive
+SpaceAfterCStyleCast: true
+SpaceAfterLogicalNot: false
+SpaceAfterTemplateKeyword: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInCStyleCastParentheses: false
+SpacesInContainerLiterals: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+TabWidth: 2
+UseTab: Never

+ 147 - 0
.clang-tidy

@@ -0,0 +1,147 @@
+# Generated from CLion Inspection settings
+---
+Checks: '-*,
+bugprone-argument-comment,
+bugprone-assert-side-effect,
+bugprone-bad-signal-to-kill-thread,
+bugprone-branch-clone,
+bugprone-copy-constructor-init,
+bugprone-dangling-handle,
+bugprone-dynamic-static-initializers,
+bugprone-fold-init-type,
+bugprone-forward-declaration-namespace,
+bugprone-forwarding-reference-overload,
+bugprone-inaccurate-erase,
+bugprone-incorrect-roundings,
+bugprone-integer-division,
+bugprone-lambda-function-name,
+bugprone-macro-parentheses,
+bugprone-macro-repeated-side-effects,
+bugprone-misplaced-operator-in-strlen-in-alloc,
+bugprone-misplaced-pointer-arithmetic-in-alloc,
+bugprone-misplaced-widening-cast,
+bugprone-move-forwarding-reference,
+bugprone-multiple-statement-macro,
+bugprone-no-escape,
+bugprone-not-null-terminated-result,
+bugprone-parent-virtual-call,
+bugprone-posix-return,
+bugprone-reserved-identifier,
+bugprone-sizeof-container,
+bugprone-sizeof-expression,
+bugprone-spuriously-wake-up-functions,
+bugprone-string-constructor,
+bugprone-string-integer-assignment,
+bugprone-string-literal-with-embedded-nul,
+bugprone-suspicious-enum-usage,
+bugprone-suspicious-include,
+bugprone-suspicious-memory-comparison,
+bugprone-suspicious-memset-usage,
+bugprone-suspicious-missing-comma,
+bugprone-suspicious-semicolon,
+bugprone-suspicious-string-compare,
+bugprone-swapped-arguments,
+bugprone-terminating-continue,
+bugprone-throw-keyword-missing,
+bugprone-too-small-loop-variable,
+bugprone-undefined-memory-manipulation,
+bugprone-undelegated-constructor,
+bugprone-unhandled-self-assignment,
+bugprone-unused-raii,
+bugprone-unused-return-value,
+bugprone-use-after-move,
+bugprone-virtual-near-miss,
+cert-dcl21-cpp,
+cert-dcl58-cpp,
+cert-err34-c,
+cert-err52-cpp,
+cert-err60-cpp,
+cert-flp30-c,
+cert-msc50-cpp,
+cert-msc51-cpp,
+cert-str34-c,
+cppcoreguidelines-interfaces-global-init,
+cppcoreguidelines-narrowing-conversions,
+cppcoreguidelines-pro-type-member-init,
+cppcoreguidelines-pro-type-static-cast-downcast,
+cppcoreguidelines-slicing,
+google-default-arguments,
+google-explicit-constructor,
+google-runtime-operator,
+hicpp-exception-baseclass,
+hicpp-multiway-paths-covered,
+misc-misplaced-const,
+misc-new-delete-overloads,
+misc-no-recursion,
+misc-non-copyable-objects,
+misc-throw-by-value-catch-by-reference,
+misc-unconventional-assign-operator,
+misc-uniqueptr-reset-release,
+modernize-avoid-bind,
+modernize-concat-nested-namespaces,
+modernize-deprecated-headers,
+modernize-deprecated-ios-base-aliases,
+modernize-loop-convert,
+modernize-make-shared,
+modernize-make-unique,
+modernize-pass-by-value,
+modernize-raw-string-literal,
+modernize-redundant-void-arg,
+modernize-replace-auto-ptr,
+modernize-replace-disallow-copy-and-assign-macro,
+modernize-replace-random-shuffle,
+modernize-return-braced-init-list,
+modernize-shrink-to-fit,
+modernize-unary-static-assert,
+modernize-use-auto,
+modernize-use-bool-literals,
+modernize-use-emplace,
+modernize-use-equals-default,
+modernize-use-equals-delete,
+modernize-use-nodiscard,
+modernize-use-noexcept,
+modernize-use-nullptr,
+modernize-use-override,
+modernize-use-transparent-functors,
+modernize-use-uncaught-exceptions,
+mpi-buffer-deref,
+mpi-type-mismatch,
+openmp-use-default-none,
+performance-faster-string-find,
+performance-for-range-copy,
+performance-implicit-conversion-in-loop,
+performance-inefficient-algorithm,
+performance-inefficient-string-concatenation,
+performance-inefficient-vector-operation,
+performance-move-const-arg,
+performance-move-constructor-init,
+performance-no-automatic-move,
+performance-noexcept-move-constructor,
+performance-trivially-destructible,
+performance-type-promotion-in-math-fn,
+performance-unnecessary-copy-initialization,
+performance-unnecessary-value-param,
+portability-simd-intrinsics,
+readability-avoid-const-params-in-decls,
+readability-const-return-type,
+readability-container-size-empty,
+readability-convert-member-functions-to-static,
+readability-delete-null-pointer,
+readability-deleted-default,
+readability-inconsistent-declaration-parameter-name,
+readability-make-member-function-const,
+readability-misleading-indentation,
+readability-misplaced-array-index,
+readability-non-const-parameter,
+readability-redundant-control-flow,
+readability-redundant-declaration,
+readability-redundant-function-ptr-dereference,
+readability-redundant-smartptr-get,
+readability-redundant-string-cstr,
+readability-redundant-string-init,
+readability-simplify-subscript-expr,
+readability-static-accessed-through-instance,
+readability-static-definition-in-anonymous-namespace,
+readability-string-compare,
+readability-uniqueptr-delete-release,
+readability-use-anyofallof'

+ 12 - 43
CMakeLists.txt

@@ -7,9 +7,9 @@
 ####################################################################################################################
 
 cmake_minimum_required(VERSION 3.17)
-project(ls_math VERSION 2022.1.0)
+project(ls-math VERSION 2023.1.0)
 
-set(MODULE_NAME_LS_MATH_VECTOR ls_math_vector)
+set(MODULE_NAME_LS_MATH_VECTOR ls-math-vector)
 
 set(GOOGLE_TEST_MODULE googletest-1.11.0)
 
@@ -21,7 +21,6 @@ option(BUILD_LS_MATH_WITH_TESTS "Build project with tests..." OFF)
 option(BUILD_LS_MATH_WITH_SUPPORTED_COMPILER "Build project with supported compiler only..." ON)
 option(BUILD_LS_MATH_STATIC "Build ls-math static library..." ON)
 option(BUILD_LS_MATH_SHARED "Build ls-math shared library..." OFF)
-option(BUILD_LS_MATH_MODULE "Build ls-math module library..." OFF)
 
 set(TARGET_COUNTER 0)
 
@@ -35,11 +34,6 @@ if (${BUILD_LS_MATH_SHARED})
     set(GOAL "shared library")
 endif ()
 
-if (${BUILD_LS_MATH_MODULE})
-    math(EXPR TARGET_COUNTER "${TARGET_COUNTER} + 1")
-    set(GOAL "module library")
-endif ()
-
 message("${PROJECT_NAME}: [Goal] ${GOAL}")
 
 if (TARGET_COUNTER GREATER 1)
@@ -72,35 +66,15 @@ if(${BUILD_LS_MATH_WITH_SUPPORTED_COMPILER})
 
     if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC OR
             ${CMAKE_CXX_COMPILER_ID} STREQUAL GNU OR
-            ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
+            ${CMAKE_CXX_COMPILER_ID} STREQUAL ClangOR OR
+            ${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang)
         message("${PROJECT_NAME}: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} is supported...")
     else()
         message("${PROJECT_NAME}: [Error] ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} is not supported... terminated!")
         return()
     endif ()
-
-    # define which compilers are supported for shared or module goal
-
-    if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC AND ${BUILD_LS_MATH_MODULE})
-        message("${PROJECT_NAME}: [Error] building \"${GOAL}\" with ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} is not supported... terminated!")
-        return()
-    endif ()
 endif()
 
-# define which goals can run tests
-
-if (${BUILD_LS_MATH_WITH_TESTS} AND ${BUILD_LS_MATH_MODULE})
-    message("${PROJECT_NAME}: [Error] building \"${GOAL}\" with tests is not supported... terminated!")
-    return()
-endif ()
-
-######################################################
-# Conan Setup
-######################################################
-
-# include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
-# conan_basic_setup()
-
 ######################################################
 # Include Directories
 ######################################################
@@ -134,7 +108,7 @@ endif ()
 ####################################################################################################################
 
 set(SOURCE_FILES_LS_MATH_VECTOR
-        ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_math/vector/Vector2.cpp)
+        ${CMAKE_CURRENT_SOURCE_DIR}/source/ls-math/vector/Vector2.cpp)
 
 ####################################################################################################################
 ####################################################################################################################
@@ -158,12 +132,12 @@ endif ()
 ####################################################################################################################
 
 ##########################################################
-# Build Tests (ls_math_vector)
+# Build Tests (ls-math-vector)
 ##########################################################
 
 if (${BUILD_LS_MATH_WITH_TESTS})
     message("${MODULE_NAME_LS_MATH_VECTOR}: Building tests...")
-    add_executable(${MODULE_NAME_LS_MATH_VECTOR}_test ${TEST_FILES_LS_MATH_VECTOR})
+    add_executable(${MODULE_NAME_LS_MATH_VECTOR}-test ${TEST_FILES_LS_MATH_VECTOR})
 endif ()
 
 ####################################################################################################################
@@ -175,25 +149,20 @@ endif ()
 ####################################################################################################################
 
 ##########################################################
-# Build Library (ls_math_vector)
+# Build Library (ls-math-vector)
 ##########################################################
 
 message("${PROJECT_NAME}: Building ${MODULE_NAME_LS_MATH_VECTOR} library version ${PROJECT_VERSION}...")
 
 if (${BUILD_LS_MATH_STATIC})
     add_library("${MODULE_NAME_LS_MATH_VECTOR}" STATIC ${SOURCE_FILES_LS_MATH_VECTOR})
-    set_target_properties("${MODULE_NAME_LS_MATH_VECTOR}" PROPERTIES DEBUG_POSTFIX "_d")
+    set_target_properties("${MODULE_NAME_LS_MATH_VECTOR}" PROPERTIES DEBUG_POSTFIX "-d")
 endif ()
 
 if (${BUILD_LS_MATH_SHARED})
     add_library("${MODULE_NAME_LS_MATH_VECTOR}" SHARED ${SOURCE_FILES_LS_MATH_VECTOR})
     target_link_libraries("${MODULE_NAME_LS_MATH_VECTOR}" ${MODULE_NAME_CORE})
-    set_target_properties("${MODULE_NAME_LS_MATH_VECTOR}" PROPERTIES DEBUG_POSTFIX "_d")
-endif ()
-
-if (${BUILD_LS_MATH_MODULE})
-    add_library("${MODULE_NAME_LS_MATH_VECTOR}" MODULE ${SOURCE_FILES_LS_MATH_VECTOR})
-    set_target_properties("${MODULE_NAME_LS_MATH_VECTOR}" PROPERTIES DEBUG_POSTFIX "_d")
+    set_target_properties("${MODULE_NAME_LS_MATH_VECTOR}" PROPERTIES DEBUG_POSTFIX "-d")
 endif ()
 
 ####################################################################################################################
@@ -205,12 +174,12 @@ endif ()
 ####################################################################################################################
 
 ##########################################################
-# Linking (ls_math_vector)
+# Linking (ls-math-vector)
 ##########################################################
 
 if (${BUILD_LS_MATH_WITH_TESTS})
     message("${MODULE_NAME_LS_MATH_VECTOR}: Linking libraries for test application...")
-    target_link_libraries(${MODULE_NAME_LS_MATH_VECTOR}_test
+    target_link_libraries(${MODULE_NAME_LS_MATH_VECTOR}-test
             gtest
             gmock
             gtest_main

+ 5 - 4
README.md

@@ -1,4 +1,4 @@
-# Lynar Studios - Math Library - 2022.1.0
+# Lynar Studios - Math Library - 2023.1.0
 
 
 This library provides mathematical functionalities. All functionalities are provided in independent modules, which can be added to your project.
@@ -15,11 +15,12 @@ This module provides vector functionalities of a cartesian coordinate system.
 
 #### Features ####
 
-- vector module has been added to provide functionalities for 2D vector calculations 
+- AppleClang compiler is now officially supported
 
 #### Improvements ####
 
-- none
+- solve SonarLint findings
+- apply naming convention that forbids the usage of underscores
 
 #### Fixes ####
 
@@ -27,7 +28,7 @@ This module provides vector functionalities of a cartesian coordinate system.
 
 ### Documentation ###
 
-Currently there is no documentation available due to the small scope of this library.
+Currently, there is no documentation available due to the small scope of this library.
 
 ### Building ###
 

+ 1 - 1
include/ls_math/core/types/VectorTypes.hpp → include/ls-math/core/types/VectorTypes.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-08-05
- * Changed:         2022-11-06
+ * Changed:         2023-06-02
  *
  * */
 

+ 2 - 2
include/ls_math/ls_math_core.hpp → include/ls-math/ls-math-core.hpp

@@ -3,13 +3,13 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-08-05
- * Changed:         2022-11-06
+ * Changed:         2023-06-02
  *
  * */
 
 #ifndef LS_MATH_LS_MATH_CORE_HPP
 #define LS_MATH_LS_MATH_CORE_HPP
 
-#include <ls_math/core/types/VectorTypes.hpp>
+#include <ls-math/core/types/VectorTypes.hpp>
 
 #endif

+ 2 - 2
include/ls_math/ls_math_vector.hpp → include/ls-math/ls-math-vector.hpp

@@ -3,13 +3,13 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-08-05
- * Changed:         2022-11-06
+ * Changed:         2023-06-02
  *
  * */
 
 #ifndef LS_MATH_LS_MATH_VECTOR_HPP
 #define LS_MATH_LS_MATH_VECTOR_HPP
 
-#include <ls_math/vector/Vector2.hpp>
+#include <ls-math/vector/Vector2.hpp>
 
 #endif

+ 3 - 3
include/ls_math/os/dynamic_goal.hpp → include/ls-math/os/dynamic-goal.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-11-06
- * Changed:         2022-11-06
+ * Changed:         2023-06-02
  *
  * */
 
@@ -11,10 +11,10 @@
 #define LS_MATH_DYNAMIC_GOAL_HPP
 
 #if defined(_WIN32) && defined(_MSC_VER)
-#include <ls_math/os/windows/msvc_dll_definitions.hpp>
+  #include <ls-math/os/windows/msvc-dll-definitions.hpp>
 #endif
 #if defined(unix) || defined(__APPLE__) || defined(_WIN32) && defined(__GNUC__)
-#include <ls_math/os/unix/unix_so_definitions.hpp>
+  #include <ls-math/os/unix/unix-so-definitions.hpp>
 #endif
 
 #endif

+ 1 - 1
include/ls_math/os/unix/unix_so_definitions.hpp → include/ls-math/os/unix/unix-so-definitions.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-11-06
- * Changed:         2022-11-06
+ * Changed:         2023-06-02
  *
  * */
 

+ 4 - 4
include/ls_math/os/windows/msvc_dll_definitions.hpp → include/ls-math/os/windows/msvc-dll-definitions.hpp

@@ -3,15 +3,15 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-11-06
- * Changed:         2022-11-06
+ * Changed:         2023-06-02
  *
  * */
 
 #ifndef LS_MATH_MSVC_DLL_DEFINITIONS_HPP
 #define LS_MATH_MSVC_DLL_DEFINITIONS_HPP
 
-#define LS_MATH_DLL_EXPORT        __declspec(dllexport)
-#define LS_MATH_DLL_IMPORT        __declspec(dllimport)
-#define LS_MATH_DYNAMIC_GOAL      LS_MATH_DLL_EXPORT
+#define LS_MATH_DLL_EXPORT __declspec(dllexport)
+#define LS_MATH_DLL_IMPORT __declspec(dllimport)
+#define LS_MATH_DYNAMIC_GOAL LS_MATH_DLL_EXPORT
 
 #endif

+ 20 - 20
include/ls_math/vector/Vector2.hpp → include/ls-math/vector/Vector2.hpp

@@ -3,16 +3,16 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-08-05
- * Changed:         2022-11-06
+ * Changed:         2023-06-02
  *
  * */
 
 #ifndef LS_MATH_VECTOR2_HPP
 #define LS_MATH_VECTOR2_HPP
 
-#include <ls_math/core/types/VectorTypes.hpp>
-#include <ls_math/os/dynamic_goal.hpp>
 #include <cstdlib>
+#include <ls-math/core/types/VectorTypes.hpp>
+#include <ls-math/os/dynamic-goal.hpp>
 
 namespace ls::math::vector
 {
@@ -20,44 +20,44 @@ namespace ls::math::vector
   {
     public:
 
-      Vector2(const ls::math::core::type::vector2_component& _x, const ls::math::core::type::vector2_component& _y);
+      Vector2(const ls::math::core::type::vector2_component &_x, const ls::math::core::type::vector2_component &_y);
       ~Vector2() = default;
 
       // arithmetic operations
 
-      ls::math::vector::Vector2 operator+(const ls::math::vector::Vector2& _vector) const;
-      ls::math::vector::Vector2 operator-(const ls::math::vector::Vector2& _vector) const;
-      ls::math::core::type::vector_scalar operator*(const ls::math::vector::Vector2& _vector) const;
+      ls::math::vector::Vector2 operator+(const ls::math::vector::Vector2 &_vector) const;
+      ls::math::vector::Vector2 operator-(const ls::math::vector::Vector2 &_vector) const;
+      ls::math::core::type::vector_scalar operator*(const ls::math::vector::Vector2 &_vector) const;
       ls::math::vector::Vector2 operator*(double _value);
       ls::math::vector::Vector2 operator/(double _divisor);
 
       // comparison operations
 
-      bool operator==(const Vector2& _vector);
-      bool operator!=(const Vector2& _vector);
+      bool operator==(const Vector2 &_vector);
+      bool operator!=(const Vector2 &_vector);
 
       // additional functionality
 
-      [[nodiscard]] static ls::math::vector::Vector2 add(const ls::math::vector::Vector2& _leftAddend, const ls::math::vector::Vector2& _rightAddend);
-      [[nodiscard]] static ls::math::core::type::vector_scalar dot(const ls::math::vector::Vector2& _leftAddend, const ls::math::vector::Vector2& _rightAddend);
-      [[nodiscard]] ls::math::core::type::vector2_components getComponents();
+      [[nodiscard]] static ls::math::vector::Vector2 add(const ls::math::vector::Vector2 &_leftAddend, const ls::math::vector::Vector2 &_rightAddend);
+      [[nodiscard]] static ls::math::core::type::vector_scalar dot(const ls::math::vector::Vector2 &_leftAddend, const ls::math::vector::Vector2 &_rightAddend);
+      [[nodiscard]] ls::math::core::type::vector2_components getComponents() const;
       [[nodiscard]] double getLength();
       [[nodiscard]] ls::math::core::type::vector2_component getX();
       [[nodiscard]] ls::math::core::type::vector2_component getY();
       [[nodiscard]] ls::math::vector::Vector2 normalize();
-      void setX(const ls::math::core::type::vector2_component& _value);
-      void setY(const ls::math::core::type::vector2_component& _value);
-      [[nodiscard]] static ls::math::vector::Vector2 subtract(const ls::math::vector::Vector2& _leftAddend, const ls::math::vector::Vector2& _rightAddend);
+      void setX(const ls::math::core::type::vector2_component &_value);
+      void setY(const ls::math::core::type::vector2_component &_value);
+      [[nodiscard]] static ls::math::vector::Vector2 subtract(const ls::math::vector::Vector2 &_leftAddend, const ls::math::vector::Vector2 &_rightAddend);
 
     private:
 
       ls::math::core::type::vector2_components components{};
 
-      [[nodiscard]] static ls::math::vector::Vector2 _add(const ls::math::vector::Vector2& _leftAddend, const ls::math::vector::Vector2& _rightAddend);
-      [[nodiscard]] static ls::math::core::type::vector_scalar _dot(const ls::math::vector::Vector2& _leftAddend, const ls::math::vector::Vector2& _rightAddend);
-      [[nodiscard]] static double _getLength(const ls::math::core::type::vector2_component& _x, const ls::math::core::type::vector2_component& _y);
-      [[nodiscard]] static ls::math::vector::Vector2 _operatorDivision(const ls::math::core::type::vector2_component& _x, const ls::math::core::type::vector2_component& _y, double _divisor);
-      [[nodiscard]] static ls::math::vector::Vector2 _subtract(const ls::math::vector::Vector2& _leftAddend, const ls::math::vector::Vector2& _rightAddend);
+      [[nodiscard]] static ls::math::vector::Vector2 _add(const ls::math::vector::Vector2 &_leftAddend, const ls::math::vector::Vector2 &_rightAddend);
+      [[nodiscard]] static ls::math::core::type::vector_scalar _dot(const ls::math::vector::Vector2 &_leftAddend, const ls::math::vector::Vector2 &_rightAddend);
+      [[nodiscard]] static double _getLength(const ls::math::core::type::vector2_component &_x, const ls::math::core::type::vector2_component &_y);
+      [[nodiscard]] static ls::math::vector::Vector2 _operatorDivision(const ls::math::core::type::vector2_component &_x, const ls::math::core::type::vector2_component &_y, double _divisor);
+      [[nodiscard]] static ls::math::vector::Vector2 _subtract(const ls::math::vector::Vector2 &_leftAddend, const ls::math::vector::Vector2 &_rightAddend);
   };
 }
 

+ 134 - 0
source/ls-math/vector/Vector2.cpp

@@ -0,0 +1,134 @@
+/*
+ * Author:          Patrick-Christopher Mattulat
+ * Company:         Lynar Studios
+ * E-Mail:          webmaster@lynarstudios.com
+ * Created:         2022-08-05
+ * Changed:         2023-06-02
+ *
+ * */
+
+#include <cmath>
+#include <limits>
+#include <ls-math/vector/Vector2.hpp>
+
+using ls::math::core::type::vector2_component;
+using ls::math::core::type::vector2_components;
+using ls::math::core::type::vector_scalar;
+using ls::math::vector::Vector2;
+
+Vector2::Vector2(const vector2_component &_x, const vector2_component &_y)
+{
+  this->components[0] = _x;
+  this->components[1] = _y;
+}
+
+Vector2 Vector2::operator+(const Vector2 &_vector) const
+{
+  return Vector2::_add(*this, _vector);
+}
+
+Vector2 Vector2::operator-(const Vector2 &_vector) const
+{
+  return Vector2::_subtract(*this, _vector);
+}
+
+vector_scalar Vector2::operator*(const Vector2 &_vector) const
+{
+  return Vector2::_dot(*this, _vector);
+}
+
+Vector2 Vector2::operator*(double _value)
+{
+  return Vector2{components[0] * _value, components[1] * _value};
+}
+
+Vector2 Vector2::operator/(double _divisor)
+{
+  return Vector2::_operatorDivision(this->components[0], this->components[1], _divisor);
+}
+
+bool Vector2::operator==(const Vector2 &_vector)
+{
+  return this->components[0] == _vector.components[0] && this->components[1] == _vector.components[1];
+}
+
+bool Vector2::operator!=(const Vector2 &_vector)
+{
+  return this->components[0] != _vector.components[0] || this->components[1] != _vector.components[1];
+}
+
+Vector2 Vector2::add(const Vector2 &_leftAddend, const Vector2 &_rightAddend)
+{
+  return Vector2::_add(_leftAddend, _rightAddend);
+}
+
+vector_scalar Vector2::dot(const Vector2 &_leftAddend, const Vector2 &_rightAddend)
+{
+  return Vector2::_dot(_leftAddend, _rightAddend);
+}
+
+vector2_components Vector2::getComponents() const
+{
+  return this->components;
+}
+
+double Vector2::getLength()
+{
+  return Vector2::_getLength(this->components[0], this->components[1]);
+}
+
+vector2_component Vector2::getX()
+{
+  return this->components[0];
+}
+
+vector2_component Vector2::getY()
+{
+  return this->components[1];
+}
+
+Vector2 Vector2::normalize()
+{
+  double length = Vector2::_getLength(this->components[0], this->components[1]) + std::numeric_limits<double>::min();
+  return Vector2::_operatorDivision(this->components[0], this->components[1], length);
+}
+
+void Vector2::setX(const vector2_component &_value)
+{
+  this->components[0] = _value;
+}
+
+void Vector2::setY(const vector2_component &_value)
+{
+  this->components[1] = _value;
+}
+
+Vector2 Vector2::subtract(const Vector2 &_leftAddend, const Vector2 &_rightAddend)
+{
+  return Vector2::_subtract(_leftAddend, _rightAddend);
+}
+
+Vector2 Vector2::_add(const Vector2 &_leftAddend, const Vector2 &_rightAddend)
+{
+  return Vector2{_leftAddend.components[0] + _rightAddend.components[0], _leftAddend.components[1] + _rightAddend.components[1]};
+}
+
+vector_scalar Vector2::_dot(const Vector2 &_leftAddend, const Vector2 &_rightAddend)
+{
+  return _leftAddend.components[0] * _rightAddend.components[0] + _leftAddend.components[1] * _rightAddend.components[1];
+}
+
+Vector2 Vector2::_subtract(const Vector2 &_leftAddend, const Vector2 &_rightAddend)
+{
+  return Vector2{_leftAddend.components[0] - _rightAddend.components[0], _leftAddend.components[1] - _rightAddend.components[1]};
+}
+
+double Vector2::_getLength(const vector2_component &_x, const vector2_component &_y)
+{
+  return sqrt(_x * _x + _y * _y);
+}
+
+Vector2 Vector2::_operatorDivision(const vector2_component &_x, const vector2_component &_y, double _divisor)
+{
+  return Vector2{_x / _divisor, _y / _divisor};
+}

+ 0 - 129
source/ls_math/vector/Vector2.cpp

@@ -1,129 +0,0 @@
-/*
- * Author:          Patrick-Christopher Mattulat
- * Company:         Lynar Studios
- * E-Mail:          webmaster@lynarstudios.com
- * Created:         2022-08-05
- * Changed:         2022-11-08
- *
- * */
-
-#include <ls_math/vector/Vector2.hpp>
-#include <limits>
-#include <cmath>
-
-ls::math::vector::Vector2::Vector2(const ls::math::core::type::vector2_component &_x, const ls::math::core::type::vector2_component &_y)
-{
-  this->components[0] = _x;
-  this->components[1] = _y;
-}
-
-ls::math::vector::Vector2 ls::math::vector::Vector2::operator+(const ls::math::vector::Vector2& _vector) const
-{
-  return ls::math::vector::Vector2::_add(*this, _vector);
-}
-
-ls::math::vector::Vector2 ls::math::vector::Vector2::operator-(const ls::math::vector::Vector2& _vector) const
-{
-  return ls::math::vector::Vector2::_subtract(*this, _vector);
-}
-
-ls::math::core::type::vector_scalar ls::math::vector::Vector2::operator*(const ls::math::vector::Vector2& _vector) const
-{
-  return ls::math::vector::Vector2::_dot(*this, _vector);
-}
-
-ls::math::vector::Vector2 ls::math::vector::Vector2::operator*(double _value)
-{
-  return ls::math::vector::Vector2{components[0] * _value, components[1] * _value};
-}
-
-ls::math::vector::Vector2 ls::math::vector::Vector2::operator/(double _divisor)
-{
-  return ls::math::vector::Vector2::_operatorDivision(this->components[0], this->components[1], _divisor);
-}
-
-bool ls::math::vector::Vector2::operator==(const ls::math::vector::Vector2 &_vector)
-{
-  return this->components[0] == _vector.components[0] && this->components[1] == _vector.components[1];
-}
-
-bool ls::math::vector::Vector2::operator!=(const ls::math::vector::Vector2 &_vector)
-{
-  return this->components[0] != _vector.components[0] || this->components[1] != _vector.components[1];
-}
-
-ls::math::vector::Vector2 ls::math::vector::Vector2::add(const ls::math::vector::Vector2 &_leftAddend, const ls::math::vector::Vector2 &_rightAddend)
-{
-  return ls::math::vector::Vector2::_add(_leftAddend, _rightAddend);
-}
-
-ls::math::core::type::vector_scalar ls::math::vector::Vector2::dot(const ls::math::vector::Vector2 &_leftAddend, const ls::math::vector::Vector2 &_rightAddend)
-{
-  return ls::math::vector::Vector2::_dot(_leftAddend, _rightAddend);
-}
-
-ls::math::core::type::vector2_components ls::math::vector::Vector2::getComponents()
-{
-  return this->components;
-}
-
-double ls::math::vector::Vector2::getLength()
-{
-  return ls::math::vector::Vector2::_getLength(this->components[0], this->components[1]);
-}
-
-ls::math::core::type::vector2_component ls::math::vector::Vector2::getX()
-{
-  return this->components[0];
-}
-
-ls::math::core::type::vector2_component ls::math::vector::Vector2::getY()
-{
-  return this->components[1];
-}
-
-ls::math::vector::Vector2 ls::math::vector::Vector2::normalize()
-{
-  double length = ls::math::vector::Vector2::_getLength(this->components[0], this->components[1]) + std::numeric_limits<double>::min();
-  return ls::math::vector::Vector2::_operatorDivision(this->components[0], this->components[1], length);
-}
-
-void ls::math::vector::Vector2::setX(const ls::math::core::type::vector2_component &_value)
-{
-  this->components[0] = _value;
-}
-
-void ls::math::vector::Vector2::setY(const ls::math::core::type::vector2_component &_value)
-{
-  this->components[1] = _value;
-}
-
-ls::math::vector::Vector2 ls::math::vector::Vector2::subtract(const ls::math::vector::Vector2 &_leftAddend, const ls::math::vector::Vector2 &_rightAddend)
-{
-  return ls::math::vector::Vector2::_subtract(_leftAddend, _rightAddend);
-}
-
-ls::math::vector::Vector2 ls::math::vector::Vector2::_add(const ls::math::vector::Vector2 &_leftAddend, const ls::math::vector::Vector2 &_rightAddend)
-{
-  return ls::math::vector::Vector2{_leftAddend.components[0] + _rightAddend.components[0], _leftAddend.components[1] + _rightAddend.components[1]};
-}
-
-ls::math::core::type::vector_scalar ls::math::vector::Vector2::_dot(const ls::math::vector::Vector2 &_leftAddend, const ls::math::vector::Vector2 &_rightAddend)
-{
-  return _leftAddend.components[0] * _rightAddend.components[0] + _leftAddend.components[1] * _rightAddend.components[1];
-}
-
-ls::math::vector::Vector2 ls::math::vector::Vector2::_subtract(const ls::math::vector::Vector2 &_leftAddend, const ls::math::vector::Vector2 &_rightAddend)
-{
-  return ls::math::vector::Vector2{_leftAddend.components[0] - _rightAddend.components[0], _leftAddend.components[1] - _rightAddend.components[1]};
-}
-
-double ls::math::vector::Vector2::_getLength(const ls::math::core::type::vector2_component& _x, const ls::math::core::type::vector2_component& _y)
-{
-  return sqrt(_x * _x + _y * _y);
-}
-
-ls::math::vector::Vector2 ls::math::vector::Vector2::_operatorDivision(const ls::math::core::type::vector2_component &_x, const ls::math::core::type::vector2_component &_y, double _divisor)
-{
-  return ls::math::vector::Vector2{_x / _divisor, _y / _divisor};
-}

+ 13 - 17
test/cases/vector/Vector2Test.cpp

@@ -3,31 +3,27 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-08-05
- * Changed:         2022-08-07
+ * Changed:         2023-06-02
  *
  * */
 
-#include <gtest/gtest.h>
-#include <ls_math/ls_math_vector.hpp>
 #include <cmath>
+#include <gtest/gtest.h>
+#include <ls-math/ls-math-vector.hpp>
 
-using namespace ls::math::vector;
-using namespace ls::math::core::type;
+using ls::math::core::type::vector2_components;
+using ls::math::core::type::vector_scalar;
+using ls::math::vector::Vector2;
+using testing::Test;
 
 namespace
 {
-  class Vector2Test : public ::testing::Test
+  class Vector2Test : public Test
   {
-    protected:
+    public:
 
       Vector2Test() = default;
       ~Vector2Test() override = default;
-
-      void SetUp() override
-      {}
-
-      void TearDown() override
-      {}
   };
 
   TEST_F(Vector2Test, operator_addition)
@@ -62,12 +58,12 @@ namespace
 
   TEST_F(Vector2Test, operator_divisor)
   {
-    Vector2 c = Vector2(150.0f, -25.0f);
+    auto c = Vector2(150.0f, -25.0f);
     Vector2 n = c / 152.4f;
 
     // round by two decimals
 
-    double powValue = pow(10.0f, (double)2);
+    double powValue = pow(10.0f, (double) 2);
     double roundedX = round(n.getX() * powValue) / powValue;
     double roundedY = round(n.getY() * powValue) / powValue;
 
@@ -107,7 +103,7 @@ namespace
 
   TEST_F(Vector2Test, dot)
   {
-    vector_scalar scalar = ls::math::vector::Vector2::dot(Vector2(3.0f, 4.0f), Vector2(5.0f, 3.0f));
+    vector_scalar scalar = Vector2::dot(Vector2(3.0f, 4.0f), Vector2(5.0f, 3.0f));
     ASSERT_FLOAT_EQ(27.0f, scalar);
   }
 
@@ -173,7 +169,7 @@ namespace
 
   TEST_F(Vector2Test, subtract)
   {
-    Vector2 c = ls::math::vector::Vector2::subtract(Vector2(3.0f, 4.0f), Vector2(5.0f, 3.0f));
+    Vector2 c = Vector2::subtract(Vector2(3.0f, 4.0f), Vector2(5.0f, 3.0f));
 
     ASSERT_FLOAT_EQ(-2.0f, c.getX());
     ASSERT_FLOAT_EQ(1.0f, c.getY());