Добавление тангентов (аналог версоров, но для двумерных пространств) / Adding of tangent pairs, it is like versors but for 2 dimensional spaces

This commit is contained in:
Andrey Pokidov 2024-12-19 00:16:52 +07:00
parent 5fd14e4627
commit 896c8615f5
7 changed files with 316 additions and 5 deletions

View file

@ -234,7 +234,7 @@ int main()
for (int j = 0; j < 1000; j++) {
for (unsigned int i = 0; i < amount; i++) {
bg_fp32_versor_combine(&versors1[i], &versors2[i], &results[i]);
bg_fp32_versor_get_rotation_matrix(&versors1[i], &matrixes[i]);
bg_fp32_versor_make_rotation_matrix(&versors1[i], &matrixes[i]);
bg_fp32_matrix3x3_right_product(&matrixes[i], &vectors[i], &vectors[i]);
//bg_fp32_versor_turn(&results[i], &vectors[i], &vectors[i]);
}

View file

@ -14,6 +14,8 @@
#include "matrix3x2.h"
#include "matrix3x3.h"
#include "tangent.h"
#include "rotation3.h"
#include "quaternion.h"

View file

@ -29,6 +29,7 @@
<ClInclude Include="matrixes.h" />
<ClInclude Include="quaternion.h" />
<ClInclude Include="rotation3.h" />
<ClInclude Include="tangent.h" />
<ClInclude Include="versor.h" />
<ClInclude Include="vector2.h" />
<ClInclude Include="vector3.h" />
@ -43,6 +44,7 @@
<ClCompile Include="matrixes.c" />
<ClCompile Include="quaternion.c" />
<ClCompile Include="rotation3.c" />
<ClCompile Include="tangent.c" />
<ClCompile Include="versor.c" />
<ClCompile Include="vector2.c" />
<ClCompile Include="vector3.c" />

View file

@ -54,6 +54,9 @@
<ClInclude Include="matrixes.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="tangent.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="angle.c">
@ -92,5 +95,8 @@
<ClCompile Include="matrix3x2.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="tangent.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup>
</Project>

5
basic-geometry/tangent.c Normal file
View file

@ -0,0 +1,5 @@
#include "tangent.h"
const BgFP32Tangent BG_FP32_IDLE_TANGENT = { 1.0f, 0.0f };
const BgFP64Tangent BG_FP64_IDLE_TANGENT = { 1.0, 0.0 };

296
basic-geometry/tangent.h Normal file
View file

Internal server error - Personal Git Server: Beyond coding. We Forge.

500

Internal server error

Forgejo version: 11.0.1+gitea-1.22.0

@ -0,0 +1,296 @@
#ifndef _GEOMETRY_TANGENT_H_
#define _GEOMETRY_TANGENT_H_
#include <math.h>
#include "basis.h"
#include "angle.h"
#include "vector2.h"
#include "matrix2x2.h"
typedef struct
{
float _cos, _sin;
} BgFP32Tangent;
typedef struct
{
double _cos, _sin;
} BgFP64Tangent;
extern const BgFP32Tangent BG_FP32_IDLE_TANGENT;
extern const BgFP64Tangent BG_FP64_IDLE_TANGENT;
// =================== Reset ==================== //
static inline void bg_fp32_tangent_reset(BgFP32Tangent* tangent)
{
tangent->_cos = 1.0f;
tangent->_sin = 0.0f;
}
static inline void bg_fp64_tangent_reset(BgFP64Tangent* tangent)
{
tangent->_cos = 1.0;