diff --git a/Geometry.workspace.layout b/Geometry.workspace.layout
index e46768a..1c395b7 100644
--- a/Geometry.workspace.layout
+++ b/Geometry.workspace.layout
@@ -1,5 +1,6 @@
-
+
+
diff --git a/GeometryC.sln b/GeometryC.sln
index aec3cde..7e0cf58 100644
--- a/GeometryC.sln
+++ b/GeometryC.sln
@@ -1,51 +1,51 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.1.32421.90
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geometry", "src\geometry.vcxproj", "{40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geometry-test", "test\geometry-test.vcxproj", "{48DAE315-715F-4044-ADF5-0308483B887C}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geometry-dev", "dev\geometry-dev.vcxproj", "{46DE6C8F-3179-4652-95CF-28D44AC4774A}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {48DAE315-715F-4044-ADF5-0308483B887C}.Debug|x64.ActiveCfg = Debug|x64
- {48DAE315-715F-4044-ADF5-0308483B887C}.Debug|x64.Build.0 = Debug|x64
- {48DAE315-715F-4044-ADF5-0308483B887C}.Debug|x86.ActiveCfg = Debug|Win32
- {48DAE315-715F-4044-ADF5-0308483B887C}.Debug|x86.Build.0 = Debug|Win32
- {48DAE315-715F-4044-ADF5-0308483B887C}.Release|x64.ActiveCfg = Release|x64
- {48DAE315-715F-4044-ADF5-0308483B887C}.Release|x64.Build.0 = Release|x64
- {48DAE315-715F-4044-ADF5-0308483B887C}.Release|x86.ActiveCfg = Release|Win32
- {48DAE315-715F-4044-ADF5-0308483B887C}.Release|x86.Build.0 = Release|Win32
- {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Debug|x64.ActiveCfg = Debug|x64
- {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Debug|x64.Build.0 = Debug|x64
- {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Debug|x86.ActiveCfg = Debug|Win32
- {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Debug|x86.Build.0 = Debug|Win32
- {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Release|x64.ActiveCfg = Release|x64
- {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Release|x64.Build.0 = Release|x64
- {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Release|x86.ActiveCfg = Release|Win32
- {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Release|x86.Build.0 = Release|Win32
- {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Debug|x64.ActiveCfg = Debug|x64
- {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Debug|x64.Build.0 = Debug|x64
- {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Debug|x86.ActiveCfg = Debug|Win32
- {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Debug|x86.Build.0 = Debug|Win32
- {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Release|x64.ActiveCfg = Release|x64
- {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Release|x64.Build.0 = Release|x64
- {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Release|x86.ActiveCfg = Release|Win32
- {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Release|x86.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {482D2212-4373-4231-88E5-34BD6B8CFF46}
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32421.90
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geometry", "src\geometry.vcxproj", "{40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geometry-test", "test\geometry-test.vcxproj", "{48DAE315-715F-4044-ADF5-0308483B887C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geometry-dev", "dev\geometry-dev.vcxproj", "{46DE6C8F-3179-4652-95CF-28D44AC4774A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {48DAE315-715F-4044-ADF5-0308483B887C}.Debug|x64.ActiveCfg = Debug|x64
+ {48DAE315-715F-4044-ADF5-0308483B887C}.Debug|x64.Build.0 = Debug|x64
+ {48DAE315-715F-4044-ADF5-0308483B887C}.Debug|x86.ActiveCfg = Debug|Win32
+ {48DAE315-715F-4044-ADF5-0308483B887C}.Debug|x86.Build.0 = Debug|Win32
+ {48DAE315-715F-4044-ADF5-0308483B887C}.Release|x64.ActiveCfg = Release|x64
+ {48DAE315-715F-4044-ADF5-0308483B887C}.Release|x64.Build.0 = Release|x64
+ {48DAE315-715F-4044-ADF5-0308483B887C}.Release|x86.ActiveCfg = Release|Win32
+ {48DAE315-715F-4044-ADF5-0308483B887C}.Release|x86.Build.0 = Release|Win32
+ {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Debug|x64.ActiveCfg = Debug|x64
+ {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Debug|x64.Build.0 = Debug|x64
+ {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Debug|x86.ActiveCfg = Debug|Win32
+ {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Debug|x86.Build.0 = Debug|Win32
+ {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Release|x64.ActiveCfg = Release|x64
+ {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Release|x64.Build.0 = Release|x64
+ {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Release|x86.ActiveCfg = Release|Win32
+ {40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}.Release|x86.Build.0 = Release|Win32
+ {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Debug|x64.ActiveCfg = Debug|x64
+ {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Debug|x64.Build.0 = Debug|x64
+ {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Debug|x86.ActiveCfg = Debug|Win32
+ {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Debug|x86.Build.0 = Debug|Win32
+ {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Release|x64.ActiveCfg = Release|x64
+ {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Release|x64.Build.0 = Release|x64
+ {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Release|x86.ActiveCfg = Release|Win32
+ {46DE6C8F-3179-4652-95CF-28D44AC4774A}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {482D2212-4373-4231-88E5-34BD6B8CFF46}
+ EndGlobalSection
+EndGlobal
diff --git a/dev/geometry-dev.layout b/dev/geometry-dev.layout
index 39a63a4..e500d34 100644
--- a/dev/geometry-dev.layout
+++ b/dev/geometry-dev.layout
@@ -1,10 +1,10 @@
-
+
-
+
diff --git a/dev/geometry-dev.vcxproj b/dev/geometry-dev.vcxproj
index b3c937c..7329822 100644
--- a/dev/geometry-dev.vcxproj
+++ b/dev/geometry-dev.vcxproj
@@ -1,165 +1,165 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
-
-
-
-
- {40ca6fb4-135f-4d54-a8d9-7338ba56e6a7}
-
-
-
- 16.0
- Win32Proj
- {46de6c8f-3179-4652-95cf-28d44ac4774a}
- geometry-dev
- 10.0
-
-
-
- Application
- true
- v143
- Unicode
-
-
- Application
- false
- v143
- true
- Unicode
-
-
- Application
- true
- v143
- Unicode
-
-
- Application
- false
- v143
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- false
-
-
- true
-
-
- false
-
-
-
- Level3
- true
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- CompileAsC
- $(SolutionDir)src;%(AdditionalIncludeDirectories)
-
-
- Console
- true
-
-
-
-
- Level3
- true
- true
- true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- CompileAsC
- $(SolutionDir)src;%(AdditionalIncludeDirectories)
-
-
- Console
- true
- true
- true
-
-
-
-
- Level3
- true
- _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- CompileAsC
- $(SolutionDir)src;%(AdditionalIncludeDirectories)
-
-
- Console
- true
-
-
-
-
- Level3
- true
- true
- true
- NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- CompileAsC
- MaxSpeed
- $(SolutionDir)src;%(AdditionalIncludeDirectories)
- Neither
- Sync
- NotSet
- Precise
-
-
- Console
- true
- true
- true
-
-
-
-
-
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+
+
+
+
+ {40ca6fb4-135f-4d54-a8d9-7338ba56e6a7}
+
+
+
+ 16.0
+ Win32Proj
+ {46de6c8f-3179-4652-95cf-28d44ac4774a}
+ geometry-dev
+ 10.0
+
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+ true
+
+
+ false
+
+
+
+ Level3
+ true
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ CompileAsC
+ $(SolutionDir)src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ CompileAsC
+ $(SolutionDir)src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ CompileAsC
+ $(SolutionDir)src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ CompileAsC
+ MaxSpeed
+ $(SolutionDir)src;%(AdditionalIncludeDirectories)
+ Neither
+ Sync
+ NotSet
+ Precise
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
\ No newline at end of file
diff --git a/dev/geometry-dev.vcxproj.filters b/dev/geometry-dev.vcxproj.filters
index 669bc4e..48814f7 100644
--- a/dev/geometry-dev.vcxproj.filters
+++ b/dev/geometry-dev.vcxproj.filters
@@ -1,22 +1,22 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Исходные файлы
-
-
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Исходные файлы
+
+
\ No newline at end of file
diff --git a/dev/geometry-dev.vcxproj.user b/dev/geometry-dev.vcxproj.user
index 88a5509..0f14913 100644
--- a/dev/geometry-dev.vcxproj.user
+++ b/dev/geometry-dev.vcxproj.user
@@ -1,4 +1,4 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/dev/main.c b/dev/main.c
index 9db6f02..93cc706 100644
--- a/dev/main.c
+++ b/dev/main.c
@@ -135,7 +135,7 @@ void print_matrix(const DPMatrix3x3* matrix)
printf("(%lf, %lf, %lf)\n", matrix->r2c1, matrix->r2c2, matrix->r2c3);
printf("(%lf, %lf, %lf)\n\n", matrix->r3c1, matrix->r3c2, matrix->r3c3);
}
-
+/*
int main()
{
DPMatrix3x3 m1, m2, check;
@@ -170,3 +170,18 @@ int main()
return 0;
}
+*/
+
+int main()
+{
+SPVector2 vector;
+
+sp_vector2_set(0, 0, &vector);
+
+printf("SPVector2(%f, %f), module = %d\n",
+ vector.x1,
+ vector.x2,
+ sp_vector2_is_zero(&vector)
+);
+ return 0;
+}
diff --git a/docs/documentation.odt b/docs/documentation.odt
new file mode 100644
index 0000000..a15f6fd
Binary files /dev/null and b/docs/documentation.odt differ
diff --git a/src/geometry.cbp b/src/geometry.cbp
index 91658c5..08bb01b 100644
--- a/src/geometry.cbp
+++ b/src/geometry.cbp
@@ -58,10 +58,16 @@
+
+
+
+
+
+
diff --git a/src/geometry.h b/src/geometry.h
index 1cbdaee..ecb9e4b 100644
--- a/src/geometry.h
+++ b/src/geometry.h
@@ -1,19 +1,21 @@
-#ifndef __GEOMETRY_H__
-#define __GEOMETRY_H__
-
-#include "basis.h"
-
-#include "angle.h"
-
-#include "vector2.h"
-#include "vector3.h"
-
+#ifndef __GEOMETRY_H__
+#define __GEOMETRY_H__
+
+#include "basis.h"
+
+#include "angle.h"
+
+#include "vector2.h"
+#include "vector3.h"
+
+#include "matrixes.h"
#include "matrix2x2.h"
-#include "matrix3x3.h"
-
-#include "rotation3.h"
-
-#include "quaternion.h"
-#include "versor.h"
-
-#endif
+#include "matrix2x3.h"
+#include "matrix3x3.h"
+
+#include "rotation3.h"
+
+#include "quaternion.h"
+#include "versor.h"
+
+#endif
diff --git a/src/geometry.layout b/src/geometry.layout
index 173e12c..8f5c836 100644
--- a/src/geometry.layout
+++ b/src/geometry.layout
@@ -2,59 +2,19 @@
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -62,34 +22,34 @@
-
+
-
+
-
+
-
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
+
@@ -97,4 +57,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/geometry.vcxproj b/src/geometry.vcxproj
index 7e406c9..7fed42e 100644
--- a/src/geometry.vcxproj
+++ b/src/geometry.vcxproj
@@ -1,175 +1,175 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 16.0
- Win32Proj
- {40ca6fb4-135f-4d54-a8d9-7338ba56e6a7}
- geometry
- 10.0
-
-
-
- StaticLibrary
- true
- v143
- Unicode
-
-
- StaticLibrary
- false
- v143
- true
- Unicode
-
-
- StaticLibrary
- true
- v143
- Unicode
-
-
- StaticLibrary
- false
- v143
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- false
-
-
- true
-
-
- false
-
-
-
- Level3
- true
- WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)
- true
- NotUsing
-
-
-
-
- true
-
-
-
-
- Level3
- true
- true
- true
- WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)
- true
- NotUsing
-
-
-
-
- true
- true
- true
-
-
-
-
- Level3
- true
- _DEBUG;_LIB;%(PreprocessorDefinitions)
- true
- NotUsing
-
-
-
-
- true
-
-
-
-
- Level3
- true
- true
- true
- NDEBUG;_LIB;%(PreprocessorDefinitions)
- true
- NotUsing
-
-
-
-
- true
- true
- true
-
-
-
-
-
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 16.0
+ Win32Proj
+ {40ca6fb4-135f-4d54-a8d9-7338ba56e6a7}
+ geometry
+ 10.0
+
+
+
+ StaticLibrary
+ true
+ v143
+ Unicode
+
+
+ StaticLibrary
+ false
+ v143
+ true
+ Unicode
+
+
+ StaticLibrary
+ true
+ v143
+ Unicode
+
+
+ StaticLibrary
+ false
+ v143
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+ true
+
+
+ false
+
+
+
+ Level3
+ true
+ WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)
+ true
+ NotUsing
+
+
+
+
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)
+ true
+ NotUsing
+
+
+
+
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ _DEBUG;_LIB;%(PreprocessorDefinitions)
+ true
+ NotUsing
+
+
+
+
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_LIB;%(PreprocessorDefinitions)
+ true
+ NotUsing
+
+
+
+
+ true
+ true
+ true
+
+
+
+
+
\ No newline at end of file
diff --git a/src/geometry.vcxproj.filters b/src/geometry.vcxproj.filters
index 8262b96..b851ec4 100644
--- a/src/geometry.vcxproj.filters
+++ b/src/geometry.vcxproj.filters
@@ -1,78 +1,78 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Файлы заголовков
-
-
- Файлы заголовков
-
-
- Файлы заголовков
-
-
- Файлы заголовков
-
-
- Файлы заголовков
-
-
- Файлы заголовков
-
-
- Файлы заголовков
-
-
- Файлы заголовков
-
-
- Файлы заголовков
-
-
- Файлы заголовков
-
-
-
-
- Исходные файлы
-
-
- Исходные файлы
-
-
- Исходные файлы
-
-
- Исходные файлы
-
-
- Исходные файлы
-
-
- Исходные файлы
-
-
- Исходные файлы
-
-
- Исходные файлы
-
-
- Исходные файлы
-
-
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
\ No newline at end of file
diff --git a/src/geometry.vcxproj.user b/src/geometry.vcxproj.user
index 88a5509..0f14913 100644
--- a/src/geometry.vcxproj.user
+++ b/src/geometry.vcxproj.user
@@ -1,4 +1,4 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/src/matrix2x2.c b/src/matrix2x2.c
index 6ba579f..4bf7977 100644
--- a/src/matrix2x2.c
+++ b/src/matrix2x2.c
@@ -1,24 +1 @@
-#include "matrix2x2.h"
-
-#include
-#include "angle.h"
-
-const SPMatrix2x2 SP_ZERO_MATRIX2X2 = {
- 0.0f, 0.0f,
- 0.0f, 0.0f
-};
-
-const DPMatrix2x2 DP_ZERO_MATRIX2X2 = {
- 0.0, 0.0,
- 0.0, 0.0
-};
-
-const SPMatrix2x2 SP_IDENTITY_MATRIX2X2 = {
- 1.0f, 0.0f,
- 0.0f, 1.0f
-};
-
-const DPMatrix2x2 DP_IDENTITY_MATRIX2X2 = {
- 1.0, 0.0,
- 0.0, 1.0
-};
+#include "matrix2x2.h"
diff --git a/src/matrix2x2.h b/src/matrix2x2.h
index 5153223..eafea4e 100644
--- a/src/matrix2x2.h
+++ b/src/matrix2x2.h
@@ -3,24 +3,7 @@
#include "angle.h"
#include "vector2.h"
-
-typedef struct {
- float r1c1, r1c2;
- float r2c1, r2c2;
-} SPMatrix2x2;
-
-typedef struct {
- double r1c1, r1c2;
- double r2c1, r2c2;
-} DPMatrix2x2;
-
-extern const SPMatrix2x2 SP_ZERO_MATRIX2X2;
-
-extern const DPMatrix2x2 DP_ZERO_MATRIX2X2;
-
-extern const SPMatrix2x2 SP_IDENTITY_MATRIX2X2;
-
-extern const DPMatrix2x2 DP_IDENTITY_MATRIX2X2;
+#include "matrixes.h"
// =================== Reset ==================== //
@@ -124,22 +107,24 @@ static inline void dp_matrix2x2_copy(const DPMatrix2x2* from, DPMatrix2x2* to)
// ============= Copy to twin type ============== //
-static inline void sp_matrix2x2_copy_to_double(const SPMatrix2x2* from, DPMatrix2x2* to)
-{
- to->r1c1 = (double)from->r1c1;
- to->r1c2 = (double)from->r1c2;
- to->r2c1 = (double)from->r2c1;
- to->r2c2 = (double)from->r2c2;
-}
-
-static inline void dp_matrix2x2_copy_to_single(const DPMatrix2x2* from, SPMatrix2x2* to)
+static inline void sp_matrix2x2_set_from_double(const DPMatrix2x2* from, SPMatrix2x2* to)
{
to->r1c1 = (float)from->r1c1;
to->r1c2 = (float)from->r1c2;
+
to->r2c1 = (float)from->r2c1;
to->r2c2 = (float)from->r2c2;
}
+static inline void dp_matrix2x2_set_from_single(const SPMatrix2x2* from, DPMatrix2x2* to)
+{
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r1c2;
+
+ to->r2c1 = from->r2c1;
+ to->r2c2 = from->r2c2;
+}
+
// ================ Determinant ================= //
static inline float sp_matrix2x2_get_determinant(const SPMatrix2x2* matrix)
@@ -232,98 +217,78 @@ static inline int dp_matrix2x2_invert(DPMatrix2x2* matrix)
return 1;
}
-// =============== Make Transposed ============== //
+// =============== Set Transposed =============== //
-static inline void sp_matrix2x2_make_transposed(const SPMatrix2x2* matrix, SPMatrix2x2* result)
+static inline void sp_matrix2x2_set_transposed(const SPMatrix2x2* from, SPMatrix2x2* to)
{
- if (matrix == result) {
- sp_matrix2x2_transpose(result);
- return;
- }
+ float tmp = from->r1c2;
- result->r1c1 = matrix->r1c1;
- result->r1c2 = matrix->r2c1;
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r2c1;
- result->r2c1 = matrix->r1c2;
- result->r2c2 = matrix->r2c2;
+ to->r2c1 = tmp;
+ to->r2c2 = from->r2c2;
}
-static inline void dp_matrix2x2_make_transposed(const DPMatrix2x2* matrix, DPMatrix2x2* result)
+static inline void dp_matrix2x2_set_transposed(const DPMatrix2x2* from, DPMatrix2x2* to)
{
- if (matrix == result) {
- dp_matrix2x2_transpose(result);
- return;
- }
+ double tmp = from->r1c2;
- result->r1c1 = matrix->r1c1;
- result->r1c2 = matrix->r1c2;
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r2c1;
- result->r2c1 = matrix->r2c1;
- result->r2c2 = matrix->r2c2;
+ to->r2c1 = tmp;
+ to->r2c2 = from->r2c2;
}
-// ================ Make Inverted =============== //
+// ================ Set Inverted ================ //
-static inline int sp_matrix2x2_make_inverted(const SPMatrix2x2* matrix, SPMatrix2x2* result)
+static inline int sp_matrix2x2_set_inverted(const SPMatrix2x2* from, SPMatrix2x2* to)
{
- const float determinant = sp_matrix2x2_get_determinant(matrix);
+ const float determinant = sp_matrix2x2_get_determinant(from);
if (-SP_EPSYLON <= determinant && determinant <= SP_EPSYLON) {
return 0;
}
- const float r1c1 = matrix->r2c2;
- const float r1c2 = -matrix->r1c2;
+ const float r1c1 = from->r2c2;
+ const float r1c2 = -from->r1c2;
- const float r2c1 = -matrix->r2c1;
- const float r2c2 = matrix->r1c1;
+ const float r2c1 = -from->r2c1;
+ const float r2c2 = from->r1c1;
- result->r1c1 = r1c1 / determinant;
- result->r1c2 = r1c2 / determinant;
+ to->r1c1 = r1c1 / determinant;
+ to->r1c2 = r1c2 / determinant;
- result->r2c1 = r2c1 / determinant;
- result->r2c2 = r2c2 / determinant;
+ to->r2c1 = r2c1 / determinant;
+ to->r2c2 = r2c2 / determinant;
return 1;
}
-static inline int dp_matrix2x2_make_inverted(const DPMatrix2x2* matrix, DPMatrix2x2* result)
+static inline int dp_matrix2x2_set_inverted(const DPMatrix2x2* from, DPMatrix2x2* to)
{
- const double determinant = dp_matrix2x2_get_determinant(matrix);
+ const double determinant = dp_matrix2x2_get_determinant(from);
if (-DP_EPSYLON <= determinant && determinant <= DP_EPSYLON) {
return 0;
}
- const double r1c1 = matrix->r2c2;
- const double r1c2 = -matrix->r1c2;
+ const double r1c1 = from->r2c2;
+ const double r1c2 = -from->r1c2;
- const double r2c1 = -matrix->r2c1;
- const double r2c2 = matrix->r1c1;
+ const double r2c1 = -from->r2c1;
+ const double r2c2 = from->r1c1;
- result->r1c1 = r1c1 / determinant;
- result->r1c2 = r1c2 / determinant;
+ to->r1c1 = r1c1 / determinant;
+ to->r1c2 = r1c2 / determinant;
- result->r2c1 = r2c1 / determinant;
- result->r2c2 = r2c2 / determinant;
+ to->r2c1 = r2c1 / determinant;
+ to->r2c2 = r2c2 / determinant;
return 1;
}
-// ================ Set Diagonal ================ //
-
-static inline void sp_matrix2x2_set_main_diagonal(const float d1, const float d2, SPMatrix2x2* matrix)
-{
- matrix->r1c1 = d1;
- matrix->r2c2 = d2;
-}
-
-static inline void dp_matrix2x2_set_main_diagonal(const double d1, const double d2, DPMatrix2x2* matrix)
-{
- matrix->r1c1 = d1;
- matrix->r2c2 = d2;
-}
-
// ================= Set Row 1 ================== //
static inline void sp_matrix2x2_set_row1(const float c1, const float c2, SPMatrix2x2* matrix)
@@ -720,36 +685,4 @@ static inline void dp_matrix2x2_right_product(const DPMatrix2x2* matrix, const D
);
}
-// =============== Matrix Product =============== //
-
-static inline void sp_matrix2x2_matrix_product(const SPMatrix2x2* matrix1, const SPMatrix2x2* matrix2, SPMatrix2x2* result)
-{
- const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
- const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
-
- const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
- const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
-
- result->r1c1 = r1c1;
- result->r1c2 = r1c2;
-
- result->r2c1 = r2c1;
- result->r2c2 = r2c2;
-}
-
-static inline void dp_matrix2x2_matrix_product(const DPMatrix2x2* matrix1, const DPMatrix2x2* matrix2, DPMatrix2x2* result)
-{
- const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
- const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
-
- const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
- const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
-
- result->r1c1 = r1c1;
- result->r1c2 = r1c2;
-
- result->r2c1 = r2c1;
- result->r2c2 = r2c2;
-}
-
#endif
diff --git a/src/matrix2x3.h b/src/matrix2x3.h
new file mode 100644
index 0000000..ef7eead
--- /dev/null
+++ b/src/matrix2x3.h
@@ -0,0 +1,141 @@
+#ifndef _GEOMETRY_MATRIX2X3_H_
+#define _GEOMETRY_MATRIX2X3_H_
+
+#include "vector2.h"
+#include "vector3.h"
+#include "matrixes.h"
+
+// =================== Reset ==================== //
+
+static inline void sp_matrix2x3_reset(SPMatrix2x3* matrix)
+{
+ matrix->r1c1 = 0.0f;
+ matrix->r1c2 = 0.0f;
+
+ matrix->r2c1 = 0.0f;
+ matrix->r2c2 = 0.0f;
+
+ matrix->r3c1 = 0.0f;
+ matrix->r3c2 = 0.0f;
+}
+
+static inline void dp_matrix2x3_reset(DPMatrix2x3* matrix)
+{
+ matrix->r1c1 = 0.0;
+ matrix->r1c2 = 0.0;
+
+ matrix->r2c1 = 0.0;
+ matrix->r2c2 = 0.0;
+
+ matrix->r3c1 = 0.0;
+ matrix->r3c2 = 0.0;
+}
+
+// ==================== Copy ==================== //
+
+static inline void sp_matrix2x3_copy(const SPMatrix2x3* from, SPMatrix2x3* to)
+{
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r1c2;
+ to->r1c3 = from->r1c3;
+
+ to->r2c1 = from->r2c1;
+ to->r2c2 = from->r2c2;
+ to->r2c3 = from->r2c3;
+
+ to->r3c1 = from->r3c1;
+ to->r3c2 = from->r3c2;
+ to->r3c3 = from->r3c3;
+}
+
+static inline void dp_matrix2x3_copy(const DPMatrix2x3* from, DPMatrix2x3* to)
+{
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r1c2;
+
+ to->r2c1 = from->r2c1;
+ to->r2c2 = from->r2c2;
+
+ to->r3c1 = from->r3c1;
+ to->r3c2 = from->r3c2;
+}
+
+// ============= Copy to twin type ============== //
+
+static inline void sp_matrix2x3_set_from_double(const DPMatrix2x3* from, SPMatrix2x3* to)
+{
+ to->r1c1 = (float) from->r1c1;
+ to->r1c2 = (float) from->r1c2;
+
+ to->r2c1 = (float) from->r2c1;
+ to->r2c2 = (float) from->r2c2;
+
+ to->r3c1 = (float) from->r3c1;
+ to->r3c2 = (float) from->r3c2;
+}
+
+static inline void dp_matrix2x3_set_from_single(const SPMatrix2x3* from, DPMatrix2x3* to)
+{
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r1c2;
+
+ to->r2c1 = from->r2c1;
+ to->r2c2 = from->r2c2;
+
+ to->r3c1 = from->r3c1;
+ to->r3c2 = from->r3c2;
+}
+
+// =============== Set transposed =============== //
+
+static inline void sp_matrix2x3_set_transposed(const SPMatrix3x2* from, SPMatrix2x3* to)
+{
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r2c1;
+
+ to->r2c1 = from->r1c2;
+ to->r2c2 = from->r2c2;
+
+ to->r3c1 = from->r1c3;
+ to->r3c2 = from->r2c3;
+}
+
+static inline void dp_matrix2x3_set_transposed(const DPMatrix3x2* from, DPMatrix2x3* to)
+{
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r2c1;
+
+ to->r2c1 = from->r1c2;
+ to->r2c2 = from->r2c2;
+
+ to->r3c1 = from->r1c3;
+ to->r3c2 = from->r2c3;
+}
+
+// =============== Set transposed =============== //
+
+static inline void sp_matrix2x3_transpose_double(const DPMatrix3x2* from, SPMatrix2x3* to)
+{
+ to->r1c1 = (float) from->r1c1;
+ to->r1c2 = (float) from->r2c1;
+
+ to->r2c1 = (float) from->r1c2;
+ to->r2c2 = (float) from->r2c2;
+
+ to->r3c1 = (float) from->r1c3;
+ to->r3c2 = (float) from->r2c3;
+}
+
+static inline void dp_matrix2x3_transpose_single(const SPMatrix3x2* from, DPMatrix2x3* to)
+{
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r2c1;
+
+ to->r2c1 = from->r1c2;
+ to->r2c2 = from->r2c2;
+
+ to->r3c1 = from->r1c3;
+ to->r3c2 = from->r2c3;
+}
+
+#endif
diff --git a/src/matrix3x2.h b/src/matrix3x2.h
new file mode 100644
index 0000000..9cbd73e
--- /dev/null
+++ b/src/matrix3x2.h
@@ -0,0 +1,100 @@
+#ifndef _GEOMETRY_MATRIX3X2_H_
+#define _GEOMETRY_MATRIX3X2_H_
+
+// =================== Reset ==================== //
+
+static inline void sp_matrix3x2_reset(SPMatrix3x2* matrix)
+{
+ matrix->r1c1 = 0.0f;
+ matrix->r1c2 = 0.0f;
+ matrix->r1c3 = 0.0f;
+
+ matrix->r2c1 = 0.0f;
+ matrix->r2c2 = 0.0f;
+ matrix->r2c3 = 0.0f;
+}
+
+static inline void dp_matrix3x2_reset(DPMatrix3x2* matrix)
+{
+ matrix->r1c1 = 0.0;
+ matrix->r1c2 = 0.0;
+ matrix->r1c3 = 0.0;
+
+ matrix->r2c1 = 0.0;
+ matrix->r2c2 = 0.0;
+ matrix->r2c3 = 0.0;
+}
+
+// ============= Set from twin type ============= //
+
+static inline void sp_matrix3x2_set_from_double(const DPMatrix3x2* from, SPMatrix3x2* to)
+{
+ to->r1c1 = (float) from->r1c1;
+ to->r1c2 = (float) from->r1c2;
+ to->r1c3 = (float) from->r1c3;
+
+ to->r2c1 = (float) from->r2c1;
+ to->r2c2 = (float) from->r2c2;
+ to->r2c3 = (float) from->r2c3;
+}
+
+static inline void dp_matrix3x2_set_from_single(const SPMatrix3x2* from, DPMatrix3x2* to)
+{
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r1c2;
+ to->r1c3 = from->r1c3;
+
+ to->r2c1 = from->r2c1;
+ to->r2c2 = from->r2c2;
+ to->r2c3 = from->r2c3;
+}
+
+// =============== Set transposed =============== //
+
+static inline void sp_matrix3x2_set_transposed(const SPMatrix2x3* from, SPMatrix3x2* to)
+{
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r2c1;
+ to->r1c3 = from->r3c1;
+
+ to->r2c1 = from->r1c2;
+ to->r2c2 = from->r2c2;
+ to->r2c3 = from->r3c2;
+}
+
+static inline void dp_matrix3x2_set_transposed(const DPMatrix2x3* from, DPMatrix3x2* to)
+{
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r2c1;
+ to->r1c3 = from->r3c1;
+
+ to->r2c1 = from->r1c2;
+ to->r2c2 = from->r2c2;
+ to->r2c3 = from->r3c2;
+}
+
+// =============== Set transposed =============== //
+
+static inline void sp_matrix3x2_transpose_double(const DPMatrix2x3* from, SPMatrix3x2* to)
+{
+ to->r1c1 = (float) from->r1c1;
+ to->r1c2 = (float) from->r2c1;
+ to->r1c3 = (float) from->r3c1;
+
+ to->r2c1 = (float) from->r1c2;
+ to->r2c2 = (float) from->r2c2;
+ to->r2c3 = (float) from->r3c2;
+}
+
+static inline void dp_matrix3x2_transpose_single(const SPMatrix2x3* from, DPMatrix3x2* to)
+{
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r2c1;
+ to->r1c3 = from->r3c1;
+
+ to->r2c1 = from->r1c2;
+ to->r2c2 = from->r2c2;
+ to->r2c3 = from->r3c2;
+}
+
+#endif
diff --git a/src/matrix3x3.c b/src/matrix3x3.c
index 224a5e6..8111347 100644
--- a/src/matrix3x3.c
+++ b/src/matrix3x3.c
@@ -1,29 +1,5 @@
#include "matrix3x3.h"
-const SPMatrix3x3 SP_ZERO_MATRIX3X3 = {
- 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f
-};
-
-const DPMatrix3x3 DP_ZERO_MATRIX3X3 = {
- 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0
-};
-
-const SPMatrix3x3 SP_IDENTITY_MATRIX3X3 = {
- 1.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 1.0f
-};
-
-const DPMatrix3x3 DP_IDENTITY_MATRIX3X3 = {
- 1.0, 0.0, 0.0,
- 0.0, 1.0, 0.0,
- 0.0, 0.0, 1.0
-};
-
// ================= Inversion ================== //
int sp_matrix3x3_invert(SPMatrix3x3* matrix)
@@ -339,59 +315,3 @@ void dp_matrix3x3_get_weighted_sum5(
sum->r3c2 = (matrix1->r3c2 * weight1 + matrix2->r3c2 * weight2) + (matrix3->r3c2 * weight3 + matrix4->r3c2 * weight4) + matrix5->r3c2 * weight5;
sum->r3c3 = (matrix1->r3c3 * weight1 + matrix2->r3c3 * weight2) + (matrix3->r3c3 * weight3 + matrix4->r3c3 * weight4) + matrix5->r3c3 * weight5;
}
-
-// =============== Matrix Product =============== //
-
-void sp_matrix3x3_matrix_product(const SPMatrix3x3* matrix1, const SPMatrix3x3* matrix2, SPMatrix3x3* result)
-{
- const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
- const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
- const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
-
- const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
- const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
- const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
-
- const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
- const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
- const float r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
-
- result->r1c1 = r1c1;
- result->r1c2 = r1c2;
- result->r1c3 = r1c3;
-
- result->r2c1 = r2c1;
- result->r2c2 = r2c2;
- result->r2c3 = r2c3;
-
- result->r3c1 = r3c1;
- result->r3c2 = r3c2;
- result->r3c3 = r3c3;
-}
-
-void dp_matrix3x3_matrix_product(const DPMatrix3x3* matrix1, const DPMatrix3x3* matrix2, DPMatrix3x3* result)
-{
- const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
- const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
- const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
-
- const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
- const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
- const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
-
- const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
- const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
- const double r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
-
- result->r1c1 = r1c1;
- result->r1c2 = r1c2;
- result->r1c3 = r1c3;
-
- result->r2c1 = r2c1;
- result->r2c2 = r2c2;
- result->r2c3 = r2c3;
-
- result->r3c1 = r3c1;
- result->r3c2 = r3c2;
- result->r3c3 = r3c3;
-}
diff --git a/src/matrix3x3.h b/src/matrix3x3.h
index 25d5595..2e1ea9d 100644
--- a/src/matrix3x3.h
+++ b/src/matrix3x3.h
@@ -2,26 +2,7 @@
#define _GEOMETRY_MATRIX3X3_H_
#include "vector3.h"
-
-typedef struct {
- float r1c1, r1c2, r1c3;
- float r2c1, r2c2, r2c3;
- float r3c1, r3c2, r3c3;
-} SPMatrix3x3;
-
-typedef struct {
- double r1c1, r1c2, r1c3;
- double r2c1, r2c2, r2c3;
- double r3c1, r3c2, r3c3;
-} DPMatrix3x3;
-
-extern const SPMatrix3x3 SP_ZERO_MATRIX3X3;
-
-extern const DPMatrix3x3 DP_ZERO_MATRIX3X3;
-
-extern const SPMatrix3x3 SP_IDENTITY_MATRIX3X3;
-
-extern const DPMatrix3x3 DP_IDENTITY_MATRIX3X3;
+#include "matrixes.h"
// =================== Reset ==================== //
@@ -151,24 +132,9 @@ static inline void dp_matrix3x3_copy(const DPMatrix3x3* from, DPMatrix3x3* to)
to->r3c3 = from->r3c3;
}
-// ============= Copy to twin type ============== //
+// ============= Set from twin type ============= //
-static inline void sp_matrix3x3_copy_to_double(const SPMatrix3x3* from, DPMatrix3x3* to)
-{
- to->r1c1 = (double)from->r1c1;
- to->r1c2 = (double)from->r1c2;
- to->r1c3 = (double)from->r1c3;
-
- to->r2c1 = (double)from->r2c1;
- to->r2c2 = (double)from->r2c2;
- to->r2c3 = (double)from->r2c3;
-
- to->r3c1 = (double)from->r3c1;
- to->r3c2 = (double)from->r3c2;
- to->r3c3 = (double)from->r3c3;
-}
-
-static inline void dp_matrix3x3_copy_to_single(const DPMatrix3x3* from, SPMatrix3x3* to)
+static inline void sp_matrix3x3_set_from_double(const DPMatrix3x3* from, SPMatrix3x3* to)
{
to->r1c1 = (float)from->r1c1;
to->r1c2 = (float)from->r1c2;
@@ -183,6 +149,21 @@ static inline void dp_matrix3x3_copy_to_single(const DPMatrix3x3* from, SPMatrix
to->r3c3 = (float)from->r3c3;
}
+static inline void dp_matrix3x3_set_from_single(const SPMatrix3x3* from, DPMatrix3x3* to)
+{
+ to->r1c1 = from->r1c1;
+ to->r1c2 = from->r1c2;
+ to->r1c3 = from->r1c3;
+
+ to->r2c1 = from->r2c1;
+ to->r2c2 = from->r2c2;
+ to->r2c3 = from->r2c3;
+
+ to->r3c1 = from->r3c1;
+ to->r3c2 = from->r3c2;
+ to->r3c3 = from->r3c3;
+}
+
// ================ Determinant ================= //
static inline float sp_matrix3x3_get_determinant(const SPMatrix3x3* matrix)
@@ -785,10 +766,4 @@ static inline void dp_matrix3x3_right_product(const DPMatrix3x3* matrix, const D
);
}
-// =============== Matrix Product =============== //
-
-void sp_matrix3x3_matrix_product(const SPMatrix3x3* matrix1, const SPMatrix3x3* matrix2, SPMatrix3x3* result);
-
-void dp_matrix3x3_matrix_product(const DPMatrix3x3* matrix1, const DPMatrix3x3* matrix2, DPMatrix3x3* result);
-
#endif
diff --git a/src/matrixes.c b/src/matrixes.c
new file mode 100644
index 0000000..8be7c36
--- /dev/null
+++ b/src/matrixes.c
@@ -0,0 +1,257 @@
+#include "matrixes.h"
+
+// ========== Matrix Product 2x2 at 3x2 ========= //
+
+void sp_matrix_product_2x2_at_3x2(const SPMatrix2x2* matrix1, const SPMatrix3x2* matrix2, SPMatrix3x2* result)
+{
+ const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
+ const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
+ const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
+
+ const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
+ const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
+ const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
+
+ result->r1c1 = r1c1;
+ result->r1c2 = r1c2;
+ result->r1c3 = r1c3;
+
+ result->r2c1 = r2c1;
+ result->r2c2 = r2c2;
+ result->r2c3 = r2c3;
+}
+
+void dp_matrix_product_2x2_at_3x2(const DPMatrix2x2* matrix1, const DPMatrix3x2* matrix2, DPMatrix3x2* result)
+{
+ const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
+ const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
+ const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
+
+ const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
+ const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
+ const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
+
+ result->r1c1 = r1c1;
+ result->r1c2 = r1c2;
+ result->r1c3 = r1c3;
+
+ result->r2c1 = r2c1;
+ result->r2c2 = r2c2;
+ result->r2c3 = r2c3;
+}
+
+// ========== Matrix Product 2x3 at 2x2 ========= //
+
+void sp_matrix_product_2x3_at_2x2(const SPMatrix2x3* matrix1, const SPMatrix2x2* matrix2, SPMatrix2x3* result)
+{
+ const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
+ const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
+
+ const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
+ const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
+
+ const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
+ const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
+
+ result->r1c1 = r1c1;
+ result->r1c2 = r1c2;
+
+ result->r2c1 = r2c1;
+ result->r2c2 = r2c2;
+
+ result->r3c1 = r3c1;
+ result->r3c2 = r3c2;
+}
+
+void dp_matrix_product_2x3_at_2x2(const DPMatrix2x3* matrix1, const DPMatrix2x2* matrix2, DPMatrix2x3* result)
+{
+ const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
+ const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
+
+ const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
+ const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
+
+ const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
+ const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
+
+ result->r1c1 = r1c1;
+ result->r1c2 = r1c2;
+
+ result->r2c1 = r2c1;
+ result->r2c2 = r2c2;
+
+ result->r3c1 = r3c1;
+ result->r3c2 = r3c2;
+}
+
+// ========== Matrix Product 2x3 at 3x2 ========= //
+
+void sp_matrix_product_2x3_at_3x2(const SPMatrix2x3* matrix1, const SPMatrix3x2* matrix2, SPMatrix3x3* result)
+{
+ result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
+ result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
+ result->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
+
+ result->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
+ result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
+ result->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
+
+ result->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
+ result->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
+ result->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
+}
+
+void dp_matrix_product_2x3_at_3x2(const DPMatrix2x3* matrix1, const DPMatrix3x2* matrix2, DPMatrix3x3* result)
+{
+ result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
+ result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
+ result->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
+
+ result->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
+ result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
+ result->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
+
+ result->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
+ result->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
+ result->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
+}
+
+// ========== Matrix Product 3x2 at 3x3 ========= //
+
+void sp_matrix_product_3x2_at_3x3(const SPMatrix3x2* matrix1, const SPMatrix3x3* matrix2, SPMatrix3x2* result)
+{
+ const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
+ const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
+ const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
+
+ const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
+ const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
+ const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
+
+ result->r1c1 = r1c1;
+ result->r1c2 = r1c2;
+ result->r1c3 = r1c3;
+
+ result->r2c1 = r2c1;
+ result->r2c2 = r2c2;
+ result->r2c3 = r2c3;
+}
+
+void dp_matrix_product_3x2_at_3x3(const DPMatrix3x2* matrix1, const DPMatrix3x3* matrix2, DPMatrix3x2* result)
+{
+ const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
+ const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
+ const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
+
+ const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
+ const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
+ const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
+
+ result->r1c1 = r1c1;
+ result->r1c2 = r1c2;
+ result->r1c3 = r1c3;
+
+ result->r2c1 = r2c1;
+ result->r2c2 = r2c2;
+ result->r2c3 = r2c3;
+}
+
+// ========== Matrix Product 3x3 at 2x3 ========= //
+
+void sp_matrix_product_3x3_at_2x3(const SPMatrix3x3* matrix1, const SPMatrix2x3* matrix2, SPMatrix2x3* result)
+{
+ const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
+ const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
+
+ const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
+ const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
+
+ const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
+ const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
+
+ result->r1c1 = r1c1;
+ result->r1c2 = r1c2;
+
+ result->r2c1 = r2c1;
+ result->r2c2 = r2c2;
+
+ result->r3c1 = r3c1;
+ result->r3c2 = r3c2;
+}
+
+void dp_matrix_product_3x3_at_2x3(const DPMatrix3x3* matrix1, const DPMatrix2x3* matrix2, DPMatrix2x3* result)
+{
+ const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
+ const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
+
+ const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
+ const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
+
+ const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
+ const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
+
+ result->r1c1 = r1c1;
+ result->r1c2 = r1c2;
+
+ result->r2c1 = r2c1;
+ result->r2c2 = r2c2;
+
+ result->r3c1 = r3c1;
+ result->r3c2 = r3c2;
+}
+
+// ========== Matrix Product 3x3 at 3x3 ========= //
+
+void sp_matrix_product_3x3_at_3x3(const SPMatrix3x3* matrix1, const SPMatrix3x3* matrix2, SPMatrix3x3* result)
+{
+ const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
+ const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
+ const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
+
+ const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
+ const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
+ const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
+
+ const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
+ const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
+ const float r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
+
+ result->r1c1 = r1c1;
+ result->r1c2 = r1c2;
+ result->r1c3 = r1c3;
+
+ result->r2c1 = r2c1;
+ result->r2c2 = r2c2;
+ result->r2c3 = r2c3;
+
+ result->r3c1 = r3c1;
+ result->r3c2 = r3c2;
+ result->r3c3 = r3c3;
+}
+
+void dp_matrix_product_3x3_at_3x3(const DPMatrix3x3* matrix1, const DPMatrix3x3* matrix2, DPMatrix3x3* result)
+{
+ const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
+ const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
+ const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
+
+ const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
+ const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
+ const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
+
+ const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
+ const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
+ const double r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
+
+ result->r1c1 = r1c1;
+ result->r1c2 = r1c2;
+ result->r1c3 = r1c3;
+
+ result->r2c1 = r2c1;
+ result->r2c2 = r2c2;
+ result->r2c3 = r2c3;
+
+ result->r3c1 = r3c1;
+ result->r3c2 = r3c2;
+ result->r3c3 = r3c3;
+}
diff --git a/src/matrixes.h b/src/matrixes.h
new file mode 100644
index 0000000..dd63a11
--- /dev/null
+++ b/src/matrixes.h
@@ -0,0 +1,144 @@
+#ifndef _GEOMETRY_MATRIX_TYPES_H_
+#define _GEOMETRY_MATRIX_TYPES_H_
+
+// ================== Matrix2x2 ================= //
+
+typedef struct {
+ float r1c1, r1c2;
+ float r2c1, r2c2;
+} SPMatrix2x2;
+
+typedef struct {
+ double r1c1, r1c2;
+ double r2c1, r2c2;
+} DPMatrix2x2;
+
+// ================== Matrix2x3 ================= //
+
+typedef struct {
+ float r1c1, r1c2;
+ float r2c1, r2c2;
+ float r3c1, r3c2;
+} SPMatrix2x3;
+
+typedef struct {
+ double r1c1, r1c2;
+ double r2c1, r2c2;
+ double r3c1, r3c2;
+} DPMatrix2x3;
+
+// ================== Matrix3x2 ================= //
+
+typedef struct {
+ float r1c1, r1c2, r1c3;
+ float r2c1, r2c2, r2c3;
+} SPMatrix3x2;
+
+typedef struct {
+ double r1c1, r1c2, r1c3;
+ double r2c1, r2c2, r2c3;
+} DPMatrix3x2;
+
+// ================== Matrix3x3 ================= //
+
+typedef struct {
+ float r1c1, r1c2, r1c3;
+ float r2c1, r2c2, r2c3;
+ float r3c1, r3c2, r3c3;
+} SPMatrix3x3;
+
+typedef struct {
+ double r1c1, r1c2, r1c3;
+ double r2c1, r2c2, r2c3;
+ double r3c1, r3c2, r3c3;
+} DPMatrix3x3;
+
+// ========== Matrix Product 2x2 at 2x2 ========= //
+
+static inline void sp_matrix_product_2x2_at_2x2(const SPMatrix2x2* matrix1, const SPMatrix2x2* matrix2, SPMatrix2x2* result)
+{
+ const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
+ const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
+
+ const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
+ const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
+
+ result->r1c1 = r1c1;
+ result->r1c2 = r1c2;
+
+ result->r2c1 = r2c1;
+ result->r2c2 = r2c2;
+}
+
+static inline void dp_matrix_product_2x2_at_2x2(const DPMatrix2x2* matrix1, const DPMatrix2x2* matrix2, DPMatrix2x2* result)
+{
+ const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
+ const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
+
+ const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
+ const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
+
+ result->r1c1 = r1c1;
+ result->r1c2 = r1c2;
+
+ result->r2c1 = r2c1;
+ result->r2c2 = r2c2;
+}
+
+// ========== Matrix Product 2x2 at 3x2 ========= //
+
+void sp_matrix_product_2x2_at_3x2(const SPMatrix2x2* matrix1, const SPMatrix3x2* matrix2, SPMatrix3x2* result);
+
+void dp_matrix_product_2x2_at_3x2(const DPMatrix2x2* matrix1, const DPMatrix3x2* matrix2, DPMatrix3x2* result);
+
+// ========== Matrix Product 2x3 at 2x2 ========= //
+
+void sp_matrix_product_2x3_at_2x2(const SPMatrix2x3* matrix1, const SPMatrix2x2* matrix2, SPMatrix2x3* result);
+
+void dp_matrix_product_2x3_at_2x2(const DPMatrix2x3* matrix1, const DPMatrix2x2* matrix2, DPMatrix2x3* result);
+
+// ========== Matrix Product 2x3 at 3x2 ========= //
+
+void sp_matrix_product_2x3_at_3x2(const SPMatrix2x3* matrix1, const SPMatrix3x2* matrix2, SPMatrix3x3* result);
+
+void dp_matrix_product_2x3_at_3x2(const DPMatrix2x3* matrix1, const DPMatrix3x2* matrix2, DPMatrix3x3* result);
+
+// ========== Matrix Product 3x2 at 2x3 ========= //
+
+void sp_matrix_product_3x2_at_2x3(const SPMatrix3x2* matrix1, const SPMatrix2x3* matrix2, SPMatrix2x2* result)
+{
+ result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
+ result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
+
+ result->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
+ result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
+}
+
+void dp_matrix_product_3x2_at_2x3(const DPMatrix3x2* matrix1, const DPMatrix2x3* matrix2, DPMatrix2x2* result)
+{
+ result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
+ result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
+
+ result->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
+ result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
+}
+
+// ========== Matrix Product 3x2 at 3x3 ========= //
+
+void sp_matrix_product_3x2_at_3x3(const SPMatrix3x2* matrix1, const SPMatrix3x3* matrix2, SPMatrix3x2* result);
+
+void dp_matrix_product_3x2_at_3x3(const DPMatrix3x2* matrix1, const DPMatrix3x3* matrix2, DPMatrix3x2* result);
+
+// ========== Matrix Product 3x3 at 2x3 ========= //
+
+void sp_matrix_product_3x3_at_2x3(const SPMatrix3x3* matrix1, const SPMatrix2x3* matrix2, SPMatrix2x3* result);
+
+void dp_matrix_product_3x3_at_2x3(const DPMatrix3x3* matrix1, const DPMatrix2x3* matrix2, DPMatrix2x3* result);
+
+// ========== Matrix Product 3x3 at 3x3 ========= //
+
+void sp_matrix_product_3x3_at_3x3(const SPMatrix3x3* matrix1, const SPMatrix3x3* matrix2, SPMatrix3x3* result);
+
+void dp_matrix_product_3x3_at_3x3(const DPMatrix3x3* matrix1, const DPMatrix3x3* matrix2, DPMatrix3x3* result);
+
+#endif // _GEOMETRY_MATRIX_TYPES_H_
diff --git a/src/quaternion.h b/src/quaternion.h
index 37b590f..b818083 100644
--- a/src/quaternion.h
+++ b/src/quaternion.h
@@ -32,9 +32,27 @@ static inline void dp_quaternion_reset(DPQuaternion * quaternion)
quaternion->x3 = 0.0;
}
+// ================== Set Unit ================== //
+
+static inline void sp_quaternion_set_identity(SPQuaternion * quaternion)
+{
+ quaternion->s0 = 1.0f;
+ quaternion->x1 = 0.0f;
+ quaternion->x2 = 0.0f;
+ quaternion->x3 = 0.0f;
+}
+
+static inline void dp_quaternion_set_identity(DPQuaternion * quaternion)
+{
+ quaternion->s0 = 1.0;
+ quaternion->x1 = 0.0;
+ quaternion->x2 = 0.0;
+ quaternion->x3 = 0.0;
+}
+
// ==================== Set ===================== //
-static inline void sp_quaternion_set(const float s0, const float x1, const float x2, const float x3, SPQuaternion * quaternion)
+static inline void sp_quaternion_set_values(const float s0, const float x1, const float x2, const float x3, SPQuaternion * quaternion)
{
quaternion->s0 = s0;
quaternion->x1 = x1;
@@ -42,7 +60,7 @@ static inline void sp_quaternion_set(const float s0, const float x1, const float
quaternion->x3 = x3;
}
-static inline void dp_quaternion_set(const double s0, const double x1, const double x2, const double x3, DPQuaternion * quaternion)
+static inline void dp_quaternion_set_values(const double s0, const double x1, const double x2, const double x3, DPQuaternion * quaternion)
{
quaternion->s0 = s0;
quaternion->x1 = x1;
@@ -70,15 +88,7 @@ static inline void dp_quaternion_copy(const DPQuaternion* from, DPQuaternion* to
// ============= Copy to twin type ============== //
-static inline void sp_quaternion_copy_to_double(const SPQuaternion* versor, DPQuaternion* result)
-{
- result->s0 = (double)versor->s0;
- result->x1 = (double)versor->x1;
- result->x2 = (double)versor->x2;
- result->x3 = (double)versor->x3;
-}
-
-static inline void dp_quaternion_copy_to_single(const DPQuaternion* versor, SPQuaternion* result)
+static inline void sp_quaternion_copy_from_double(const DPQuaternion* versor, SPQuaternion* result)
{
result->s0 = (float)versor->s0;
result->x1 = (float)versor->x1;
@@ -86,6 +96,14 @@ static inline void dp_quaternion_copy_to_single(const DPQuaternion* versor, SPQu
result->x3 = (float)versor->x3;
}
+static inline void dp_quaternion_copy_from_single(const SPQuaternion* versor, DPQuaternion* result)
+{
+ result->s0 = versor->s0;
+ result->x1 = versor->x1;
+ result->x2 = versor->x2;
+ result->x3 = versor->x3;
+}
+
// ================= Inversion ================== //
static inline void sp_quaternion_conjugate(SPQuaternion* versor)
@@ -102,9 +120,9 @@ static inline void dp_quaternion_conjugate(DPQuaternion* versor)
versor->x3 = -versor->x3;
}
-// ================ Get Inverted ================ //
+// ================ Set Conjugate =============== //
-static inline void sp_quaternion_get_conjugate(const SPQuaternion* versor, SPQuaternion* result)
+static inline void sp_quaternion_set_conjugate(const SPQuaternion* versor, SPQuaternion* result)
{
result->s0 = versor->s0;
result->x1 = -versor->x1;
@@ -112,7 +130,25 @@ static inline void sp_quaternion_get_conjugate(const SPQuaternion* versor, SPQua
result->x3 = -versor->x3;
}
-static inline void dp_quaternion_get_conjugate(const DPQuaternion* versor, DPQuaternion* result)
+static inline void dp_quaternion_set_conjugate(const DPQuaternion* versor, DPQuaternion* result)
+{
+ result->s0 = versor->s0;
+ result->x1 = -versor->x1;
+ result->x2 = -versor->x2;
+ result->x3 = -versor->x3;
+}
+
+// ================ Get Inverted ================ //
+
+static inline void sp_quaternion_conjugate_double(const DPQuaternion* versor, SPQuaternion* result)
+{
+ result->s0 = (float)versor->s0;
+ result->x1 = -(float)versor->x1;
+ result->x2 = -(float)versor->x2;
+ result->x3 = -(float)versor->x3;
+}
+
+static inline void dp_quaternion_conjugate_single(const SPQuaternion* versor, DPQuaternion* result)
{
result->s0 = versor->s0;
result->x1 = -versor->x1;
diff --git a/src/vector2.c b/src/vector2.c
index 3a53b70..85654d5 100644
--- a/src/vector2.c
+++ b/src/vector2.c
@@ -1,73 +1,73 @@
-#include "vector2.h"
-
-const SPVector2 SP_ZERO_VECTOR2 = { 0.0f, 0.0f };
-const SPVector2 SP_X1_UNIT_VECTOR2 = { 1.0f, 0.0f };
-const SPVector2 SP_X2_UNIT_VECTOR2 = { 0.0f, 1.0f };
-
-const DPVector2 DP_ZERO_VECTOR2 = { 0.0, 0.0 };
-const DPVector2 DP_X1_UNIT_VECTOR2 = { 1.0, 0.0 };
-const DPVector2 DP_X2_UNIT_VECTOR2 = { 0.0, 1.0 };
-
-// =================== Angle ==================== //
-
-float sp_vector2_angle(const SPVector2* vector1, const SPVector2* vector2, const angle_unit_t unit)
-{
- if (vector1 == 0 || vector2 == 0) {
- return 0.0f;
- }
-
- const float square_module1 = sp_vector2_get_square_module(vector1);
-
- if (square_module1 <= SP_SQUARE_EPSYLON) {
- return 0.0f;
- }
-
- const float square_module2 = sp_vector2_get_square_module(vector2);
-
- if (square_module2 <= SP_SQUARE_EPSYLON) {
- return 0.0f;
- }
-
- const float cosine = sp_vector2_scalar(vector1, vector2) / sqrtf(square_module1 * square_module2);
-
- if (cosine >= 1.0f - SP_EPSYLON) {
- return 0.0f;
- }
-
- if (cosine <= -1.0f + SP_EPSYLON) {
- return sp_get_half_circle(unit);
- }
-
- return sp_convert_from_radians(acosf(cosine), unit);
-}
-
-double dp_vector2_angle(const DPVector2* vector1, const DPVector2* vector2, const angle_unit_t unit)
-{
- if (vector1 == 0 || vector2 == 0) {
- return 0.0;
- }
-
- const double square_module1 = dp_vector2_get_square_module(vector1);
-
- if (square_module1 <= DP_SQUARE_EPSYLON) {
- return 0.0;
- }
-
- const double square_module2 = dp_vector2_get_square_module(vector2);
-
- if (square_module2 <= DP_SQUARE_EPSYLON) {
- return 0.0;
- }
-
- const double cosine = dp_vector2_scalar(vector1, vector2) / sqrt(square_module1 * square_module2);
-
- if (cosine >= 1.0 - DP_EPSYLON) {
- return 0.0;
- }
-
- if (cosine <= -1.0 + DP_EPSYLON) {
- return dp_get_half_circle(unit);
- }
-
- return dp_convert_from_radians(acos(cosine), unit);
-}
+#include "vector2.h"
+
+const SPVector2 SP_ZERO_VECTOR2 = { 0.0f, 0.0f };
+const SPVector2 SP_X1_UNIT_VECTOR2 = { 1.0f, 0.0f };
+const SPVector2 SP_X2_UNIT_VECTOR2 = { 0.0f, 1.0f };
+
+const DPVector2 DP_ZERO_VECTOR2 = { 0.0, 0.0 };
+const DPVector2 DP_X1_UNIT_VECTOR2 = { 1.0, 0.0 };
+const DPVector2 DP_X2_UNIT_VECTOR2 = { 0.0, 1.0 };
+
+// =================== Angle ==================== //
+
+float sp_vector2_angle(const SPVector2* vector1, const SPVector2* vector2, const angle_unit_t unit)
+{
+ if (vector1 == 0 || vector2 == 0) {
+ return 0.0f;
+ }
+
+ const float square_module1 = sp_vector2_get_square_module(vector1);
+
+ if (square_module1 <= SP_SQUARE_EPSYLON) {
+ return 0.0f;
+ }
+
+ const float square_module2 = sp_vector2_get_square_module(vector2);
+
+ if (square_module2 <= SP_SQUARE_EPSYLON) {
+ return 0.0f;
+ }
+
+ const float cosine = sp_vector2_scalar(vector1, vector2) / sqrtf(square_module1 * square_module2);
+
+ if (cosine >= 1.0f - SP_EPSYLON) {
+ return 0.0f;
+ }
+
+ if (cosine <= -1.0f + SP_EPSYLON) {
+ return sp_get_half_circle(unit);
+ }
+
+ return sp_convert_from_radians(acosf(cosine), unit);
+}
+
+double dp_vector2_angle(const DPVector2* vector1, const DPVector2* vector2, const angle_unit_t unit)
+{
+ if (vector1 == 0 || vector2 == 0) {
+ return 0.0;
+ }
+
+ const double square_module1 = dp_vector2_get_square_module(vector1);
+
+ if (square_module1 <= DP_SQUARE_EPSYLON) {
+ return 0.0;
+ }
+
+ const double square_module2 = dp_vector2_get_square_module(vector2);
+
+ if (square_module2 <= DP_SQUARE_EPSYLON) {
+ return 0.0;
+ }
+
+ const double cosine = dp_vector2_scalar(vector1, vector2) / sqrt(square_module1 * square_module2);
+
+ if (cosine >= 1.0 - DP_EPSYLON) {
+ return 0.0;
+ }
+
+ if (cosine <= -1.0 + DP_EPSYLON) {
+ return dp_get_half_circle(unit);
+ }
+
+ return dp_convert_from_radians(acos(cosine), unit);
+}
diff --git a/src/vector2.h b/src/vector2.h
index e1c4a1c..c2a4aec 100644
--- a/src/vector2.h
+++ b/src/vector2.h
@@ -38,6 +38,20 @@ static inline void dp_vector2_reset(DPVector2* vector)
vector->x2 = 0.0;
}
+// ==================== Set ===================== //
+
+static inline void sp_vector2_set_values(const float x1, const float x2, SPVector2* to)
+{
+ to->x1 = x1;
+ to->x2 = x2;
+}
+
+static inline void dp_vector2_set_values(const double x1, const double x2, DPVector2* to)
+{
+ to->x1 = x1;
+ to->x2 = x2;
+}
+
// ==================== Copy ==================== //
static inline void sp_vector2_copy(const SPVector2* from, SPVector2* to)
@@ -52,18 +66,46 @@ static inline void dp_vector2_copy(const DPVector2* from, DPVector2* to)
to->x2 = from->x2;
}
-// ==================== Set ===================== //
+// ============= Copy to twin type ============== //
-static inline void sp_vector2_set(const float x1, const float x2, SPVector2* to)
+static inline void sp_vector2_copy_from_double(const DPVector2* from, SPVector2* to)
{
- to->x1 = x1;
- to->x2 = x2;
+ to->x1 = (float)from->x1;
+ to->x2 = (float)from->x2;
}
-static inline void dp_vector2_set(const double x1, const double x2, DPVector2* to)
+static inline void dp_vector2_copy_from_single(const SPVector2* from, DPVector2* to)
{
- to->x1 = x1;
- to->x2 = x2;
+ to->x1 = from->x1;
+ to->x2 = from->x2;
+}
+
+// =================== Reverse ================== //
+
+static inline void sp_vector2_reverse(const SPVector2* from, SPVector2* to)
+{
+ to->x1 = -from->x1;
+ to->x2 = -from->x2;
+}
+
+static inline void dp_vector2_reverse(const DPVector2* from, DPVector2* to)
+{
+ to->x1 = -from->x1;
+ to->x2 = -from->x2;
+}
+
+// ============= Reverse twin type ============== //
+
+static inline void sp_vector2_reverse_double(const DPVector2* from, SPVector2* to)
+{
+ to->x1 = -(float)from->x1;
+ to->x2 = -(float)from->x2;
+}
+
+static inline void dp_vector2_reverse_single(const SPVector2* from, DPVector2* to)
+{
+ to->x1 = -from->x1;
+ to->x2 = -from->x2;
}
// =================== Module =================== //
@@ -114,48 +156,6 @@ static inline int dp_vector2_is_unit(const DPVector2* vector)
return 1.0f - DP_TWO_EPSYLON <= square_module && square_module <= 1.0f + DP_TWO_EPSYLON;
}
-// ============= Copy to twin type ============== //
-
-static inline void sp_vector2_copy_to_double(const SPVector2* from, DPVector2* to)
-{
- to->x1 = (double)from->x1;
- to->x2 = (double)from->x2;
-}
-
-static inline void dp_vector2_copy_to_single(const DPVector2* from, SPVector2* to)
-{
- to->x1 = (float)from->x1;
- to->x2 = (float)from->x2;
-}
-
-// ================= Inversion ================== //
-
-static inline void sp_vector2_invert(SPVector2* vector)
-{
- vector->x1 = -vector->x1;
- vector->x2 = -vector->x2;
-}
-
-static inline void dp_vector2_invert(DPVector2* vector)
-{
- vector->x1 = -vector->x1;
- vector->x2 = -vector->x2;
-}
-
-// ================ Get Inverted ================ //
-
-static inline void sp_vector2_get_inverted(const SPVector2* vector, SPVector2* result)
-{
- result->x1 = -vector->x1;
- result->x2 = -vector->x2;
-}
-
-static inline void dp_vector2_get_inverted(const DPVector2* vector, DPVector2* result)
-{
- result->x1 = -vector->x1;
- result->x2 = -vector->x2;
-}
-
// ==================== Add ===================== //
static inline void sp_vector2_add(const SPVector2* vector1, const SPVector2* vector2, SPVector2* result)
diff --git a/src/vector3.c b/src/vector3.c
index ffd3c49..7ec09a7 100644
--- a/src/vector3.c
+++ b/src/vector3.c
@@ -1,75 +1,75 @@
-#include "vector3.h"
-
-const SPVector3 SP_ZERO_VECTOR3 = { 0.0f, 0.0f, 0.0f };
-const SPVector3 SP_X1_UNIT_VECTOR3 = { 1.0f, 0.0f, 0.0f };
-const SPVector3 SP_X2_UNIT_VECTOR3 = { 0.0f, 1.0f, 0.0f };
-const SPVector3 SP_X3_UNIT_VECTOR3 = { 0.0f, 0.0f, 1.0f };
-
-const DPVector3 DP_ZERO_VECTOR3 = { 0.0, 0.0, 0.0 };
-const DPVector3 DP_X1_UNIT_VECTOR3 = { 1.0, 0.0, 0.0 };
-const DPVector3 DP_X2_UNIT_VECTOR3 = { 0.0, 1.0, 0.0 };
-const DPVector3 DP_X3_UNIT_VECTOR3 = { 0.0, 0.0, 1.0 };
-
-// =================== Angle ==================== //
-
-float sp_vector3_angle(const SPVector3* vector1, const SPVector3* vector2, const angle_unit_t unit)
-{
- if (vector1 == 0 || vector2 == 0) {
- return 0.0f;
- }
-
- const float square_module1 = sp_vector3_get_square_module(vector1);
-
- if (square_module1 <= SP_SQUARE_EPSYLON) {
- return 0.0f;
- }
-
- const float square_module2 = sp_vector3_get_square_module(vector2);
-
- if (square_module2 <= SP_SQUARE_EPSYLON) {
- return 0.0f;
- }
-
- const float cosine = sp_vector3_scalar(vector1, vector2) / sqrtf(square_module1 * square_module2);
-
- if (cosine >= 1.0f - SP_EPSYLON) {
- return 0.0f;
- }
-
- if (cosine <= -1.0f + SP_EPSYLON) {
- return sp_get_half_circle(unit);
- }
-
- return sp_convert_from_radians(acosf(cosine), unit);
-}
-
-double dp_vector3_angle(const DPVector3* vector1, const DPVector3* vector2, const angle_unit_t unit)
-{
- if (vector1 == 0 || vector2 == 0) {
- return 0.0;
- }
-
- const double square_module1 = dp_vector3_get_square_module(vector1);
-
- if (square_module1 <= DP_SQUARE_EPSYLON) {
- return 0.0;
- }
-
- const double square_module2 = dp_vector3_get_square_module(vector2);
-
- if (square_module2 <= DP_SQUARE_EPSYLON) {
- return 0.0;
- }
-
- const double cosine = dp_vector3_scalar(vector1, vector2) / sqrt(square_module1 * square_module2);
-
- if (cosine >= 1.0 - DP_EPSYLON) {
- return 0.0;
- }
-
- if (cosine <= -1.0 + DP_EPSYLON) {
- return dp_get_half_circle(unit);
- }
-
- return dp_convert_from_radians(acos(cosine), unit);
-}
+#include "vector3.h"
+
+const SPVector3 SP_ZERO_VECTOR3 = { 0.0f, 0.0f, 0.0f };
+const SPVector3 SP_X1_UNIT_VECTOR3 = { 1.0f, 0.0f, 0.0f };
+const SPVector3 SP_X2_UNIT_VECTOR3 = { 0.0f, 1.0f, 0.0f };
+const SPVector3 SP_X3_UNIT_VECTOR3 = { 0.0f, 0.0f, 1.0f };
+
+const DPVector3 DP_ZERO_VECTOR3 = { 0.0, 0.0, 0.0 };
+const DPVector3 DP_X1_UNIT_VECTOR3 = { 1.0, 0.0, 0.0 };
+const DPVector3 DP_X2_UNIT_VECTOR3 = { 0.0, 1.0, 0.0 };
+const DPVector3 DP_X3_UNIT_VECTOR3 = { 0.0, 0.0, 1.0 };
+
+// =================== Angle ==================== //
+
+float sp_vector3_angle(const SPVector3* vector1, const SPVector3* vector2, const angle_unit_t unit)
+{
+ if (vector1 == 0 || vector2 == 0) {
+ return 0.0f;
+ }
+
+ const float square_module1 = sp_vector3_get_square_module(vector1);
+
+ if (square_module1 <= SP_SQUARE_EPSYLON) {
+ return 0.0f;
+ }
+
+ const float square_module2 = sp_vector3_get_square_module(vector2);
+
+ if (square_module2 <= SP_SQUARE_EPSYLON) {
+ return 0.0f;
+ }
+
+ const float cosine = sp_vector3_scalar(vector1, vector2) / sqrtf(square_module1 * square_module2);
+
+ if (cosine >= 1.0f - SP_EPSYLON) {
+ return 0.0f;
+ }
+
+ if (cosine <= -1.0f + SP_EPSYLON) {
+ return sp_get_half_circle(unit);
+ }
+
+ return sp_convert_from_radians(acosf(cosine), unit);
+}
+
+double dp_vector3_angle(const DPVector3* vector1, const DPVector3* vector2, const angle_unit_t unit)
+{
+ if (vector1 == 0 || vector2 == 0) {
+ return 0.0;
+ }
+
+ const double square_module1 = dp_vector3_get_square_module(vector1);
+
+ if (square_module1 <= DP_SQUARE_EPSYLON) {
+ return 0.0;
+ }
+
+ const double square_module2 = dp_vector3_get_square_module(vector2);
+
+ if (square_module2 <= DP_SQUARE_EPSYLON) {
+ return 0.0;
+ }
+
+ const double cosine = dp_vector3_scalar(vector1, vector2) / sqrt(square_module1 * square_module2);
+
+ if (cosine >= 1.0 - DP_EPSYLON) {
+ return 0.0;
+ }
+
+ if (cosine <= -1.0 + DP_EPSYLON) {
+ return dp_get_half_circle(unit);
+ }
+
+ return dp_convert_from_radians(acos(cosine), unit);
+}
diff --git a/src/vector3.h b/src/vector3.h
index c907832..aa8d162 100644
--- a/src/vector3.h
+++ b/src/vector3.h
@@ -44,6 +44,22 @@ static inline void dp_vector3_reset(DPVector3* vector)
vector->x3 = 0.0;
}
+// ==================== Set ===================== //
+
+static inline void sp_vector3_set_values(const float x1, const float x2, const float x3, SPVector3* to)
+{
+ to->x1 = x1;
+ to->x2 = x2;
+ to->x3 = x3;
+}
+
+static inline void dp_vector3_set_values(const double x1, const double x2, const double x3, DPVector3* to)
+{
+ to->x1 = x1;
+ to->x2 = x2;
+ to->x3 = x3;
+}
+
// ==================== Copy ==================== //
static inline void sp_vector3_copy(const SPVector3* from, SPVector3* to)
@@ -60,20 +76,52 @@ static inline void dp_vector3_copy(const DPVector3* from, DPVector3* to)
to->x3 = from->x3;
}
-// ==================== Set ===================== //
+// ============= Copy to twin type ============== //
-static inline void sp_vector3_set(const float x1, const float x2, const float x3, SPVector3* to)
+static inline void sp_vector3_copy_from_double(const DPVector3* from, SPVector3* to)
{
- to->x1 = x1;
- to->x2 = x2;
- to->x3 = x3;
+ to->x1 = (float)from->x1;
+ to->x2 = (float)from->x2;
+ to->x3 = (float)from->x3;
}
-static inline void dp_vector3_set(const double x1, const double x2, const double x3, DPVector3* to)
+static inline void dp_vector3_copy_from_single(const SPVector3* from, DPVector3* to)
{
- to->x1 = x1;
- to->x2 = x2;
- to->x3 = x3;
+ to->x1 = from->x1;
+ to->x2 = from->x2;
+ to->x3 = from->x3;
+}
+
+// =================== Reverse ================== //
+
+static inline void sp_vector3_reverse(const SPVector3* from, SPVector3* to)
+{
+ to->x1 = -from->x1;
+ to->x2 = -from->x2;
+ to->x3 = -from->x3;
+}
+
+static inline void dp_vector3_reverse(const DPVector3* from, DPVector3* to)
+{
+ to->x1 = -from->x1;
+ to->x2 = -from->x2;
+ to->x3 = -from->x3;
+}
+
+// ============= Reverse twin type ============== //
+
+static inline void sp_vector3_reverse_double(const DPVector3* from, SPVector3* to)
+{
+ to->x1 = -(float)from->x1;
+ to->x2 = -(float)from->x2;
+ to->x3 = -(float)from->x3;
+}
+
+static inline void dp_vector3_reverse_single(const SPVector3* from, DPVector3* to)
+{
+ to->x1 = -from->x1;
+ to->x2 = -from->x2;
+ to->x3 = -from->x3;
}
// =================== Module =================== //
@@ -124,54 +172,6 @@ static inline int dp_vector3_is_unit(const DPVector3* vector)
return 1.0f - DP_TWO_EPSYLON <= square_module && square_module <= 1.0f + DP_TWO_EPSYLON;
}
-// ============= Copy to twin type ============== //
-
-static inline void sp_vector3_copy_to_double(const SPVector3* from, DPVector3* to)
-{
- to->x1 = (double)from->x1;
- to->x2 = (double)from->x2;
- to->x3 = (double)from->x3;
-}
-
-static inline void dp_vector3_copy_to_single(const DPVector3* from, SPVector3* to)
-{
- to->x1 = (float)from->x1;
- to->x2 = (float)from->x2;
- to->x3 = (float)from->x3;
-}
-
-// ================= Inversion ================== //
-
-static inline void sp_vector3_invert(SPVector3* vector)
-{
- vector->x1 = -vector->x1;
- vector->x2 = -vector->x2;
- vector->x3 = -vector->x3;
-}
-
-static inline void dp_vector3_invert(DPVector3* vector)
-{
- vector->x1 = -vector->x1;
- vector->x2 = -vector->x2;
- vector->x3 = -vector->x3;
-}
-
-// ================ Get Inverted ================ //
-
-static inline void sp_vector3_get_inverted(const SPVector3* vector, SPVector3* result)
-{
- result->x1 = -vector->x1;
- result->x2 = -vector->x2;
- result->x3 = -vector->x3;
-}
-
-static inline void dp_vector3_get_inverted(const DPVector3* vector, DPVector3* result)
-{
- result->x1 = -vector->x1;
- result->x2 = -vector->x2;
- result->x3 = -vector->x3;
-}
-
// ==================== Add ===================== //
static inline void sp_vector3_add(const SPVector3* vector1, const SPVector3* vector2, SPVector3* result)
diff --git a/src/versor.h b/src/versor.h
index a450cd8..fa7361e 100644
--- a/src/versor.h
+++ b/src/versor.h
@@ -226,18 +226,7 @@ static inline int dp_versor_is_idle(const DPVersor* versor)
// ============= Copy to twin type ============== //
-static inline void sp_versor_copy_to_double(const SPVersor* versor, DPVersor* result)
-{
- dp_versor_set(
- (double)versor->_s0,
- (double)versor->_x1,
- (double)versor->_x2,
- (double)versor->_x3,
- result
- );
-}
-
-static inline void dp_versor_copy_to_single(const DPVersor* versor, SPVersor* result)
+static inline void sp_versor_from_double(const DPVersor* versor, SPVersor* result)
{
sp_versor_set(
(float)versor->_s0,
@@ -248,6 +237,17 @@ static inline void dp_versor_copy_to_single(const DPVersor* versor, SPVersor* re
);
}
+static inline void dp_versor_from_single(const SPVersor* versor, DPVersor* result)
+{
+ dp_versor_set(
+ (double)versor->_s0,
+ (double)versor->_x1,
+ (double)versor->_x2,
+ (double)versor->_x3,
+ result
+ );
+}
+
// ================= Inversion ================== //
static inline void sp_versor_invert(SPVersor* versor)
diff --git a/test/geometry-test.vcxproj b/test/geometry-test.vcxproj
index 6ca000b..466a968 100644
--- a/test/geometry-test.vcxproj
+++ b/test/geometry-test.vcxproj
@@ -1,162 +1,162 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- 16.0
- Win32Proj
- {48dae315-715f-4044-adf5-0308483b887c}
- geometry-test
- 10.0
-
-
-
- Application
- true
- v143
- Unicode
-
-
- Application
- false
- v143
- true
- Unicode
-
-
- Application
- true
- v143
- Unicode
-
-
- Application
- false
- v143
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- false
-
-
- true
-
-
- false
-
-
-
- Level3
- true
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- $(SolutionDir)src;%(AdditionalIncludeDirectories)
-
-
- Console
- true
-
-
-
-
- Level3
- true
- true
- true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- $(SolutionDir)src;%(AdditionalIncludeDirectories)
-
-
- Console
- true
- true
- true
-
-
-
-
- Level3
- true
- _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- $(SolutionDir)src;%(AdditionalIncludeDirectories)
-
-
- Console
- true
-
-
-
-
- Level3
- true
- true
- true
- NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- $(SolutionDir)src;%(AdditionalIncludeDirectories)
-
-
- Console
- true
- true
- true
-
-
-
-
- {40ca6fb4-135f-4d54-a8d9-7338ba56e6a7}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 16.0
+ Win32Proj
+ {48dae315-715f-4044-adf5-0308483b887c}
+ geometry-test
+ 10.0
+
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+ true
+
+
+ false
+
+
+
+ Level3
+ true
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ $(SolutionDir)src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ {40ca6fb4-135f-4d54-a8d9-7338ba56e6a7}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/geometry-test.vcxproj.filters b/test/geometry-test.vcxproj.filters
index 1e57359..d7e4b49 100644
--- a/test/geometry-test.vcxproj.filters
+++ b/test/geometry-test.vcxproj.filters
@@ -1,36 +1,36 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Исходные файлы
-
-
- Исходные файлы
-
-
- Исходные файлы
-
-
-
-
- Исходные файлы
-
-
- Исходные файлы
-
-
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
\ No newline at end of file
diff --git a/test/geometry-test.vcxproj.user b/test/geometry-test.vcxproj.user
index 88a5509..0f14913 100644
--- a/test/geometry-test.vcxproj.user
+++ b/test/geometry-test.vcxproj.user
@@ -1,4 +1,4 @@
-
-
-
+
+
+
\ No newline at end of file