Переименование проектов / Renaming of projects
This commit is contained in:
parent
da61a9bf7c
commit
beb237fd4e
44 changed files with 6588 additions and 9 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
<CodeBlocks_workspace_file>
|
<CodeBlocks_workspace_file>
|
||||||
<Workspace title="Workspace">
|
<Workspace title="Workspace">
|
||||||
<Project filename="src/geometry.cbp" />
|
<Project filename="basic-geometry/basic-geometry.cbp" />
|
||||||
<Project filename="dev/geometry-dev.cbp">
|
<Project filename="basic-geometry-dev/basic-geometry-dev.cbp">
|
||||||
<Depends filename="src/geometry.cbp" />
|
<Depends filename="basic-geometry/basic-geometry.cbp" />
|
||||||
</Project>
|
</Project>
|
||||||
<Project filename="test/geometry-test.cbp">
|
<Project filename="basic-geometry-test/basic-geometry-test.cbp">
|
||||||
<Depends filename="src/geometry.cbp" />
|
<Depends filename="basic-geometry/basic-geometry.cbp" />
|
||||||
</Project>
|
</Project>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
</CodeBlocks_workspace_file>
|
</CodeBlocks_workspace_file>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
<CodeBlocks_workspace_layout_file>
|
<CodeBlocks_workspace_layout_file>
|
||||||
<FileVersion major="1" minor="0" />
|
<FileVersion major="1" minor="0" />
|
||||||
<ActiveProject path="dev/geometry-dev.cbp" />
|
<ActiveProject path="basic-geometry-dev/basic-geometry-dev.cbp" />
|
||||||
|
<PreferredTarget name="Release" />
|
||||||
</CodeBlocks_workspace_layout_file>
|
</CodeBlocks_workspace_layout_file>
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.1.32421.90
|
VisualStudioVersion = 17.1.32421.90
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geometry", "src\geometry.vcxproj", "{40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic-geometry", "basic-geometry\basic-geometry.vcxproj", "{40CA6FB4-135F-4D54-A8D9-7338BA56E6A7}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geometry-test", "test\geometry-test.vcxproj", "{48DAE315-715F-4044-ADF5-0308483B887C}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic-geometry-test", "basic-geometry-test\basic-geometry-test.vcxproj", "{48DAE315-715F-4044-ADF5-0308483B887C}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geometry-dev", "dev\geometry-dev.vcxproj", "{46DE6C8F-3179-4652-95CF-28D44AC4774A}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic-geometry-dev", "basic-geometry-dev\basic-geometry-dev.vcxproj", "{46DE6C8F-3179-4652-95CF-28D44AC4774A}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
|
||||||
50
basic-geometry-dev/basic-geometry-dev.cbp
Normal file
50
basic-geometry-dev/basic-geometry-dev.cbp
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_project_file>
|
||||||
|
<FileVersion major="1" minor="6" />
|
||||||
|
<Project>
|
||||||
|
<Option title="basic-geometry-dev" />
|
||||||
|
<Option pch_mode="2" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Build>
|
||||||
|
<Target title="Debug">
|
||||||
|
<Option output="bin/Debug/basic-geometry-dev" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option object_output="obj/Debug/" />
|
||||||
|
<Option type="1" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-g" />
|
||||||
|
<Add directory="../basic-geometry" />
|
||||||
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add library="basic-geometry" />
|
||||||
|
<Add library="m" />
|
||||||
|
<Add directory="../basic-geometry/bin/Debug" />
|
||||||
|
</Linker>
|
||||||
|
</Target>
|
||||||
|
<Target title="Release">
|
||||||
|
<Option output="bin/Release/basic-geometry-dev" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option object_output="obj/Release/" />
|
||||||
|
<Option type="1" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-O2" />
|
||||||
|
<Add directory="../basic-geometry" />
|
||||||
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add option="-O2" />
|
||||||
|
<Add option="-s" />
|
||||||
|
<Add library="basic-geometry" />
|
||||||
|
<Add library="m" />
|
||||||
|
<Add directory="../basic-geometry/bin/Release" />
|
||||||
|
</Linker>
|
||||||
|
</Target>
|
||||||
|
</Build>
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-Wall" />
|
||||||
|
</Compiler>
|
||||||
|
<Unit filename="main.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Extensions />
|
||||||
|
</Project>
|
||||||
|
</CodeBlocks_project_file>
|
||||||
165
basic-geometry-dev/basic-geometry-dev.vcxproj
Normal file
165
basic-geometry-dev/basic-geometry-dev.vcxproj
Normal file
|
|
@ -0,0 +1,165 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="main.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\basic-geometry\basic-geometry.vcxproj">
|
||||||
|
<Project>{40ca6fb4-135f-4d54-a8d9-7338ba56e6a7}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{46de6c8f-3179-4652-95cf-28d44ac4774a}</ProjectGuid>
|
||||||
|
<RootNamespace>basic-geometry-dev</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
|
||||||
|
<ExceptionHandling>Sync</ExceptionHandling>
|
||||||
|
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||||
|
<FloatingPointModel>Precise</FloatingPointModel>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
22
basic-geometry-dev/basic-geometry-dev.vcxproj.filters
Normal file
22
basic-geometry-dev/basic-geometry-dev.vcxproj.filters
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Исходные файлы">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Файлы заголовков">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Файлы ресурсов">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="main.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
194
basic-geometry-dev/main.c
Normal file
194
basic-geometry-dev/main.c
Normal file
|
|
@ -0,0 +1,194 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <basic-geometry.h>
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <time.h>
|
||||||
|
#endif // _WINDOWS_
|
||||||
|
|
||||||
|
BgFP32Versor * allocate_versors(const unsigned int amount)
|
||||||
|
{
|
||||||
|
return calloc(amount, sizeof(BgFP32Versor));
|
||||||
|
}
|
||||||
|
|
||||||
|
BgFP32Versor * make_zero_versors(const unsigned int amount)
|
||||||
|
{
|
||||||
|
BgFP32Versor * list = allocate_versors(amount);
|
||||||
|
|
||||||
|
if (list == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < amount; i++) {
|
||||||
|
bg_fp32_versor_reset(&list[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
BgFP32Versor * make_random_versors(const unsigned int amount)
|
||||||
|
{
|
||||||
|
BgFP32Versor * list = allocate_versors(amount);
|
||||||
|
|
||||||
|
if (list == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < amount; i++) {
|
||||||
|
bg_fp32_versor_set_values(
|
||||||
|
(2.0f * rand()) / RAND_MAX - 1.0f,
|
||||||
|
(2.0f * rand()) / RAND_MAX - 1.0f,
|
||||||
|
(2.0f * rand()) / RAND_MAX - 1.0f,
|
||||||
|
(2.0f * rand()) / RAND_MAX - 1.0f,
|
||||||
|
&list[i]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_versor(const BgFP32Versor* versor)
|
||||||
|
{
|
||||||
|
printf("(%f, %f, %f, %f)\n", versor->s0, versor->x1, versor->x2, versor->x3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_vector(const BgFP32Vector3* vector)
|
||||||
|
{
|
||||||
|
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, bg_fp32_vector3_get_module(vector));
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
const unsigned int amount = 1000000;
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
ULONGLONG now;
|
||||||
|
now = GetTickCount64();
|
||||||
|
srand((unsigned int)(now & 0xfffffff));
|
||||||
|
#else
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &now);
|
||||||
|
srand((unsigned int)(now.tv_nsec & 0xfffffff));
|
||||||
|
#endif // _WIN64
|
||||||
|
|
||||||
|
BgFP32Versor * versors = make_random_versors(amount);
|
||||||
|
|
||||||
|
if (versors == 0) {
|
||||||
|
printf("Cannot allocate memory for versors");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BgFP32Vector3 initial, result;
|
||||||
|
|
||||||
|
bg_fp32_vector3_set_values(1, 2, 3, &initial);
|
||||||
|
bg_fp32_vector3_copy(&initial, &result);
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
ULONGLONG start, end;
|
||||||
|
start = GetTickCount64();
|
||||||
|
#else
|
||||||
|
struct timespec start, end;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &start);
|
||||||
|
#endif // _WIN64
|
||||||
|
for (unsigned int i = 0; i < amount; i++) {
|
||||||
|
bg_fp32_versor_turn2(&versors[i], &result, &result);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = amount; i > 0; i--) {
|
||||||
|
bg_fp32_versor_turn_back2(&versors[i - 1], &result, &result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
end = GetTickCount64();
|
||||||
|
|
||||||
|
printf("Time: %lld\n", end - start);
|
||||||
|
#else
|
||||||
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
|
|
||||||
|
printf("Time: %lf\n", (end.tv_sec - start.tv_sec) * 1000.0 + (end.tv_nsec - start.tv_nsec) * 0.000001);
|
||||||
|
#endif // _WIN64
|
||||||
|
|
||||||
|
|
||||||
|
print_vector(&initial);
|
||||||
|
print_vector(&result);
|
||||||
|
|
||||||
|
free(versors);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
const unsigned int amount = 1000000;
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
ULONGLONG now;
|
||||||
|
now = GetTickCount64();
|
||||||
|
srand((unsigned int)(now & 0xfffffff));
|
||||||
|
#else
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &now);
|
||||||
|
srand((unsigned int)(now.tv_nsec & 0xfffffff));
|
||||||
|
#endif // _WIN64
|
||||||
|
|
||||||
|
BgFP32Versor * versors1 = make_random_versors(amount);
|
||||||
|
|
||||||
|
if (versors1 == 0) {
|
||||||
|
printf("Cannot allocate memory for versors1");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BgFP32Versor * versors2 = make_random_versors(amount);
|
||||||
|
|
||||||
|
if (versors2 == 0) {
|
||||||
|
printf("Cannot allocate memory for versors2");
|
||||||
|
free(versors1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BgFP32Versor * results = make_zero_versors(amount);
|
||||||
|
|
||||||
|
if (results == 0) {
|
||||||
|
printf("Cannot allocate memory for results");
|
||||||
|
free(versors2);
|
||||||
|
free(versors1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
ULONGLONG start, end;
|
||||||
|
start = GetTickCount64();
|
||||||
|
#else
|
||||||
|
struct timespec start, end;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &start);
|
||||||
|
#endif // _WIN64
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
end = GetTickCount64();
|
||||||
|
|
||||||
|
printf("Time: %lld\n", end - start);
|
||||||
|
#else
|
||||||
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
|
|
||||||
|
printf("Time: %lf\n", (end.tv_sec - start.tv_sec) * 1000.0 + (end.tv_nsec - start.tv_nsec) * 0.000001);
|
||||||
|
#endif // _WIN64
|
||||||
|
|
||||||
|
print_versor(versors1 + 10);
|
||||||
|
print_versor(versors2 + 10);
|
||||||
|
print_versor(results + 10);
|
||||||
|
|
||||||
|
free(results);
|
||||||
|
free(versors2);
|
||||||
|
free(versors1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
58
basic-geometry-test/basic-geometry-test.cbp
Normal file
58
basic-geometry-test/basic-geometry-test.cbp
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_project_file>
|
||||||
|
<FileVersion major="1" minor="6" />
|
||||||
|
<Project>
|
||||||
|
<Option title="basic-geometry-test" />
|
||||||
|
<Option pch_mode="2" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Build>
|
||||||
|
<Target title="Debug">
|
||||||
|
<Option output="bin/Debug/basic-geometry-test" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option object_output="obj/Debug/" />
|
||||||
|
<Option type="1" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-g" />
|
||||||
|
<Add directory="../basic-geometry" />
|
||||||
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add library="basic-geometry" />
|
||||||
|
<Add library="m" />
|
||||||
|
<Add directory="../basic-geometry/bin/Debug" />
|
||||||
|
</Linker>
|
||||||
|
</Target>
|
||||||
|
<Target title="Release">
|
||||||
|
<Option output="bin/Release/basic-geometry-test" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option object_output="obj/Release/" />
|
||||||
|
<Option type="1" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-O3" />
|
||||||
|
<Add directory="../basic-geometry" />
|
||||||
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add option="-O3" />
|
||||||
|
<Add option="-s" />
|
||||||
|
<Add library="basic-geometry" />
|
||||||
|
<Add library="m" />
|
||||||
|
<Add directory="../basic-geometry/bin/Release" />
|
||||||
|
</Linker>
|
||||||
|
</Target>
|
||||||
|
</Build>
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-Wall" />
|
||||||
|
</Compiler>
|
||||||
|
<Unit filename="fp32_vector2_test.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="fp32_vector2_test.h" />
|
||||||
|
<Unit filename="geometry_test.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="geometry_test.h" />
|
||||||
|
<Unit filename="main.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Extensions />
|
||||||
|
</Project>
|
||||||
|
</CodeBlocks_project_file>
|
||||||
162
basic-geometry-test/basic-geometry-test.vcxproj
Normal file
162
basic-geometry-test/basic-geometry-test.vcxproj
Normal file
|
|
@ -0,0 +1,162 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{48dae315-715f-4044-adf5-0308483b887c}</ProjectGuid>
|
||||||
|
<RootNamespace>basic-geometry-test</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\basic-geometry\basic-geometry.vcxproj">
|
||||||
|
<Project>{40ca6fb4-135f-4d54-a8d9-7338ba56e6a7}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="geometry_test.c" />
|
||||||
|
<ClCompile Include="main.c" />
|
||||||
|
<ClCompile Include="sp_vector2_test.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="geometry_test.h" />
|
||||||
|
<ClInclude Include="sp_vector2_test.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
36
basic-geometry-test/basic-geometry-test.vcxproj.filters
Normal file
36
basic-geometry-test/basic-geometry-test.vcxproj.filters
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Исходные файлы">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Файлы заголовков">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Файлы ресурсов">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="main.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="geometry_test.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="sp_vector2_test.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="geometry_test.h">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="sp_vector2_test.h">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
150
basic-geometry-test/fp32_vector2_test.c
Normal file
150
basic-geometry-test/fp32_vector2_test.c
Normal file
|
|
@ -0,0 +1,150 @@
|
||||||
|
#include "fp32_vector2_test.h"
|
||||||
|
|
||||||
|
const int TEST_BG_FP32_VECTOR2_AMOUNT_1 = 5;
|
||||||
|
|
||||||
|
const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1[] = {
|
||||||
|
{ 3.0f, 4.0f },
|
||||||
|
{ -3.0f, -4.0f },
|
||||||
|
{ 10000.0f, -20000.0f },
|
||||||
|
{ 0.1f, -10.0f },
|
||||||
|
{ -123.5f, 3.7283f }
|
||||||
|
};
|
||||||
|
|
||||||
|
const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_2[] = {
|
||||||
|
{ -3.0f, -4.0f },
|
||||||
|
{ -3.0f, -4.0f },
|
||||||
|
{ 0.002f, -0.05f },
|
||||||
|
{ -0.2f, 12.0f },
|
||||||
|
{ 1.5f, -23.35f }
|
||||||
|
};
|
||||||
|
|
||||||
|
// =============== Square module ================ //
|
||||||
|
|
||||||
|
const float BG_FP32_VECTOR2_SQUARE_MODULE_1[] = { 25.0f, 25.0f, 500000000.0f, 100.01f, 15266.150221f };
|
||||||
|
|
||||||
|
int test_bg_fp32_vector2_square_module()
|
||||||
|
{
|
||||||
|
print_test_name("BgFP32Vector2 square module");
|
||||||
|
|
||||||
|
float square_module;
|
||||||
|
|
||||||
|
for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||||
|
square_module = bg_fp32_vector2_get_square_module(&TEST_BG_FP32_VECTOR2_COMMON_1[i]);
|
||||||
|
|
||||||
|
if (!test_bg_fp32_are_equal(square_module, BG_FP32_VECTOR2_SQUARE_MODULE_1[i], TEST_BG_FP32_TWO_EPSYLON)) {
|
||||||
|
print_test_failed();
|
||||||
|
return TEST_RESULT_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_test_success();
|
||||||
|
return TEST_RESULT_SUCCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== Module =================== //
|
||||||
|
|
||||||
|
const float BG_FP32_VECTOR2_MODULE_1[] = { 5.0f, 5.0f, 22360.68f, 10.0005f, 123.55626338f };
|
||||||
|
|
||||||
|
int test_bg_fp32_vector2_module()
|
||||||
|
{
|
||||||
|
print_test_name("BgFP32Vector2 module");
|
||||||
|
|
||||||
|
float square_module;
|
||||||
|
|
||||||
|
for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||||
|
square_module = bg_fp32_vector2_get_module(&TEST_BG_FP32_VECTOR2_COMMON_1[i]);
|
||||||
|
|
||||||
|
if (!test_bg_fp32_are_equal(square_module, BG_FP32_VECTOR2_MODULE_1[i], TEST_BG_FP32_EPSYLON)) {
|
||||||
|
print_test_failed();
|
||||||
|
return TEST_RESULT_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_test_success();
|
||||||
|
return TEST_RESULT_SUCCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== Add ==================== //
|
||||||
|
|
||||||
|
const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[] = {
|
||||||
|
{ 0.0f, 0.0f },
|
||||||
|
{ -6.0f, -8.0f },
|
||||||
|
{ 10000.002f, -20000.05f },
|
||||||
|
{ -0.1f, 2.0f },
|
||||||
|
{ -122.0f, -19.6217f }
|
||||||
|
};
|
||||||
|
|
||||||
|
int test_bg_fp32_vector2_add()
|
||||||
|
{
|
||||||
|
print_test_name("BgFP32Vector2 add");
|
||||||
|
|
||||||
|
BgFP32Vector2 vector;
|
||||||
|
|
||||||
|
for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||||
|
bg_fp32_vector2_add(&TEST_BG_FP32_VECTOR2_COMMON_1[i], &TEST_BG_FP32_VECTOR2_COMMON_2[i], &vector);
|
||||||
|
|
||||||
|
if (!test_bg_fp32_are_equal(vector.x1, TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[i].x1, TEST_BG_FP32_EPSYLON) ||
|
||||||
|
!test_bg_fp32_are_equal(vector.x2, TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[i].x2, TEST_BG_FP32_EPSYLON)) {
|
||||||
|
print_test_failed();
|
||||||
|
return TEST_RESULT_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_test_success();
|
||||||
|
return TEST_RESULT_SUCCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================== Subtract ================== //
|
||||||
|
|
||||||
|
const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
|
||||||
|
{ 6.0f, 8.0f },
|
||||||
|
{ 0.0f, 0.0f },
|
||||||
|
{ 9999.998f, -19999.95f },
|
||||||
|
{ 0.3f, -22.0f },
|
||||||
|
{ -125.0f, 27.0783f }
|
||||||
|
};
|
||||||
|
|
||||||
|
int test_bg_fp32_vector2_subtract()
|
||||||
|
{
|
||||||
|
print_test_name("BgFP32Vector2 subtract");
|
||||||
|
|
||||||
|
BgFP32Vector2 vector;
|
||||||
|
|
||||||
|
for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||||
|
bg_fp32_vector2_subtract(&TEST_BG_FP32_VECTOR2_COMMON_1[i], &TEST_BG_FP32_VECTOR2_COMMON_2[i], &vector);
|
||||||
|
|
||||||
|
if (!test_bg_fp32_are_equal(vector.x1, TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[i].x1, TEST_BG_FP32_EPSYLON) ||
|
||||||
|
!test_bg_fp32_are_equal(vector.x2, TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2, TEST_BG_FP32_EPSYLON)) {
|
||||||
|
print_test_failed();
|
||||||
|
return TEST_RESULT_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_test_success();
|
||||||
|
return TEST_RESULT_SUCCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 1234 ==================== //
|
||||||
|
|
||||||
|
int test_bg_fp32_vector2()
|
||||||
|
{
|
||||||
|
print_test_section("BgFP32Vector2");
|
||||||
|
|
||||||
|
if (test_bg_fp32_vector2_square_module() != TEST_RESULT_SUCCES) {
|
||||||
|
return TEST_RESULT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (test_bg_fp32_vector2_module() != TEST_RESULT_SUCCES) {
|
||||||
|
return TEST_RESULT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (test_bg_fp32_vector2_add() != TEST_RESULT_SUCCES) {
|
||||||
|
return TEST_RESULT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (test_bg_fp32_vector2_subtract() != TEST_RESULT_SUCCES) {
|
||||||
|
return TEST_RESULT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TEST_RESULT_SUCCES;
|
||||||
|
}
|
||||||
16
basic-geometry-test/fp32_vector2_test.h
Normal file
16
basic-geometry-test/fp32_vector2_test.h
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef __GEOMETRY_VECTOR2_FLOAT_TEST_H__
|
||||||
|
#define __GEOMETRY_VECTOR2_FLOAT_TEST_H__
|
||||||
|
|
||||||
|
#include "geometry_test.h"
|
||||||
|
|
||||||
|
int test_bg_fp32_vector2();
|
||||||
|
|
||||||
|
int test_bg_fp32_vector2_square_module();
|
||||||
|
|
||||||
|
int test_bg_fp32_vector2_module();
|
||||||
|
|
||||||
|
int test_bg_fp32_vector2_add();
|
||||||
|
|
||||||
|
int test_bg_fp32_vector2_subtract();
|
||||||
|
|
||||||
|
#endif
|
||||||
23
basic-geometry-test/geometry_test.c
Normal file
23
basic-geometry-test/geometry_test.c
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include "geometry_test.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void print_test_section(const char * name)
|
||||||
|
{
|
||||||
|
printf("================ %s ================\n", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_test_name(const char * name)
|
||||||
|
{
|
||||||
|
printf(" Testing of %s: ", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_test_success()
|
||||||
|
{
|
||||||
|
printf("[ \x1b[32mSuccess\x1b[0m ]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_test_failed()
|
||||||
|
{
|
||||||
|
printf("[ \x1b[31mFailed\x1b[0m ]\n");
|
||||||
|
}
|
||||||
53
basic-geometry-test/geometry_test.h
Normal file
53
basic-geometry-test/geometry_test.h
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
#ifndef __GEOMETRY_TEST_H__
|
||||||
|
#define __GEOMETRY_TEST_H__
|
||||||
|
|
||||||
|
#include <geometry.h>
|
||||||
|
|
||||||
|
#define TEST_RESULT_SUCCES 0
|
||||||
|
#define TEST_RESULT_FAILED 100
|
||||||
|
|
||||||
|
#define TEST_BG_FP32_EPSYLON 1E-6f
|
||||||
|
#define TEST_BG_FP32_TWO_EPSYLON 2E-6f
|
||||||
|
#define TEST_BG_FP32_SQUARE_EPSYLON 1E-12f
|
||||||
|
|
||||||
|
#define TEST_BG_FP64_EPSYLON 1E-13f
|
||||||
|
#define TEST_BG_FP64_TWO_EPSYLON 2E-13f
|
||||||
|
#define TEST_BG_FP64_SQUARE_EPSYLON 1E-26f
|
||||||
|
|
||||||
|
void print_test_section(const char * name);
|
||||||
|
|
||||||
|
void print_test_name(const char * name);
|
||||||
|
|
||||||
|
void print_test_success();
|
||||||
|
|
||||||
|
void print_test_failed();
|
||||||
|
|
||||||
|
inline int test_bg_fp32_are_equal(const float value1, const float value2, const float epsylon)
|
||||||
|
{
|
||||||
|
if (-1.0f <= value1 && value1 <= 1.0f) {
|
||||||
|
const float difference = value1 - value2;
|
||||||
|
return -epsylon <= difference && difference <= epsylon;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value1 > 0.0f) {
|
||||||
|
return value1 <= value2 * (1.0f + epsylon) && value2 <= value1 * (1.0f + epsylon);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value1 * (1.0f + epsylon) <= value2 && value2 * (1.0f + epsylon) <= value1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int test_bg_fp64_are_equal(const double value1, const double value2, const double epsylon)
|
||||||
|
{
|
||||||
|
if (-1.0 <= value1 && value1 <= 1.0) {
|
||||||
|
const double difference = value1 - value2;
|
||||||
|
return -epsylon <= difference && difference <= epsylon;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value1 > 0.0) {
|
||||||
|
return value1 <= value2 * (1.0 + epsylon) && value2 <= value1 * (1.0 + epsylon);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value1 * (1.0 + epsylon) <= value2 && value2 * (1.0 + epsylon) <= value1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
17
basic-geometry-test/main.c
Normal file
17
basic-geometry-test/main.c
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "geometry_test.h"
|
||||||
|
#include "fp32_vector2_test.h"
|
||||||
|
|
||||||
|
#define PROGRAM_RESULT_SUCCESS 0
|
||||||
|
#define PROGRAM_RESULT_FAILED 1
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
if (test_bg_fp32_vector2() == TEST_RESULT_FAILED) {
|
||||||
|
return PROGRAM_RESULT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PROGRAM_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
3
basic-geometry/angle.c
Normal file
3
basic-geometry/angle.c
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#include "basis.h"
|
||||||
|
#include "angle.h"
|
||||||
|
|
||||||
557
basic-geometry/angle.h
Normal file
557
basic-geometry/angle.h
Normal file
|
|
@ -0,0 +1,557 @@
|
||||||
|
#ifndef _GEOMETRY_ANGLE_H_
|
||||||
|
#define _GEOMETRY_ANGLE_H_
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include "basis.h"
|
||||||
|
|
||||||
|
#define BG_FP32_PI 3.1415926536f
|
||||||
|
#define BG_FP32_TWO_PI 6.2831853072f
|
||||||
|
#define BG_FP32_HALF_OF_PI 1.5707963268f
|
||||||
|
#define BG_FP32_THIRD_OF_PI 1.0471975512f
|
||||||
|
#define BG_FP32_FOURTH_OF_PI 0.7853981634f
|
||||||
|
#define BG_FP32_SIXTH_OF_PI 0.5235987756f
|
||||||
|
|
||||||
|
#define BG_FP32_DEGREES_IN_RADIAN 57.295779513f
|
||||||
|
#define BG_FP32_TURNS_IN_RADIAN 0.1591549431f
|
||||||
|
#define BG_FP32_RADIANS_IN_DEGREE 1.745329252E-2f
|
||||||
|
#define BG_FP32_TURNS_IN_DEGREE 2.7777777778E-3f
|
||||||
|
|
||||||
|
#define BG_FP64_PI 3.14159265358979324
|
||||||
|
#define BG_FP64_TWO_PI 6.28318530717958648
|
||||||
|
#define BG_FP64_HALF_OF_PI 1.57079632679489662
|
||||||
|
#define BG_FP64_THIRD_OF_PI 1.04719755119659775
|
||||||
|
#define BG_FP64_FOURTH_OF_PI 0.78539816339744831
|
||||||
|
#define BG_FP64_SIXTH_OF_PI 0.523598775598298873
|
||||||
|
|
||||||
|
#define BG_FP64_DEGREES_IN_RADIAN 57.2957795130823209
|
||||||
|
#define BG_FP64_TURNS_IN_RADIAN 0.159154943091895336
|
||||||
|
#define BG_FP64_RADIANS_IN_DEGREE 1.74532925199432958E-2
|
||||||
|
#define BG_FP64_TURNS_IN_DEGREE 2.77777777777777778E-3
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
BG_ANGLE_UNIT_RADIANS = 1,
|
||||||
|
BG_ANGLE_UNIT_DEGREES = 2,
|
||||||
|
BG_ANGLE_UNIT_TURNS = 3
|
||||||
|
} angle_unit_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
/**
|
||||||
|
* The measure of an angle with a range of:
|
||||||
|
* [0, 360) degrees, [0, 2xPI) radians, [0, 1) turns, [0, 400) gradians
|
||||||
|
*/
|
||||||
|
BG_ANGLE_RANGE_UNSIGNED = 1,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The measure of an angle with a range of:
|
||||||
|
* (-180, 180] degrees, (-PI, PI] radians, (-0.5, 0.5] turns, (-200, 200] gradians
|
||||||
|
*/
|
||||||
|
BG_ANGLE_RANGE_SIGNED = 2
|
||||||
|
} angle_range_t;
|
||||||
|
|
||||||
|
// !================= Radians ==================! //
|
||||||
|
|
||||||
|
// ========= Convert radians to degrees ========= //
|
||||||
|
|
||||||
|
static inline float bg_fp32_radians_to_degrees(const float radians)
|
||||||
|
{
|
||||||
|
return radians * BG_FP32_DEGREES_IN_RADIAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline double bg_fp64_radians_to_degrees(const double radians)
|
||||||
|
{
|
||||||
|
return radians * BG_FP64_DEGREES_IN_RADIAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== Convert radians to turns ========== //
|
||||||
|
|
||||||
|
static inline float bg_fp32_radians_to_turns(const float radians)
|
||||||
|
{
|
||||||
|
return radians * BG_FP32_TURNS_IN_RADIAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline double bg_fp64_radians_to_turns(const double radians)
|
||||||
|
{
|
||||||
|
return radians * BG_FP64_TURNS_IN_RADIAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========= Convert radians to any unit ======== //
|
||||||
|
|
||||||
|
static inline float bg_fp32_radians_to_units(const float radians, const angle_unit_t to_unit)
|
||||||
|
{
|
||||||
|
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
||||||
|
return radians * BG_FP32_DEGREES_IN_RADIAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to_unit == BG_ANGLE_UNIT_TURNS) {
|
||||||
|
return radians * BG_FP32_TURNS_IN_RADIAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return radians;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline double bg_fp64_radians_to_units(const double radians, const angle_unit_t to_unit)
|
||||||
|
{
|
||||||
|
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
||||||
|
return radians * BG_FP64_DEGREES_IN_RADIAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to_unit == BG_ANGLE_UNIT_TURNS) {
|
||||||
|
return radians * BG_FP64_TURNS_IN_RADIAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return radians;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Normalize radians ============= //
|
||||||
|
|
||||||
|
static inline float bg_fp32_radians_normalize(const float radians, const angle_range_t range)
|
||||||
|
{
|
||||||
|
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||||
|
if (0.0f <= radians && radians < BG_FP32_TWO_PI) {
|
||||||
|
return radians;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (-BG_FP32_PI < radians && radians <= BG_FP32_PI) {
|
||||||
|
return radians;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float turns = radians * BG_FP32_TURNS_IN_RADIAN;
|
||||||
|
|
||||||
|
turns -= floorf(turns);
|
||||||
|
|
||||||
|
if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5f) {
|
||||||
|
turns -= 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return turns * BG_FP32_TWO_PI;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline double bg_fp64_radians_normalize(const double radians, const angle_range_t range)
|
||||||
|
{
|
||||||
|
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||||
|
if (0.0 <= radians && radians < BG_FP64_TWO_PI) {
|
||||||
|
return radians;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (-BG_FP64_PI < radians && radians <= BG_FP64_PI) {
|
||||||
|
return radians;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double turns = radians * BG_FP64_TURNS_IN_RADIAN;
|
||||||
|
|
||||||
|
turns -= floor(turns);
|
||||||
|
|
||||||
|
if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5) {
|
||||||
|
turns -= 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return turns * BG_FP64_TWO_PI;
|
||||||
|
}
|
||||||
|
|
||||||
|
// !================= Degrees ==================! //
|
||||||
|
|
||||||
|
// ========= Convert degrees to radians ========= //
|
||||||
|
|
||||||
|
static inline float bg_fp32_degrees_to_radians(const float degrees)
|
||||||
|
{
|
||||||
|
return degrees * BG_FP32_RADIANS_IN_DEGREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline double bg_fp64_degrees_to_radians(const double degrees)
|
||||||
|
{
|
||||||
|
return degrees * BG_FP64_RADIANS_IN_DEGREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== Convert degrees to turns ========== //
|
||||||
|
|
||||||
|
static inline float bg_fp32_degrees_to_turns(const float radians)
|
||||||
|
{
|
||||||