diff --git a/.gitignore b/.gitignore index 5d98e62..d18e22c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,8 @@ # Bazel files bazel-* -# Rust files -Cargo.lock +# Lock files +*.lock # Python files __pycache__ diff --git a/Cargo.toml b/Cargo.toml index 4234253..fb17cf3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,21 +2,22 @@ resolver = "2" members = [ # Main crates - "libs/l2math/bindings", - "libs/l2math", - "libs/libodo", - "libs/libpath", - "libs/libtrig", + "arc", # Client side of the robot (python) + "libs/robot", # Robot [Server] side of the robot (rust) # Helper crates - "libs/macros-core", - "libs/macros", + "libs/helper/l2math", + # "libs/libodo", + # "libs/libpath", + # "libs/libtrig", + "libs/helper/macros-core", + "libs/helper/macros", ] [workspace.package] authors = ["Матвей Т AtomicGamer9523@github"] -repository = "https://github.com/AtomicGamer9523/librobomath" -version = "0.1.0-dev" +repository = "https://github.com/DranikiRobotics/arc" +version = "0.0.1-dev" edition = "2021" license = "MIT" diff --git a/README.md b/README.md index f22759d..b73fc60 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -# `LibRoboTOP` +# ARC: A complete framework for controlling robots -## A **Lib**rary for **Robo**tics, featuring **T**rigonometry, **O**dometry, and **P**athing +ARC is a feature complete framework for writing robot code. It is designed to be easy to use, and easy to understand. It is also designed to be modular, so that you can use only the parts you need. ARC is also designed to be easy to extend, so that you can add your own functionality to it. ARC is an acronym, and it stands for: **A**dvanced **R**obot **C**ontroller. -### Features +## Features - **[`l2math`](./libs/l2math/)** - Low Level Math - Fundamental math functions and types. - **[`libtrig`](./libs/libtrig/)** - Trigonometry functionality (angles, vectors, etc.). -### Documentation +## Documentation For Developers who are planning on using this [read here](./docs/GUIDE.md). diff --git a/libs/libodo/Cargo.toml b/arc/Cargo.toml similarity index 50% rename from libs/libodo/Cargo.toml rename to arc/Cargo.toml index 4091d0b..86c6c72 100644 --- a/libs/libodo/Cargo.toml +++ b/arc/Cargo.toml @@ -1,14 +1,11 @@ [package] -name = "libodo" -description = "Core odometrix functionality, you probably shouldn't use this directly" +name = "arc" +description = "Advanced Robot Controller" repository.workspace = true version.workspace = true edition.workspace = true authors.workspace = true license.workspace = true -[dependencies.libtrig] -path = "../libtrig" - [lib] path = "lib.rs" diff --git a/arc/__init__.pyi b/arc/__init__.pyi new file mode 100644 index 0000000..de28fc9 --- /dev/null +++ b/arc/__init__.pyi @@ -0,0 +1,6 @@ +from typing import Callable + +type RunResult = bool +OK: RunResult = True +FAIL: RunResult = False +def MAIN(func: Callable[[], RunResult]) -> None: ... diff --git a/bindings/README.md b/arc/lib.rs similarity index 100% rename from bindings/README.md rename to arc/lib.rs diff --git a/bindings/.gitignore b/bindings/.gitignore deleted file mode 100644 index 8d951cb..0000000 --- a/bindings/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# I used this for dissassembly -dissassembly -/*.jar \ No newline at end of file diff --git a/docs/examples/auto.py b/docs/examples/auto.py new file mode 100644 index 0000000..3cb10a0 --- /dev/null +++ b/docs/examples/auto.py @@ -0,0 +1,7 @@ +from arc import * + +def main() -> RunResult: + print("Hello, world!") + return OK + +MAIN(main) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f3d88b1..0000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index aa991fc..0000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew deleted file mode 100644 index 91a7e26..0000000 --- a/gradlew +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index 8a0b282..0000000 --- a/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/libs/eztest/EZtest b/libs/eztest/EZtest deleted file mode 100644 index b77b5ff..0000000 --- a/libs/eztest/EZtest +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -#ifndef __EZTEST_H -#define __EZTEST_H - -#ifdef __cplusplus -#define ____EZTEST_BOOL bool -#define ____EZTEST_TRUE true -#define ____EZTEST_FALSE false -#else // __cplusplus -#define ____EZTEST_BOOL int -#define ____EZTEST_TRUE 1 -#define ____EZTEST_FALSE 0 -#endif // __cplusplus - -/// Return from a test with success. -#define OK return ____EZTEST_TRUE; -/// Return from a test with failure. -#define FAIL return ____EZTEST_FALSE; -/// Assert that a condition is true. -#define ASSERT(x) if ( !(x) ) { FAIL; } -/// Assert that two values are equal. -#define ASSERT_EQ(x, y) if ((x) != (y)) { FAIL; } -/// Assert that two values are not equal. -#define ASSERT_NE(x, y) if ((x) == (y)) { FAIL; } -/// Assert that a value is less than another. -#define ASSERT_LT(x, y) if ((x) >= (y)) { FAIL; } -/// Assert that a value is less than or equal to another. -#define ASSERT_LE(x, y) if ((x) > (y)) { FAIL; } -/// Assert that a value is greater than another. -#define ASSERT_GT(x, y) if ((x) <= (y)) { FAIL; } -/// Assert that a value is greater than or equal to another. -#define ASSERT_GE(x, y) if ((x) < (y)) { FAIL; } - -/// Register a test. -/// -/// You should not call this function directly. Instead, use the TEST macro. -/// -/// @param name The name of the test. -/// @param test The test function. -/// @return Whether the test was registered successfully. -____EZTEST_BOOL ____EZTEST_register_test(const char* name, ____EZTEST_BOOL(*test)()); -/// Runs all tests. -/// -/// You should not call this function directly. Instead, use the RUN_TESTS macro. -/// -/// @return The number of failed tests. -int ____EZTEST_run_tests(); - -/// Define a test. -/// -/// @param name The name of the test. -/// @return The test function. -#define TEST(name) \ - ____EZTEST_BOOL name(); \ - static ____EZTEST_BOOL name##_registered = \ - ____EZTEST_register_test(#name, name); \ - ____EZTEST_BOOL name() - -/// Runs all tests. -/// -/// @return The number of failed tests. -#define RUN_TESTS ____EZTEST_run_tests(); - -#endif // __EZTEST_H diff --git a/libs/eztest/eztest.cpp b/libs/eztest/eztest.cpp deleted file mode 100644 index 5dfc23e..0000000 --- a/libs/eztest/eztest.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "EZtest" -#include - -constexpr const int ____SIMPLETEST_MAX_TESTS = 1000; - -typedef struct Test { - const char* name; - ____EZTEST_BOOL(*func)(); -} Test; - -Test tests[____SIMPLETEST_MAX_TESTS]; - -____EZTEST_BOOL ____EZTEST_register_test(const char* name, ____EZTEST_BOOL(*func)()) { - for (int i = 0; i < ____SIMPLETEST_MAX_TESTS; i++) { - if (tests[i].name == NULL) { - tests[i].name = name; - tests[i].func = func; - return ____EZTEST_TRUE; - } - } - return ____EZTEST_FALSE; -} - -int ____EZTEST_run_tests() { - int failed = 0; - for (int i = 0; i < ____SIMPLETEST_MAX_TESTS; i++) { - if (tests[i].name == NULL) break; - printf("Running test %s...\n", tests[i].name); - if (!tests[i].func()) { - printf("Test %s failed!\n", tests[i].name); - failed++; - } else { - printf("Test %s passed!\n", tests[i].name); - } - } - return failed; -} diff --git a/libs/l2math/Cargo.toml b/libs/helper/l2math/Cargo.toml similarity index 100% rename from libs/l2math/Cargo.toml rename to libs/helper/l2math/Cargo.toml diff --git a/libs/l2math/README.md b/libs/helper/l2math/README.md similarity index 100% rename from libs/l2math/README.md rename to libs/helper/l2math/README.md diff --git a/libs/l2math/core.rs b/libs/helper/l2math/core.rs similarity index 100% rename from libs/l2math/core.rs rename to libs/helper/l2math/core.rs diff --git a/libs/l2math/core/acos.rs b/libs/helper/l2math/core/acos.rs similarity index 100% rename from libs/l2math/core/acos.rs rename to libs/helper/l2math/core/acos.rs diff --git a/libs/l2math/core/acosf.rs b/libs/helper/l2math/core/acosf.rs similarity index 100% rename from libs/l2math/core/acosf.rs rename to libs/helper/l2math/core/acosf.rs diff --git a/libs/l2math/core/acosh.rs b/libs/helper/l2math/core/acosh.rs similarity index 100% rename from libs/l2math/core/acosh.rs rename to libs/helper/l2math/core/acosh.rs diff --git a/libs/l2math/core/acoshf.rs b/libs/helper/l2math/core/acoshf.rs similarity index 100% rename from libs/l2math/core/acoshf.rs rename to libs/helper/l2math/core/acoshf.rs diff --git a/libs/l2math/core/asin.rs b/libs/helper/l2math/core/asin.rs similarity index 100% rename from libs/l2math/core/asin.rs rename to libs/helper/l2math/core/asin.rs diff --git a/libs/l2math/core/asinf.rs b/libs/helper/l2math/core/asinf.rs similarity index 100% rename from libs/l2math/core/asinf.rs rename to libs/helper/l2math/core/asinf.rs diff --git a/libs/l2math/core/asinh.rs b/libs/helper/l2math/core/asinh.rs similarity index 100% rename from libs/l2math/core/asinh.rs rename to libs/helper/l2math/core/asinh.rs diff --git a/libs/l2math/core/asinhf.rs b/libs/helper/l2math/core/asinhf.rs similarity index 100% rename from libs/l2math/core/asinhf.rs rename to libs/helper/l2math/core/asinhf.rs diff --git a/libs/l2math/core/atan.rs b/libs/helper/l2math/core/atan.rs similarity index 100% rename from libs/l2math/core/atan.rs rename to libs/helper/l2math/core/atan.rs diff --git a/libs/l2math/core/atan2.rs b/libs/helper/l2math/core/atan2.rs similarity index 100% rename from libs/l2math/core/atan2.rs rename to libs/helper/l2math/core/atan2.rs diff --git a/libs/l2math/core/atan2f.rs b/libs/helper/l2math/core/atan2f.rs similarity index 100% rename from libs/l2math/core/atan2f.rs rename to libs/helper/l2math/core/atan2f.rs diff --git a/libs/l2math/core/atanf.rs b/libs/helper/l2math/core/atanf.rs similarity index 100% rename from libs/l2math/core/atanf.rs rename to libs/helper/l2math/core/atanf.rs diff --git a/libs/l2math/core/atanh.rs b/libs/helper/l2math/core/atanh.rs similarity index 100% rename from libs/l2math/core/atanh.rs rename to libs/helper/l2math/core/atanh.rs diff --git a/libs/l2math/core/atanhf.rs b/libs/helper/l2math/core/atanhf.rs similarity index 100% rename from libs/l2math/core/atanhf.rs rename to libs/helper/l2math/core/atanhf.rs diff --git a/libs/l2math/core/cbrt.rs b/libs/helper/l2math/core/cbrt.rs similarity index 100% rename from libs/l2math/core/cbrt.rs rename to libs/helper/l2math/core/cbrt.rs diff --git a/libs/l2math/core/cbrtf.rs b/libs/helper/l2math/core/cbrtf.rs similarity index 100% rename from libs/l2math/core/cbrtf.rs rename to libs/helper/l2math/core/cbrtf.rs diff --git a/libs/l2math/core/ceil.rs b/libs/helper/l2math/core/ceil.rs similarity index 100% rename from libs/l2math/core/ceil.rs rename to libs/helper/l2math/core/ceil.rs diff --git a/libs/l2math/core/ceilf.rs b/libs/helper/l2math/core/ceilf.rs similarity index 100% rename from libs/l2math/core/ceilf.rs rename to libs/helper/l2math/core/ceilf.rs diff --git a/libs/l2math/core/copysign.rs b/libs/helper/l2math/core/copysign.rs similarity index 100% rename from libs/l2math/core/copysign.rs rename to libs/helper/l2math/core/copysign.rs diff --git a/libs/l2math/core/copysignf.rs b/libs/helper/l2math/core/copysignf.rs similarity index 100% rename from libs/l2math/core/copysignf.rs rename to libs/helper/l2math/core/copysignf.rs diff --git a/libs/l2math/core/cos.rs b/libs/helper/l2math/core/cos.rs similarity index 100% rename from libs/l2math/core/cos.rs rename to libs/helper/l2math/core/cos.rs diff --git a/libs/l2math/core/cosf.rs b/libs/helper/l2math/core/cosf.rs similarity index 100% rename from libs/l2math/core/cosf.rs rename to libs/helper/l2math/core/cosf.rs diff --git a/libs/l2math/core/cosh.rs b/libs/helper/l2math/core/cosh.rs similarity index 100% rename from libs/l2math/core/cosh.rs rename to libs/helper/l2math/core/cosh.rs diff --git a/libs/l2math/core/coshf.rs b/libs/helper/l2math/core/coshf.rs similarity index 100% rename from libs/l2math/core/coshf.rs rename to libs/helper/l2math/core/coshf.rs diff --git a/libs/l2math/core/erf.rs b/libs/helper/l2math/core/erf.rs similarity index 100% rename from libs/l2math/core/erf.rs rename to libs/helper/l2math/core/erf.rs diff --git a/libs/l2math/core/erff.rs b/libs/helper/l2math/core/erff.rs similarity index 100% rename from libs/l2math/core/erff.rs rename to libs/helper/l2math/core/erff.rs diff --git a/libs/l2math/core/exp.rs b/libs/helper/l2math/core/exp.rs similarity index 100% rename from libs/l2math/core/exp.rs rename to libs/helper/l2math/core/exp.rs diff --git a/libs/l2math/core/exp10.rs b/libs/helper/l2math/core/exp10.rs similarity index 100% rename from libs/l2math/core/exp10.rs rename to libs/helper/l2math/core/exp10.rs diff --git a/libs/l2math/core/exp10f.rs b/libs/helper/l2math/core/exp10f.rs similarity index 100% rename from libs/l2math/core/exp10f.rs rename to libs/helper/l2math/core/exp10f.rs diff --git a/libs/l2math/core/exp2.rs b/libs/helper/l2math/core/exp2.rs similarity index 100% rename from libs/l2math/core/exp2.rs rename to libs/helper/l2math/core/exp2.rs diff --git a/libs/l2math/core/exp2f.rs b/libs/helper/l2math/core/exp2f.rs similarity index 100% rename from libs/l2math/core/exp2f.rs rename to libs/helper/l2math/core/exp2f.rs diff --git a/libs/l2math/core/expf.rs b/libs/helper/l2math/core/expf.rs similarity index 100% rename from libs/l2math/core/expf.rs rename to libs/helper/l2math/core/expf.rs diff --git a/libs/l2math/core/expm1.rs b/libs/helper/l2math/core/expm1.rs similarity index 100% rename from libs/l2math/core/expm1.rs rename to libs/helper/l2math/core/expm1.rs diff --git a/libs/l2math/core/expm1f.rs b/libs/helper/l2math/core/expm1f.rs similarity index 100% rename from libs/l2math/core/expm1f.rs rename to libs/helper/l2math/core/expm1f.rs diff --git a/libs/l2math/core/expo2.rs b/libs/helper/l2math/core/expo2.rs similarity index 100% rename from libs/l2math/core/expo2.rs rename to libs/helper/l2math/core/expo2.rs diff --git a/libs/l2math/core/fabs.rs b/libs/helper/l2math/core/fabs.rs similarity index 100% rename from libs/l2math/core/fabs.rs rename to libs/helper/l2math/core/fabs.rs diff --git a/libs/l2math/core/fabsf.rs b/libs/helper/l2math/core/fabsf.rs similarity index 100% rename from libs/l2math/core/fabsf.rs rename to libs/helper/l2math/core/fabsf.rs diff --git a/libs/l2math/core/fdim.rs b/libs/helper/l2math/core/fdim.rs similarity index 100% rename from libs/l2math/core/fdim.rs rename to libs/helper/l2math/core/fdim.rs diff --git a/libs/l2math/core/fdimf.rs b/libs/helper/l2math/core/fdimf.rs similarity index 100% rename from libs/l2math/core/fdimf.rs rename to libs/helper/l2math/core/fdimf.rs diff --git a/libs/l2math/core/fenv.rs b/libs/helper/l2math/core/fenv.rs similarity index 100% rename from libs/l2math/core/fenv.rs rename to libs/helper/l2math/core/fenv.rs diff --git a/libs/l2math/core/floor.rs b/libs/helper/l2math/core/floor.rs similarity index 100% rename from libs/l2math/core/floor.rs rename to libs/helper/l2math/core/floor.rs diff --git a/libs/l2math/core/floorf.rs b/libs/helper/l2math/core/floorf.rs similarity index 100% rename from libs/l2math/core/floorf.rs rename to libs/helper/l2math/core/floorf.rs diff --git a/libs/l2math/core/fma.rs b/libs/helper/l2math/core/fma.rs similarity index 100% rename from libs/l2math/core/fma.rs rename to libs/helper/l2math/core/fma.rs diff --git a/libs/l2math/core/fmaf.rs b/libs/helper/l2math/core/fmaf.rs similarity index 100% rename from libs/l2math/core/fmaf.rs rename to libs/helper/l2math/core/fmaf.rs diff --git a/libs/l2math/core/fmax.rs b/libs/helper/l2math/core/fmax.rs similarity index 100% rename from libs/l2math/core/fmax.rs rename to libs/helper/l2math/core/fmax.rs diff --git a/libs/l2math/core/fmaxf.rs b/libs/helper/l2math/core/fmaxf.rs similarity index 100% rename from libs/l2math/core/fmaxf.rs rename to libs/helper/l2math/core/fmaxf.rs diff --git a/libs/l2math/core/fmin.rs b/libs/helper/l2math/core/fmin.rs similarity index 100% rename from libs/l2math/core/fmin.rs rename to libs/helper/l2math/core/fmin.rs diff --git a/libs/l2math/core/fminf.rs b/libs/helper/l2math/core/fminf.rs similarity index 100% rename from libs/l2math/core/fminf.rs rename to libs/helper/l2math/core/fminf.rs diff --git a/libs/l2math/core/fmod.rs b/libs/helper/l2math/core/fmod.rs similarity index 100% rename from libs/l2math/core/fmod.rs rename to libs/helper/l2math/core/fmod.rs diff --git a/libs/l2math/core/fmodf.rs b/libs/helper/l2math/core/fmodf.rs similarity index 100% rename from libs/l2math/core/fmodf.rs rename to libs/helper/l2math/core/fmodf.rs diff --git a/libs/l2math/core/frexp.rs b/libs/helper/l2math/core/frexp.rs similarity index 100% rename from libs/l2math/core/frexp.rs rename to libs/helper/l2math/core/frexp.rs diff --git a/libs/l2math/core/frexpf.rs b/libs/helper/l2math/core/frexpf.rs similarity index 100% rename from libs/l2math/core/frexpf.rs rename to libs/helper/l2math/core/frexpf.rs diff --git a/libs/l2math/core/hypot.rs b/libs/helper/l2math/core/hypot.rs similarity index 100% rename from libs/l2math/core/hypot.rs rename to libs/helper/l2math/core/hypot.rs diff --git a/libs/l2math/core/hypotf.rs b/libs/helper/l2math/core/hypotf.rs similarity index 100% rename from libs/l2math/core/hypotf.rs rename to libs/helper/l2math/core/hypotf.rs diff --git a/libs/l2math/core/ilogb.rs b/libs/helper/l2math/core/ilogb.rs similarity index 100% rename from libs/l2math/core/ilogb.rs rename to libs/helper/l2math/core/ilogb.rs diff --git a/libs/l2math/core/ilogbf.rs b/libs/helper/l2math/core/ilogbf.rs similarity index 100% rename from libs/l2math/core/ilogbf.rs rename to libs/helper/l2math/core/ilogbf.rs diff --git a/libs/l2math/core/j0.rs b/libs/helper/l2math/core/j0.rs similarity index 100% rename from libs/l2math/core/j0.rs rename to libs/helper/l2math/core/j0.rs diff --git a/libs/l2math/core/j0f.rs b/libs/helper/l2math/core/j0f.rs similarity index 100% rename from libs/l2math/core/j0f.rs rename to libs/helper/l2math/core/j0f.rs diff --git a/libs/l2math/core/j1.rs b/libs/helper/l2math/core/j1.rs similarity index 100% rename from libs/l2math/core/j1.rs rename to libs/helper/l2math/core/j1.rs diff --git a/libs/l2math/core/j1f.rs b/libs/helper/l2math/core/j1f.rs similarity index 100% rename from libs/l2math/core/j1f.rs rename to libs/helper/l2math/core/j1f.rs diff --git a/libs/l2math/core/jn.rs b/libs/helper/l2math/core/jn.rs similarity index 100% rename from libs/l2math/core/jn.rs rename to libs/helper/l2math/core/jn.rs diff --git a/libs/l2math/core/jnf.rs b/libs/helper/l2math/core/jnf.rs similarity index 100% rename from libs/l2math/core/jnf.rs rename to libs/helper/l2math/core/jnf.rs diff --git a/libs/l2math/core/k_cos.rs b/libs/helper/l2math/core/k_cos.rs similarity index 100% rename from libs/l2math/core/k_cos.rs rename to libs/helper/l2math/core/k_cos.rs diff --git a/libs/l2math/core/k_cosf.rs b/libs/helper/l2math/core/k_cosf.rs similarity index 100% rename from libs/l2math/core/k_cosf.rs rename to libs/helper/l2math/core/k_cosf.rs diff --git a/libs/l2math/core/k_expo2.rs b/libs/helper/l2math/core/k_expo2.rs similarity index 100% rename from libs/l2math/core/k_expo2.rs rename to libs/helper/l2math/core/k_expo2.rs diff --git a/libs/l2math/core/k_expo2f.rs b/libs/helper/l2math/core/k_expo2f.rs similarity index 100% rename from libs/l2math/core/k_expo2f.rs rename to libs/helper/l2math/core/k_expo2f.rs diff --git a/libs/l2math/core/k_sin.rs b/libs/helper/l2math/core/k_sin.rs similarity index 100% rename from libs/l2math/core/k_sin.rs rename to libs/helper/l2math/core/k_sin.rs diff --git a/libs/l2math/core/k_sinf.rs b/libs/helper/l2math/core/k_sinf.rs similarity index 100% rename from libs/l2math/core/k_sinf.rs rename to libs/helper/l2math/core/k_sinf.rs diff --git a/libs/l2math/core/k_tan.rs b/libs/helper/l2math/core/k_tan.rs similarity index 100% rename from libs/l2math/core/k_tan.rs rename to libs/helper/l2math/core/k_tan.rs diff --git a/libs/l2math/core/k_tanf.rs b/libs/helper/l2math/core/k_tanf.rs similarity index 100% rename from libs/l2math/core/k_tanf.rs rename to libs/helper/l2math/core/k_tanf.rs diff --git a/libs/l2math/core/ldexp.rs b/libs/helper/l2math/core/ldexp.rs similarity index 100% rename from libs/l2math/core/ldexp.rs rename to libs/helper/l2math/core/ldexp.rs diff --git a/libs/l2math/core/ldexpf.rs b/libs/helper/l2math/core/ldexpf.rs similarity index 100% rename from libs/l2math/core/ldexpf.rs rename to libs/helper/l2math/core/ldexpf.rs diff --git a/libs/l2math/core/lgamma.rs b/libs/helper/l2math/core/lgamma.rs similarity index 100% rename from libs/l2math/core/lgamma.rs rename to libs/helper/l2math/core/lgamma.rs diff --git a/libs/l2math/core/lgamma_r.rs b/libs/helper/l2math/core/lgamma_r.rs similarity index 100% rename from libs/l2math/core/lgamma_r.rs rename to libs/helper/l2math/core/lgamma_r.rs diff --git a/libs/l2math/core/lgammaf.rs b/libs/helper/l2math/core/lgammaf.rs similarity index 100% rename from libs/l2math/core/lgammaf.rs rename to libs/helper/l2math/core/lgammaf.rs diff --git a/libs/l2math/core/lgammaf_r.rs b/libs/helper/l2math/core/lgammaf_r.rs similarity index 100% rename from libs/l2math/core/lgammaf_r.rs rename to libs/helper/l2math/core/lgammaf_r.rs diff --git a/libs/l2math/core/ln.rs b/libs/helper/l2math/core/ln.rs similarity index 100% rename from libs/l2math/core/ln.rs rename to libs/helper/l2math/core/ln.rs diff --git a/libs/l2math/core/lnf.rs b/libs/helper/l2math/core/lnf.rs similarity index 100% rename from libs/l2math/core/lnf.rs rename to libs/helper/l2math/core/lnf.rs diff --git a/libs/l2math/core/log.rs b/libs/helper/l2math/core/log.rs similarity index 100% rename from libs/l2math/core/log.rs rename to libs/helper/l2math/core/log.rs diff --git a/libs/l2math/core/log10.rs b/libs/helper/l2math/core/log10.rs similarity index 100% rename from libs/l2math/core/log10.rs rename to libs/helper/l2math/core/log10.rs diff --git a/libs/l2math/core/log10f.rs b/libs/helper/l2math/core/log10f.rs similarity index 100% rename from libs/l2math/core/log10f.rs rename to libs/helper/l2math/core/log10f.rs diff --git a/libs/l2math/core/log1p.rs b/libs/helper/l2math/core/log1p.rs similarity index 100% rename from libs/l2math/core/log1p.rs rename to libs/helper/l2math/core/log1p.rs diff --git a/libs/l2math/core/log1pf.rs b/libs/helper/l2math/core/log1pf.rs similarity index 100% rename from libs/l2math/core/log1pf.rs rename to libs/helper/l2math/core/log1pf.rs diff --git a/libs/l2math/core/log2.rs b/libs/helper/l2math/core/log2.rs similarity index 100% rename from libs/l2math/core/log2.rs rename to libs/helper/l2math/core/log2.rs diff --git a/libs/l2math/core/log2f.rs b/libs/helper/l2math/core/log2f.rs similarity index 100% rename from libs/l2math/core/log2f.rs rename to libs/helper/l2math/core/log2f.rs diff --git a/libs/l2math/core/logf.rs b/libs/helper/l2math/core/logf.rs similarity index 100% rename from libs/l2math/core/logf.rs rename to libs/helper/l2math/core/logf.rs diff --git a/libs/l2math/core/modf.rs b/libs/helper/l2math/core/modf.rs similarity index 100% rename from libs/l2math/core/modf.rs rename to libs/helper/l2math/core/modf.rs diff --git a/libs/l2math/core/modff.rs b/libs/helper/l2math/core/modff.rs similarity index 100% rename from libs/l2math/core/modff.rs rename to libs/helper/l2math/core/modff.rs diff --git a/libs/l2math/core/nextafter.rs b/libs/helper/l2math/core/nextafter.rs similarity index 100% rename from libs/l2math/core/nextafter.rs rename to libs/helper/l2math/core/nextafter.rs diff --git a/libs/l2math/core/nextafterf.rs b/libs/helper/l2math/core/nextafterf.rs similarity index 100% rename from libs/l2math/core/nextafterf.rs rename to libs/helper/l2math/core/nextafterf.rs diff --git a/libs/l2math/core/pow.rs b/libs/helper/l2math/core/pow.rs similarity index 100% rename from libs/l2math/core/pow.rs rename to libs/helper/l2math/core/pow.rs diff --git a/libs/l2math/core/powf.rs b/libs/helper/l2math/core/powf.rs similarity index 100% rename from libs/l2math/core/powf.rs rename to libs/helper/l2math/core/powf.rs diff --git a/libs/l2math/core/rem_pio2.rs b/libs/helper/l2math/core/rem_pio2.rs similarity index 100% rename from libs/l2math/core/rem_pio2.rs rename to libs/helper/l2math/core/rem_pio2.rs diff --git a/libs/l2math/core/rem_pio2_large.rs b/libs/helper/l2math/core/rem_pio2_large.rs similarity index 100% rename from libs/l2math/core/rem_pio2_large.rs rename to libs/helper/l2math/core/rem_pio2_large.rs diff --git a/libs/l2math/core/rem_pio2f.rs b/libs/helper/l2math/core/rem_pio2f.rs similarity index 100% rename from libs/l2math/core/rem_pio2f.rs rename to libs/helper/l2math/core/rem_pio2f.rs diff --git a/libs/l2math/core/remainder.rs b/libs/helper/l2math/core/remainder.rs similarity index 100% rename from libs/l2math/core/remainder.rs rename to libs/helper/l2math/core/remainder.rs diff --git a/libs/l2math/core/remainderf.rs b/libs/helper/l2math/core/remainderf.rs similarity index 100% rename from libs/l2math/core/remainderf.rs rename to libs/helper/l2math/core/remainderf.rs diff --git a/libs/l2math/core/remquo.rs b/libs/helper/l2math/core/remquo.rs similarity index 100% rename from libs/l2math/core/remquo.rs rename to libs/helper/l2math/core/remquo.rs diff --git a/libs/l2math/core/remquof.rs b/libs/helper/l2math/core/remquof.rs similarity index 100% rename from libs/l2math/core/remquof.rs rename to libs/helper/l2math/core/remquof.rs diff --git a/libs/l2math/core/rint.rs b/libs/helper/l2math/core/rint.rs similarity index 100% rename from libs/l2math/core/rint.rs rename to libs/helper/l2math/core/rint.rs diff --git a/libs/l2math/core/rintf.rs b/libs/helper/l2math/core/rintf.rs similarity index 100% rename from libs/l2math/core/rintf.rs rename to libs/helper/l2math/core/rintf.rs diff --git a/libs/l2math/core/round.rs b/libs/helper/l2math/core/round.rs similarity index 100% rename from libs/l2math/core/round.rs rename to libs/helper/l2math/core/round.rs diff --git a/libs/l2math/core/roundf.rs b/libs/helper/l2math/core/roundf.rs similarity index 100% rename from libs/l2math/core/roundf.rs rename to libs/helper/l2math/core/roundf.rs diff --git a/libs/l2math/core/scalbn.rs b/libs/helper/l2math/core/scalbn.rs similarity index 100% rename from libs/l2math/core/scalbn.rs rename to libs/helper/l2math/core/scalbn.rs diff --git a/libs/l2math/core/scalbnf.rs b/libs/helper/l2math/core/scalbnf.rs similarity index 100% rename from libs/l2math/core/scalbnf.rs rename to libs/helper/l2math/core/scalbnf.rs diff --git a/libs/l2math/core/sin.rs b/libs/helper/l2math/core/sin.rs similarity index 100% rename from libs/l2math/core/sin.rs rename to libs/helper/l2math/core/sin.rs diff --git a/libs/l2math/core/sincos.rs b/libs/helper/l2math/core/sincos.rs similarity index 100% rename from libs/l2math/core/sincos.rs rename to libs/helper/l2math/core/sincos.rs diff --git a/libs/l2math/core/sincosf.rs b/libs/helper/l2math/core/sincosf.rs similarity index 100% rename from libs/l2math/core/sincosf.rs rename to libs/helper/l2math/core/sincosf.rs diff --git a/libs/l2math/core/sinf.rs b/libs/helper/l2math/core/sinf.rs similarity index 100% rename from libs/l2math/core/sinf.rs rename to libs/helper/l2math/core/sinf.rs diff --git a/libs/l2math/core/sinh.rs b/libs/helper/l2math/core/sinh.rs similarity index 100% rename from libs/l2math/core/sinh.rs rename to libs/helper/l2math/core/sinh.rs diff --git a/libs/l2math/core/sinhf.rs b/libs/helper/l2math/core/sinhf.rs similarity index 100% rename from libs/l2math/core/sinhf.rs rename to libs/helper/l2math/core/sinhf.rs diff --git a/libs/l2math/core/sqrt.rs b/libs/helper/l2math/core/sqrt.rs similarity index 100% rename from libs/l2math/core/sqrt.rs rename to libs/helper/l2math/core/sqrt.rs diff --git a/libs/l2math/core/sqrtf.rs b/libs/helper/l2math/core/sqrtf.rs similarity index 100% rename from libs/l2math/core/sqrtf.rs rename to libs/helper/l2math/core/sqrtf.rs diff --git a/libs/l2math/core/tan.rs b/libs/helper/l2math/core/tan.rs similarity index 100% rename from libs/l2math/core/tan.rs rename to libs/helper/l2math/core/tan.rs diff --git a/libs/l2math/core/tanf.rs b/libs/helper/l2math/core/tanf.rs similarity index 100% rename from libs/l2math/core/tanf.rs rename to libs/helper/l2math/core/tanf.rs diff --git a/libs/l2math/core/tanh.rs b/libs/helper/l2math/core/tanh.rs similarity index 100% rename from libs/l2math/core/tanh.rs rename to libs/helper/l2math/core/tanh.rs diff --git a/libs/l2math/core/tanhf.rs b/libs/helper/l2math/core/tanhf.rs similarity index 100% rename from libs/l2math/core/tanhf.rs rename to libs/helper/l2math/core/tanhf.rs diff --git a/libs/l2math/core/tgamma.rs b/libs/helper/l2math/core/tgamma.rs similarity index 100% rename from libs/l2math/core/tgamma.rs rename to libs/helper/l2math/core/tgamma.rs diff --git a/libs/l2math/core/tgammaf.rs b/libs/helper/l2math/core/tgammaf.rs similarity index 100% rename from libs/l2math/core/tgammaf.rs rename to libs/helper/l2math/core/tgammaf.rs diff --git a/libs/l2math/core/trunc.rs b/libs/helper/l2math/core/trunc.rs similarity index 100% rename from libs/l2math/core/trunc.rs rename to libs/helper/l2math/core/trunc.rs diff --git a/libs/l2math/core/truncf.rs b/libs/helper/l2math/core/truncf.rs similarity index 100% rename from libs/l2math/core/truncf.rs rename to libs/helper/l2math/core/truncf.rs diff --git a/libs/l2math/core/ulp.rs b/libs/helper/l2math/core/ulp.rs similarity index 100% rename from libs/l2math/core/ulp.rs rename to libs/helper/l2math/core/ulp.rs diff --git a/libs/l2math/lib.rs b/libs/helper/l2math/lib.rs similarity index 100% rename from libs/l2math/lib.rs rename to libs/helper/l2math/lib.rs diff --git a/libs/l2math/macros.rs b/libs/helper/l2math/macros.rs similarity index 100% rename from libs/l2math/macros.rs rename to libs/helper/l2math/macros.rs diff --git a/libs/l2math/types.rs b/libs/helper/l2math/types.rs similarity index 100% rename from libs/l2math/types.rs rename to libs/helper/l2math/types.rs diff --git a/libs/libtrig/Cargo.toml b/libs/helper/libtrig/Cargo.toml similarity index 100% rename from libs/libtrig/Cargo.toml rename to libs/helper/libtrig/Cargo.toml diff --git a/libs/libtrig/README.md b/libs/helper/libtrig/README.md similarity index 100% rename from libs/libtrig/README.md rename to libs/helper/libtrig/README.md diff --git a/libs/libtrig/angle.rs b/libs/helper/libtrig/angle.rs similarity index 100% rename from libs/libtrig/angle.rs rename to libs/helper/libtrig/angle.rs diff --git a/libs/libtrig/coords/coord2d.rs b/libs/helper/libtrig/coords/coord2d.rs similarity index 100% rename from libs/libtrig/coords/coord2d.rs rename to libs/helper/libtrig/coords/coord2d.rs diff --git a/libs/libtrig/coords/coord3d.rs b/libs/helper/libtrig/coords/coord3d.rs similarity index 100% rename from libs/libtrig/coords/coord3d.rs rename to libs/helper/libtrig/coords/coord3d.rs diff --git a/libs/libtrig/coords/mod.rs b/libs/helper/libtrig/coords/mod.rs similarity index 100% rename from libs/libtrig/coords/mod.rs rename to libs/helper/libtrig/coords/mod.rs diff --git a/libs/libtrig/lib.rs b/libs/helper/libtrig/lib.rs similarity index 100% rename from libs/libtrig/lib.rs rename to libs/helper/libtrig/lib.rs diff --git a/libs/libtrig/morenums/mod.rs b/libs/helper/libtrig/morenums/mod.rs similarity index 100% rename from libs/libtrig/morenums/mod.rs rename to libs/helper/libtrig/morenums/mod.rs diff --git a/libs/libtrig/morenums/u2/impls.rs b/libs/helper/libtrig/morenums/u2/impls.rs similarity index 100% rename from libs/libtrig/morenums/u2/impls.rs rename to libs/helper/libtrig/morenums/u2/impls.rs diff --git a/libs/libtrig/morenums/u2/mod.rs b/libs/helper/libtrig/morenums/u2/mod.rs similarity index 100% rename from libs/libtrig/morenums/u2/mod.rs rename to libs/helper/libtrig/morenums/u2/mod.rs diff --git a/libs/libtrig/morenums/u2/source.rs b/libs/helper/libtrig/morenums/u2/source.rs similarity index 100% rename from libs/libtrig/morenums/u2/source.rs rename to libs/helper/libtrig/morenums/u2/source.rs diff --git a/libs/libtrig/morenums/u2/tests.rs b/libs/helper/libtrig/morenums/u2/tests.rs similarity index 100% rename from libs/libtrig/morenums/u2/tests.rs rename to libs/helper/libtrig/morenums/u2/tests.rs diff --git a/libs/libtrig/morenums/u3/impls.rs b/libs/helper/libtrig/morenums/u3/impls.rs similarity index 100% rename from libs/libtrig/morenums/u3/impls.rs rename to libs/helper/libtrig/morenums/u3/impls.rs diff --git a/libs/libtrig/morenums/u3/mod.rs b/libs/helper/libtrig/morenums/u3/mod.rs similarity index 100% rename from libs/libtrig/morenums/u3/mod.rs rename to libs/helper/libtrig/morenums/u3/mod.rs diff --git a/libs/libtrig/morenums/u3/source.rs b/libs/helper/libtrig/morenums/u3/source.rs similarity index 100% rename from libs/libtrig/morenums/u3/source.rs rename to libs/helper/libtrig/morenums/u3/source.rs diff --git a/libs/libtrig/morenums/u3/tests.rs b/libs/helper/libtrig/morenums/u3/tests.rs similarity index 100% rename from libs/libtrig/morenums/u3/tests.rs rename to libs/helper/libtrig/morenums/u3/tests.rs diff --git a/libs/libtrig/traits/float.rs b/libs/helper/libtrig/traits/float.rs similarity index 100% rename from libs/libtrig/traits/float.rs rename to libs/helper/libtrig/traits/float.rs diff --git a/libs/libtrig/traits/impls.rs b/libs/helper/libtrig/traits/impls.rs similarity index 100% rename from libs/libtrig/traits/impls.rs rename to libs/helper/libtrig/traits/impls.rs diff --git a/libs/libtrig/traits/mod.rs b/libs/helper/libtrig/traits/mod.rs similarity index 100% rename from libs/libtrig/traits/mod.rs rename to libs/helper/libtrig/traits/mod.rs diff --git a/libs/libtrig/traits/number.rs b/libs/helper/libtrig/traits/number.rs similarity index 100% rename from libs/libtrig/traits/number.rs rename to libs/helper/libtrig/traits/number.rs diff --git a/libs/libtrig/types.rs b/libs/helper/libtrig/types.rs similarity index 100% rename from libs/libtrig/types.rs rename to libs/helper/libtrig/types.rs diff --git a/libs/libtrig/vectors/mod.rs b/libs/helper/libtrig/vectors/mod.rs similarity index 100% rename from libs/libtrig/vectors/mod.rs rename to libs/helper/libtrig/vectors/mod.rs diff --git a/libs/libtrig/vectors/vec2d.rs b/libs/helper/libtrig/vectors/vec2d.rs similarity index 100% rename from libs/libtrig/vectors/vec2d.rs rename to libs/helper/libtrig/vectors/vec2d.rs diff --git a/libs/libtrig/vectors/vec3d.rs b/libs/helper/libtrig/vectors/vec3d.rs similarity index 100% rename from libs/libtrig/vectors/vec3d.rs rename to libs/helper/libtrig/vectors/vec3d.rs diff --git a/libs/macros-core/Cargo.toml b/libs/helper/macros-core/Cargo.toml similarity index 100% rename from libs/macros-core/Cargo.toml rename to libs/helper/macros-core/Cargo.toml diff --git a/libs/macros-core/ffi/mod.rs b/libs/helper/macros-core/ffi/mod.rs similarity index 100% rename from libs/macros-core/ffi/mod.rs rename to libs/helper/macros-core/ffi/mod.rs diff --git a/libs/macros-core/func_mod/mod.rs b/libs/helper/macros-core/func_mod/mod.rs similarity index 100% rename from libs/macros-core/func_mod/mod.rs rename to libs/helper/macros-core/func_mod/mod.rs diff --git a/libs/macros-core/lib.rs b/libs/helper/macros-core/lib.rs similarity index 100% rename from libs/macros-core/lib.rs rename to libs/helper/macros-core/lib.rs diff --git a/libs/macros-core/mass_impl/args.rs b/libs/helper/macros-core/mass_impl/args.rs similarity index 100% rename from libs/macros-core/mass_impl/args.rs rename to libs/helper/macros-core/mass_impl/args.rs diff --git a/libs/macros-core/mass_impl/mod.rs b/libs/helper/macros-core/mass_impl/mod.rs similarity index 100% rename from libs/macros-core/mass_impl/mod.rs rename to libs/helper/macros-core/mass_impl/mod.rs diff --git a/libs/macros-core/mass_impl/variants.rs b/libs/helper/macros-core/mass_impl/variants.rs similarity index 100% rename from libs/macros-core/mass_impl/variants.rs rename to libs/helper/macros-core/mass_impl/variants.rs diff --git a/libs/macros/Cargo.toml b/libs/helper/macros/Cargo.toml similarity index 100% rename from libs/macros/Cargo.toml rename to libs/helper/macros/Cargo.toml diff --git a/libs/libodo/README.md b/libs/helper/macros/README.md similarity index 100% rename from libs/libodo/README.md rename to libs/helper/macros/README.md diff --git a/libs/macros/lib.rs b/libs/helper/macros/lib.rs similarity index 100% rename from libs/macros/lib.rs rename to libs/helper/macros/lib.rs diff --git a/libs/l2math/bindings/.gitignore b/libs/l2math/bindings/.gitignore deleted file mode 100644 index a40651e..0000000 --- a/libs/l2math/bindings/.gitignore +++ /dev/null @@ -1 +0,0 @@ -l2mathtestbin* \ No newline at end of file diff --git a/libs/l2math/bindings/Cargo.toml b/libs/l2math/bindings/Cargo.toml deleted file mode 100644 index 3f961e5..0000000 --- a/libs/l2math/bindings/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "l2math-bindings" -description = "Low Level Math Bindings" -repository.workspace = true -version.workspace = true -edition.workspace = true -authors.workspace = true -license.workspace = true - -[lib] -path = "lib.rs" -crate-type = ["cdylib", "staticlib"] - -[features] -no_std = [] -__android__ = [] - -[dependencies.l2math] -path = ".." diff --git a/libs/l2math/bindings/bindings.py b/libs/l2math/bindings/bindings.py deleted file mode 100644 index 958bb0d..0000000 --- a/libs/l2math/bindings/bindings.py +++ /dev/null @@ -1,165 +0,0 @@ -class BindingsTargetsConfig: - __targets: dict[str, list[str]] - def __init__(self, cd: str): - self.__targets = { } - - import tomllib - - cd = f"{cd}/libs/l2math/bindings" - - try: - with open(f"{cd}/bindings.targets.config.toml", "rb") as f: - data = tomllib.load(f) - for target in data: - self.add(target, data[target]) - except Exception as e: - print(f"Failed to load bindings.targets.config.toml: {e}") - exit(1) - - def add(self, name: str, deps: list[str]): - self.__targets[name] = deps - def get(self, name: str) -> list[str]: - if name not in self.__targets: return [] - return self.__targets[name] - def get_all_registries(self) -> list[str]: - return list(self.__targets.keys()) - def get_all_targets(self) -> list[str]: - out: list[str] = [] - for registry in self.get_all_registries(): - out.extend(self.get(registry)) - return out - -# "windows", "linux", "macos", "android", "ios", "unknown" -def get_current_platform() -> str: - import platform - - if platform.system() == "Windows": - return "windows" - elif platform.system() == "Linux": - return "linux" - elif platform.system() == "Darwin": - return "macos" - elif platform.system() == "Android": - return "android" - elif platform.system() == "iOS": - return "ios" - else: - return "unknown" - -def build_l2math_bindings(cd: str, args: list[str]) -> str | int | None: - architecture = args[0] if len(args) > 0 else get_current_platform() - - print(f"Building L2Math bindings for {architecture}...") - - config = BindingsTargetsConfig(cd) - targets = config.get(architecture) - - if len(targets) == 0: return f"No targets found for {architecture}!" - - if architecture == "windows": - return build_l2math_bindings_windows(cd, targets) - elif architecture == "linux": - return build_l2math_bindings_linux(cd, targets) - elif architecture == "macos": - return build_l2math_bindings_macos(cd, targets) - elif architecture == "android": - return build_l2math_bindings_android(cd, targets) - else: - return build_l2math_bindings_unknown(cd, targets) - -from typing import Callable - -def common_build_l2math_bindings( - cd: str, targets: list[str], - to_f: Callable[[str], list[str]], - from_f: Callable[[str], list[str]] -) -> int | str | None: - import subprocess, shutil, os - - for target in targets: - print(f"Building L2Math bindings for {target}...") - - cmd = ["cargo", "build", "--target", target, "-r", "-p", "l2math-bindings"] - res = subprocess.run(cmd, cwd=cd) - if res.returncode != 0: return res.returncode - - print("Copying L2Math bindings...") - - TO_DIR = f"{cd}/libs/l2math/bindings/.build" - if not os.path.exists(TO_DIR): - os.mkdir(TO_DIR) - to_f_res = to_f(target) - from_f_res = from_f(target) - - for i in range(len(to_f_res)): - TO = f"{TO_DIR}/{to_f_res[i]}" - if os.path.exists(TO): - print(f"Removing {TO}...") - os.remove(TO) - FROM = f"{cd}/target/{target}/release/{from_f_res[i]}" - if os.path.exists(FROM) and not os.path.exists(TO): - shutil.move(FROM, TO) - print("Done!") - return - return "Could not find the L2Math bindings library!" - -def build_l2math_bindings_windows(cd: str, targets: list[str]) -> int | str | None: - return common_build_l2math_bindings( - cd, targets, - lambda t: [f"l2math-{t}.dll", f"l2math-{t}.lib"], - lambda _: ["l2math_bindings.dll", "l2math_bindings.lib"] - ) - -def build_l2math_bindings_linux(cd: str, targets: list[str]) -> int | str | None: - return common_build_l2math_bindings( - cd, targets, - lambda t: [f"libl2math-{t}.so"], - lambda _: ["libl2math_bindings.so"] - ) - -def build_l2math_bindings_macos(cd: str, targets: list[str]) -> int | str | None: - return common_build_l2math_bindings( - cd, targets, - lambda t: [f"libl2math-{t}.dylib"], - lambda _: ["libl2math_bindings.dylib"] - ) - -def build_l2math_bindings_android(cd: str, targets: list[str]) -> int | str | None: - import shutil, os - - TO_DIR = f"{cd}/libs/l2math/bindings/.build" - if not os.path.exists(TO_DIR): os.mkdir(TO_DIR) - - for target in targets: - import subprocess - - print(f"Building L2Math bindings for {target}...") - - cmd = ["cargo", "ndk", "-t", target, "-o", f"{cd}/target/ndk/", "build", "--release", "-p", "l2math-bindings"] - res = subprocess.run(cmd, cwd = cd) - if res.returncode != 0: return res.returncode - - print(f"Copying L2Math bindings for {target}...") - - TO = f"{TO_DIR}/libl2math-{target}.so" - if os.path.exists(TO): - print(f"Removing {TO}...") - os.remove(TO) - FROM = f"{cd}/target/ndk/{target}/libl2math_bindings.so" - if os.path.exists(FROM) and not os.path.exists(TO): - shutil.move(FROM, TO) - - print("Copying libc++_shared.so...") - - TO = f"{TO_DIR}/libc++_shared.so" - if os.path.exists(TO): - print(f"Removing {TO}...") - os.remove(TO) - FROM = f"{cd}/target/ndk/libc++_shared.so" - if os.path.exists(FROM) and not os.path.exists(TO): - shutil.move(FROM, TO) - - print("Done!") - -def build_l2math_bindings_unknown(cd: str, targets: list[str]) -> str | None: - return "Unknown platform!" diff --git a/libs/l2math/bindings/bindings.targets.config.toml b/libs/l2math/bindings/bindings.targets.config.toml deleted file mode 100644 index 9feeec7..0000000 --- a/libs/l2math/bindings/bindings.targets.config.toml +++ /dev/null @@ -1,26 +0,0 @@ -linux = [ - "x86_64-unknown-linux-gnu", - # You may add more targets below, as long as they are supported by the Rust. - # ALL target triples will be built and copied to the output directory. -] - -windows = [ - "x86_64-pc-windows-msvc", -] - -macos = [ - "x86_64-apple-darwin", -] - -android = [ - "armeabi-v7a", - "arm64-v8a", - - # These also work, but are not needed for me. - # "x86_64-linux-android", - # "i686-linux-android", -] - -# You may add more targets below, as long as they are supported by the Rust. -# As an example: -# wasm = [ "wasm32-unknown-unknown" ] diff --git a/libs/l2math/bindings/build.rs b/libs/l2math/bindings/build.rs deleted file mode 100644 index 3639dba..0000000 --- a/libs/l2math/bindings/build.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![allow(unused)] - -use std::env; -use std::path::{Path, PathBuf}; - -type Res> = Result; - -fn main() -> Res { - if env::var("CARGO_CFG_TARGET_OS")? == "android" { - android()?; - }; - Ok(()) -} - -#[rustfmt::skip] -#[cfg(feature = "__android__")] -fn android() -> Res { Ok(()) } - -#[cfg(not(feature = "__android__"))] -fn android() -> Res { - println!("cargo:rustc-link-lib=c++_shared"); - let output_path = env::var("CARGO_NDK_OUTPUT_PATH")?; - let ndk_sysroot_libs_path = - env::var_os("CARGO_NDK_SYSROOT_LIBS_PATH").ok_or("CARGO_NDK_SYSROOT_LIBS_PATH not set")?; - let sysroot_libs_path: PathBuf = ndk_sysroot_libs_path.into(); - let lib_path = sysroot_libs_path.join("libc++_shared.so"); - let new_lib_path = Path::new(&output_path).join("libc++_shared.so"); - std::fs::copy(lib_path, new_lib_path)?; - Ok(()) -} diff --git a/libs/l2math/bindings/l2math.h b/libs/l2math/bindings/l2math.h deleted file mode 100644 index f0b9169..0000000 --- a/libs/l2math/bindings/l2math.h +++ /dev/null @@ -1,783 +0,0 @@ -/** - * @file l2math.h - * @author Матвей Т - * @brief C bindings for l2math - * @version 0.1.0-dev - * @date 2023-11-22 -*/ - -#ifndef __L2MATH_H -#define __L2MATH_H - -#ifdef __cplusplus -namespace l2math { - extern "C" { -#endif // __cplusplus - -// C binding for rust's f64 -typedef double ____l2math_f64; -// C binding for rust's f32 -typedef float ____l2math_f32; -// C binding for rust's i32 -typedef int ____l2math_i32; - -/// High precision floating point number -typedef ____l2math_f64 __l2math_Float64; -/// Low precision floating point number -typedef ____l2math_f32 __l2math_Float32; -/// High precision floating point number representing an angle -typedef ____l2math_f64 __l2math_Radian64; -/// Low precision floating point number representing an angle -typedef ____l2math_f32 __l2math_Radian32; -/// High precision floating point number representing an angle in degrees -typedef ____l2math_f64 __l2math_Degree64; -/// Low precision floating point number representing an angle in degrees -typedef ____l2math_f32 __l2math_Degree32; -/// A standard signed integer -typedef ____l2math_i32 __l2math_Int; - -/// A structure representing a tuple of a `__l2math_Float64` and an `__l2math_Int` -typedef struct __l2math_Tuple_Float64_Int { - __l2math_Float64 f; - __l2math_Int i; -} __l2math_Tuple_Float64_Int; - -/// A structure representing a tuple of a `__l2math_Float32` and an `__l2math_Int` -typedef struct __l2math_Tuple_Float32_Int { - __l2math_Float32 f; - __l2math_Int i; -} __l2math_Tuple_Float32_Int; - -/// A structure representing a tuple of two `__l2math_Float64`s -typedef struct __l2math_Tuple_Float64_Float64 { - __l2math_Float64 f1; - __l2math_Float64 f2; -} __l2math_Tuple_Float64_Float64; - -/// A structure representing a tuple of two `__l2math_Float32`s -typedef struct __l2math_Tuple_Float32_Float32 { - __l2math_Float32 f1; - __l2math_Float32 f2; -} __l2math_Tuple_Float32_Float32; - -/// Arccosine -__l2math_Radian64 __l2math_acos(__l2math_Float64 x); -/// Arccosine (__l2math_Float32) -__l2math_Radian32 __l2math_acosf(__l2math_Float32 x); -/// Inverse hyperbolic cosine -__l2math_Float64 __l2math_acosh(__l2math_Float64 x); -/// Inverse hyperbolic cosine (__l2math_Float32) -__l2math_Float32 __l2math_acoshf(__l2math_Float32 x); -/// Arcsine -__l2math_Radian64 __l2math_asin(__l2math_Float64 x); -/// Arcsine (__l2math_Float32) -__l2math_Radian32 __l2math_asinf(__l2math_Float32 x); -/// Inverse hyperbolic sine -__l2math_Float64 __l2math_asinh(__l2math_Float64 x); -/// Inverse hyperbolic sine (__l2math_Float32) -__l2math_Float32 __l2math_asinhf(__l2math_Float32 x); -/// Arctangent -__l2math_Radian64 __l2math_atan(__l2math_Float64 x); -/// Arctangent of y/x -__l2math_Radian64 __l2math_atan2(__l2math_Float64 y, __l2math_Float64 x); -/// Arctangent of y/x (__l2math_Float32) -__l2math_Radian32 __l2math_atan2f(__l2math_Float32 y, __l2math_Float32 x); -/// Arctangent (__l2math_Float32) -__l2math_Radian32 __l2math_atanf(__l2math_Float32 x); -/// Inverse hyperbolic tangent -__l2math_Float64 __l2math_atanh(__l2math_Float64 x); -/// Inverse hyperbolic tangent (__l2math_Float32) -__l2math_Float32 __l2math_atanhf(__l2math_Float32 x); -/// Computes the cube root of the argument. -__l2math_Float64 __l2math_cbrt(__l2math_Float64 x); -/// Cube root (__l2math_Float32) -__l2math_Float32 __l2math_cbrtf(__l2math_Float32 x); -/// Ceil -__l2math_Float64 __l2math_ceil(__l2math_Float64 x); -/// Ceil (__l2math_Float32) -__l2math_Float32 __l2math_ceilf(__l2math_Float32 x); -/// Sign of Y, magnitude of X -__l2math_Float64 __l2math_copysign(__l2math_Float64 x, __l2math_Float64 y); -/// Sign of Y, magnitude of X (__l2math_Float32) -__l2math_Float32 __l2math_copysignf(__l2math_Float32 x, __l2math_Float32 y); -/// Cosine -__l2math_Float64 __l2math_cos(__l2math_Radian64 x); -/// Cosine (__l2math_Float32) -__l2math_Float32 __l2math_cosf(__l2math_Radian32 x); -/// Hyperbolic cosine -__l2math_Float64 __l2math_cosh(__l2math_Float64 x); -/// Hyperbolic cosine (__l2math_Float32) -__l2math_Float32 __l2math_coshf(__l2math_Float32 x); -/// Computes the exponential function of x. -__l2math_Float64 __l2math_exp(__l2math_Float64 x); -/// Computes the exponential function of x (__l2math_Float32). -__l2math_Float32 __l2math_expf(__l2math_Float32 x); -/// Computes the exponential minus one function of x. -__l2math_Float64 __l2math_expm1(__l2math_Float64 x); -/// Computes the exponential minus one function of x (__l2math_Float32). -__l2math_Float32 __l2math_expm1f(__l2math_Float32 x); -/// Absolute value -__l2math_Float64 __l2math_fabs(__l2math_Float64 x); -/// Absolute value (__l2math_Float32) -__l2math_Float32 __l2math_fabsf(__l2math_Float32 x); -/// Factorial -__l2math_Float64 __l2math_factorial(__l2math_Float64 x); -/// Factorial (__l2math_Float32) -__l2math_Float32 __l2math_factorialf(__l2math_Float32 x); -/// Floor -__l2math_Float64 __l2math_floor(__l2math_Float64 x); -/// Floor (__l2math_Float32) -__l2math_Float32 __l2math_floorf(__l2math_Float32 x); -/// Computes the fused multiply-add of x, y and z. -__l2math_Float64 __l2math_fma(__l2math_Float64 x, __l2math_Float64 y, __l2math_Float64 z); -/// Computes the fused multiply-add of x, y and z (__l2math_Float32). -__l2math_Float32 __l2math_fmaf(__l2math_Float32 x, __l2math_Float32 y, __l2math_Float32 z); -/// Returns the maximum of the two arguments, signaling NaNs if either argument is a signaling NaN. -__l2math_Float64 __l2math_fmax(__l2math_Float64 x, __l2math_Float64 y); -/// Returns the maximum of the two arguments, signaling NaNs if either argument is a signaling NaN (__l2math_Float32). -__l2math_Float32 __l2math_fmaxf(__l2math_Float32 x, __l2math_Float32 y); -/// Returns the minimum of the two arguments, signaling NaNs if either argument is a signaling NaN. -__l2math_Float64 __l2math_fmin(__l2math_Float64 x, __l2math_Float64 y); -/// Returns the minimum of the two arguments, signaling NaNs if either argument is a signaling NaN (__l2math_Float32). -__l2math_Float32 __l2math_fminf(__l2math_Float32 x, __l2math_Float32 y); -/// Computes the floating-point remainder of dividing x by y. -__l2math_Float64 __l2math_fmod(__l2math_Float64 x, __l2math_Float64 y); -/// Computes the floating-point remainder of dividing x by y (__l2math_Float32). -__l2math_Float32 __l2math_fmodf(__l2math_Float32 x, __l2math_Float32 y); -/// Breaks the number into a normalized fraction and a base-2 exponent -__l2math_Tuple_Float64_Int __l2math_frexp(__l2math_Float64 x); -/// Breaks the number into a normalized fraction and a base-2 exponent (__l2math_Float32) -__l2math_Tuple_Float32_Int __l2math_frexpf(__l2math_Float32 x); -/// Calculate the length of the hypotenuse of a right-angle triangle given legs of length x and y. -__l2math_Float64 __l2math_hypot(__l2math_Float64 x, __l2math_Float64 y); -/// Calculate the length of the hypotenuse of a right-angle triangle given legs of length x and y (__l2math_Float32). -__l2math_Float32 __l2math_hypotf(__l2math_Float32 x, __l2math_Float32 y); -/// Get exponent of floating point value -__l2math_Int __l2math_ilogb(__l2math_Float64 x); -/// Get exponent of floating point value (__l2math_Float32) -__l2math_Int __l2math_ilogbf(__l2math_Float32 x); -/// Bessel function of the first kind of order zero -__l2math_Float64 __l2math_j0(__l2math_Float64 x); -/// Bessel function of the first kind of order zero (__l2math_Float32) -__l2math_Float32 __l2math_j0f(__l2math_Float32 x); -/// Bessel function of the first kind of order one -__l2math_Float64 __l2math_j1(__l2math_Float64 x); -/// Bessel function of the first kind of order one (__l2math_Float32) -__l2math_Float32 __l2math_j1f(__l2math_Float32 x); -/// Bessel function of the first kind of order n -__l2math_Float64 __l2math_jn(__l2math_Int n, __l2math_Float64 x); -/// Bessel function of the first kind of order n (__l2math_Float32) -__l2math_Float32 __l2math_jnf(__l2math_Int n, __l2math_Float32 x); -/// Returns x * 2^n. -__l2math_Float64 __l2math_ldexp(__l2math_Float64 x, __l2math_Int n); -/// Returns x * 2^n (__l2math_Float32). -__l2math_Float32 __l2math_ldexpf(__l2math_Float32 x, __l2math_Int n); -/// Natural logarithm of gamma function -__l2math_Float64 __l2math_lgamma(__l2math_Float64 x); -/// Natural logarithm of gamma function (__l2math_Float32) -__l2math_Float32 __l2math_lgammaf(__l2math_Float32 x); -/// Natural logarithm of gamma function -__l2math_Tuple_Float64_Int __l2math_lgamma_r(__l2math_Float64 x); -/// Natural logarithm of gamma function (__l2math_Float32) -__l2math_Tuple_Float32_Int __l2math_lgammaf_r(__l2math_Float32 x); -/// Return the natural logarithm of x. -__l2math_Float64 __l2math_ln(__l2math_Float64 x); -/// Return the natural logarithm of x (__l2math_Float32). -__l2math_Float32 __l2math_lnf(__l2math_Float32 x); -/// Return logarithm of x. -__l2math_Float64 __l2math_log(__l2math_Float64 x); -/// Return logarithm of x (__l2math_Float32). -__l2math_Float32 __l2math_logf(__l2math_Float32 x); -/// Return logarithm of x to base 10. -__l2math_Float64 __l2math_log10(__l2math_Float64 x); -/// Return logarithm of x to base 10 (__l2math_Float32). -__l2math_Float32 __l2math_log10f(__l2math_Float32 x); -/// Return logarithm of x to base 2. -__l2math_Float64 __l2math_log2(__l2math_Float64 x); -/// Return logarithm of x to base 2 (__l2math_Float32). -__l2math_Float32 __l2math_log2f(__l2math_Float32 x); -/// Return the natural logarithm of one plus x. -__l2math_Float64 __l2math_log1p(__l2math_Float64 x); -/// Return the natural logarithm of one plus x (__l2math_Float32). -__l2math_Float32 __l2math_log1pf(__l2math_Float32 x); -/// Breaks the given number into an integral and a fractional part. -__l2math_Tuple_Float64_Float64 __l2math_modf(__l2math_Float64 x); -/// Breaks the given number into an integral and a fractional part (__l2math_Float32). -__l2math_Tuple_Float32_Float32 __l2math_modff(__l2math_Float32 x); -/// Returns the next representable floating-point value following x in the direction of y. -__l2math_Float64 __l2math_nextafter(__l2math_Float64 x, __l2math_Float64 y); -/// Returns the next representable floating-point value following x in the direction of y. (__l2math_Float32) -__l2math_Float32 __l2math_nextafterf(__l2math_Float32 x, __l2math_Float32 y); -/// Returns x raised to the power y. -__l2math_Float64 __l2math_pow(__l2math_Float64 x, __l2math_Float64 y); -/// Returns x raised to the power y. (__l2math_Float32) -__l2math_Float32 __l2math_powf(__l2math_Float32 x, __l2math_Float32 y); -/// Returns the remainder of x/y. -__l2math_Float64 __l2math_remainder(__l2math_Float64 x, __l2math_Float64 y); -/// Returns the remainder of x/y. (__l2math_Float32) -__l2math_Float32 __l2math_remainderf(__l2math_Float32 x, __l2math_Float32 y); -/// Return the remainder and part of the quotient of x and y. -__l2math_Tuple_Float64_Int __l2math_remquo(__l2math_Float64 x, __l2math_Float64 y); -/// Return the remainder and part of the quotient of x and y. (__l2math_Float32) -__l2math_Tuple_Float32_Int __l2math_remquof(__l2math_Float32 x, __l2math_Float32 y); -/// Round to nearest integer, rounding halfway cases away from zero. -__l2math_Float64 __l2math_rint(__l2math_Float64 x); -/// Round to nearest integer, rounding halfway cases away from zero. (__l2math_Float32) -__l2math_Float32 __l2math_rintf(__l2math_Float32 x); -/// Rounds x to the nearest integer in the direction of the current rounding mode. -__l2math_Float64 __l2math_round(__l2math_Float64 x); -/// Rounds x to the nearest integer in the direction of the current rounding mode. (__l2math_Float32) -__l2math_Float32 __l2math_roundf(__l2math_Float32 x); -/// Returns x * 2^n -__l2math_Float64 __l2math_scalbn(__l2math_Float64 x, __l2math_Int n); -/// Returns x * 2^n (__l2math_Float32) -__l2math_Float32 __l2math_scalbnf(__l2math_Float32 x, __l2math_Int n); -/// Returns the sine function of x. -__l2math_Float64 __l2math_sin(__l2math_Radian64 x); -/// Simultaneously computes the sine and cosine of the argument x. -__l2math_Tuple_Float64_Float64 __l2math_sincos(__l2math_Radian64 x); -/// Simultaneously computes the sine and cosine of the argument x. (__l2math_Float32) -__l2math_Tuple_Float32_Float32 __l2math_sincosf(__l2math_Radian32 x); -/// Returns the sine of the argument x. -__l2math_Float64 __l2math_sinf(__l2math_Float64 x); -/// Returns the hyperbolic sine of x. -__l2math_Float64 __l2math_sinh(__l2math_Float64 x); -/// Returns the hyperbolic sine of x. (__l2math_Float32) -__l2math_Float32 __l2math_sinhf(__l2math_Float32 x); -/// Returns the square root of x. -__l2math_Float64 __l2math_sqrt(__l2math_Float64 x); -/// Returns the square root of x. (__l2math_Float32) -__l2math_Float32 __l2math_sqrtf(__l2math_Float32 x); -/// Returns tangent of x. -__l2math_Float64 __l2math_tan(__l2math_Radian64 x); -/// Returns tangent of x. (__l2math_Float32) -__l2math_Float32 __l2math_tanf(__l2math_Radian32 x); -/// Returns the hyperbolic tangent of x. -__l2math_Float64 __l2math_tanh(__l2math_Float64 x); -/// Returns the hyperbolic tangent of x. (__l2math_Float32) -__l2math_Float32 __l2math_tanhf(__l2math_Float32 x); -/// Returns the gamma function of x. -__l2math_Float64 __l2math_tgamma(__l2math_Float64 x); -/// Returns the gamma function of x. (__l2math_Float32) -__l2math_Float32 __l2math_tgammaf(__l2math_Float32 x); -/// Returns the integer part of self. This means that non-integer numbers are always truncated towards zero. -__l2math_Float64 __l2math_trunc(__l2math_Float64 x); -/// Returns the integer part of self. This means that non-integer numbers are always truncated towards zero. (__l2math_Float32) -__l2math_Float32 __l2math_truncf(__l2math_Float32 x); -/// Returns the value of the least significant bit of the given floating point number. -__l2math_Float64 __l2math_ulp(__l2math_Float64 x); -/// Bessel function of the second kind of order zero -__l2math_Float64 __l2math_y0(__l2math_Float64 x); -/// Bessel function of the second kind of order zero (__l2math_Float32) -__l2math_Float32 __l2math_y0f(__l2math_Float32 x); -/// Bessel function of the second kind of order one -__l2math_Float64 __l2math_y1(__l2math_Float64 x); -/// Bessel function of the second kind of order one (__l2math_Float32) -__l2math_Float32 __l2math_y1f(__l2math_Float32 x); -/// Bessel function of the second kind of order n -__l2math_Float64 __l2math_yn(__l2math_Int n, __l2math_Float64 x); -/// Bessel function of the second kind of order n (__l2math_Float32) -__l2math_Float32 __l2math_ynf(__l2math_Int n, __l2math_Float32 x); - -#ifdef __cplusplus - } - - /// High precision floating point number - typedef __l2math_Float64 Float64; - /// Low precision floating point number - typedef __l2math_Float32 Float32; - /// High precision floating point number representing an angle - typedef __l2math_Radian64 Radian64; - /// Low precision floating point number representing an angle - typedef __l2math_Radian32 Radian32; - /// High precision floating point number representing an angle in degrees - typedef __l2math_Degree64 Degree64; - /// Low precision floating point number representing an angle in degrees - typedef __l2math_Degree32 Degree32; - /// A standard signed integer - typedef __l2math_Int Int; - - constexpr const Float64 PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679; - constexpr const Float64 _PI_OVER_180 = 0.0174532925199432957692369076848861271344287188854172545609719144017100911460344944368224156963450948221230449250737905924838546922752810123984742189340471173191682450150107695616975535812386053051687886912711720870329635896026424901877043509181733439396980475940192241589469684813789632978181124952292984699278144795310454160084495609046069671761964687105143908889518362808267803695632452608441195089412947626131431088441838454784298996256210728062141559692354442374975963993652929160623774343500663840546315186802258; - constexpr const Float64 _180_OVER_PI = 57.295779513082320876798154814105170332405472466564321549160243861202847148321552632440968995851110944186223381632864893281448264601248315036068267863411942122526388097467267926307988702893110767938261442638263158209610460487020506444259656841120171912057738566280431284962624203376187937297623870790340315980719624089522045186205459923396314841906966220115126609691801514787637366923164107126774038514690165499594192515711986479435210661624389035202306756177796757113315683506205731313360156501348898018788709917776439; - - constexpr const Radian64 DEG2RAD(Degree64 deg) { - return deg * _PI_OVER_180; - } - - constexpr const Degree64 RAD2DEG(Radian64 rad) { - return rad * _180_OVER_PI; - } - - template - class Tuple { - private: - L _l; - R _r; - public: - constexpr Tuple(L l, R r) : _l(l), _r(r) {} - constexpr const inline L l() const { - return this->_l; - } - constexpr const inline R r() const { - return this->_r; - } - }; - /// Arccosine - constexpr const inline Radian64 acos(Float64 x) { - return __l2math_acos(x); - } - /// Arccosine (Float32) - constexpr const inline Radian32 acos(Float32 x) { - return __l2math_acosf(x); - } - /// Inverse hyperbolic cosine - constexpr const inline Float64 acosh(Float64 x) { - return __l2math_acosh(x); - } - /// Inverse hyperbolic cosine (Float32) - constexpr const inline Float32 acosh(Float32 x) { - return __l2math_acoshf(x); - } - /// Arcsine - constexpr const inline Radian64 asin(Float64 x) { - return __l2math_asin(x); - } - /// Arcsine (Float32) - constexpr const inline Radian32 asin(Float32 x) { - return __l2math_asinf(x); - } - /// Inverse hyperbolic sine - constexpr const inline Float64 asinh(Float64 x) { - return __l2math_asinh(x); - } - /// Inverse hyperbolic sine (Float32) - constexpr const inline Float32 asinh(Float32 x) { - return __l2math_asinhf(x); - } - /// Arctangent - constexpr const inline Radian64 atan(Float64 x) { - return __l2math_atan(x); - } - /// Arctangent of y/x - constexpr const inline Radian64 atan2(Float64 y, Float64 x) { - return __l2math_atan2(y, x); - } - /// Arctangent of y/x (Float32) - constexpr const inline Radian32 atan2(Float32 y, Float32 x) { - return __l2math_atan2f(y, x); - } - /// Arctangent (Float32) - constexpr const inline Radian32 atan(Float32 x) { - return __l2math_atanf(x); - } - /// Inverse hyperbolic tangent - constexpr const inline Float64 atanh(Float64 x) { - return __l2math_atanh(x); - } - /// Inverse hyperbolic tangent (Float32) - constexpr const inline Float32 atanh(Float32 x) { - return __l2math_atanhf(x); - } - /// Computes the cube root of the argument. - constexpr const inline Float64 cbrt(Float64 x) { - return __l2math_cbrt(x); - } - /// Cube root (Float32) - constexpr const inline Float32 cbrt(Float32 x) { - return __l2math_cbrtf(x); - } - /// Ceil - constexpr const inline Float64 ceil(Float64 x) { - return __l2math_ceil(x); - } - /// Ceil (Float32) - constexpr const inline Float32 ceil(Float32 x) { - return __l2math_ceilf(x); - } - /// Sign of Y, magnitude of X - constexpr const inline Float64 copysign(Float64 x, Float64 y) { - return __l2math_copysign(x, y); - } - /// Sign of Y, magnitude of X (Float32) - constexpr const inline Float32 copysign(Float32 x, Float32 y) { - return __l2math_copysignf(x, y); - } - /// Cosine - constexpr const inline Float64 cos(Radian64 x) { - return __l2math_cos(x); - } - /// Cosine (Float32) - constexpr const inline Float32 cos(Radian32 x) { - return __l2math_cosf(x); - } - /// Hyperbolic cosine - constexpr const inline Float64 cosh(Float64 x) { - return __l2math_cosh(x); - } - /// Hyperbolic cosine (Float32) - constexpr const inline Float32 cosh(Float32 x) { - return __l2math_coshf(x); - } - /// Computes the exponential function of x. - constexpr const inline Float64 exp(Float64 x) { - return __l2math_exp(x); - } - /// Computes the exponential function of x (Float32). - constexpr const inline Float32 exp(Float32 x) { - return __l2math_expf(x); - } - /// Computes the exponential minus one function of x. - constexpr const inline Float64 expm1(Float64 x) { - return __l2math_expm1(x); - } - /// Computes the exponential minus one function of x (Float32). - constexpr const inline Float32 expm1(Float32 x) { - return __l2math_expm1f(x); - } - /// Absolute value - constexpr const inline Float64 abs(Float64 x) { - return __l2math_fabs(x); - } - /// Absolute value (Float32) - constexpr const inline Float32 abs(Float32 x) { - return __l2math_fabsf(x); - } - /// Factorial - constexpr const inline Float64 factorial(Float64 x) { - return __l2math_factorial(x); - } - /// Factorial (Float32) - constexpr const inline Float32 factorial(Float32 x) { - return __l2math_factorialf(x); - } - /// Floor - constexpr const inline Float64 floor(Float64 x) { - return __l2math_floor(x); - } - /// Floor (Float32) - constexpr const inline Float32 floor(Float32 x) { - return __l2math_floorf(x); - } - /// Computes the fused multiply-add of x, y and z. - constexpr const inline Float64 fma(Float64 x, Float64 y, Float64 z) { - return __l2math_fma(x, y, z); - } - /// Computes the fused multiply-add of x, y and z (Float32). - constexpr const inline Float32 fma(Float32 x, Float32 y, Float32 z) { - return __l2math_fmaf(x, y, z); - } - /// Returns the maximum of the two arguments, signaling NaNs if either argument is a signaling NaN. - constexpr const inline Float64 max(Float64 x, Float64 y) { - return __l2math_fmax(x, y); - } - /// Returns the maximum of the two arguments, signaling NaNs if either argument is a signaling NaN (Float32). - constexpr const inline Float32 max(Float32 x, Float32 y) { - return __l2math_fmaxf(x, y); - } - /// Returns the minimum of the two arguments, signaling NaNs if either argument is a signaling NaN. - constexpr const inline Float64 min(Float64 x, Float64 y) { - return __l2math_fmin(x, y); - } - /// Returns the minimum of the two arguments, signaling NaNs if either argument is a signaling NaN (Float32). - constexpr const inline Float32 min(Float32 x, Float32 y) { - return __l2math_fminf(x, y); - } - /// Computes the floating-point remainder of dividing x by y. - constexpr const inline Float64 mod(Float64 x, Float64 y) { - return __l2math_fmod(x, y); - } - /// Computes the floating-point remainder of dividing x by y (Float32). - constexpr const inline Float32 mod(Float32 x, Float32 y) { - return __l2math_fmodf(x, y); - } - /// Breaks the number into a normalized fraction and a base-2 exponent - constexpr const inline Tuple frexp(Float64 x) { - __l2math_Tuple_Float64_Int res = __l2math_frexp(x); - return Tuple(res.f, res.i); - } - /// Breaks the number into a normalized fraction and a base-2 exponent (Float32) - constexpr const inline Tuple frexp(Float32 x) { - __l2math_Tuple_Float32_Int res = __l2math_frexpf(x); - return Tuple(res.f, res.i); - } - /// Calculate the length of the hypotenuse of a right-angle triangle given legs of length x and y. - constexpr const inline Float64 hypot(Float64 x, Float64 y) { - return __l2math_hypot(x, y); - } - /// Calculate the length of the hypotenuse of a right-angle triangle given legs of length x and y (Float32). - constexpr const inline Float32 hypot(Float32 x, Float32 y) { - return __l2math_hypotf(x, y); - } - /// Get exponent of floating point value - constexpr const inline Int ilogb(Float64 x) { - return __l2math_ilogb(x); - } - /// Get exponent of floating point value (Float32) - constexpr const inline Int ilogb(Float32 x) { - return __l2math_ilogbf(x); - } - /// Bessel function of the first kind of order zero - constexpr const inline Float64 j0(Float64 x) { - return __l2math_j0(x); - } - /// Bessel function of the first kind of order zero (Float32) - constexpr const inline Float32 j0(Float32 x) { - return __l2math_j0f(x); - } - /// Bessel function of the first kind of order one - constexpr const inline Float64 j1(Float64 x) { - return __l2math_j1(x); - } - /// Bessel function of the first kind of order one (Float32) - constexpr const inline Float32 j1(Float32 x) { - return __l2math_j1f(x); - } - /// Bessel function of the first kind of order n - constexpr const inline Float64 jn(Int n, Float64 x) { - return __l2math_jn(n, x); - } - /// Bessel function of the first kind of order n (Float32) - constexpr const inline Float32 jn(Int n, Float32 x) { - return __l2math_jnf(n, x); - } - /// Returns x * 2^n. - constexpr const inline Float64 ldexp(Float64 x, Int n) { - return __l2math_ldexp(x, n); - } - /// Returns x * 2^n (Float32). - constexpr const inline Float32 ldexp(Float32 x, Int n) { - return __l2math_ldexpf(x, n); - } - /// Natural logarithm of gamma function - constexpr const inline Float64 lgamma(Float64 x) { - return __l2math_lgamma(x); - } - /// Natural logarithm of gamma function (Float32) - constexpr const inline Float32 lgamma(Float32 x) { - return __l2math_lgammaf(x); - } - /// Natural logarithm of gamma function - constexpr const inline Tuple lgamma_r(Float64 x) { - __l2math_Tuple_Float64_Int res = __l2math_lgamma_r(x); - return Tuple(res.f, res.i); - } - /// Natural logarithm of gamma function (Float32) - constexpr const inline Tuple lgamma_r(Float32 x) { - __l2math_Tuple_Float32_Int res = __l2math_lgammaf_r(x); - return Tuple(res.f, res.i); - } - /// Return the natural logarithm of x. - constexpr const inline Float64 ln(Float64 x) { - return __l2math_ln(x); - } - /// Return the natural logarithm of x (Float32). - constexpr const inline Float32 ln(Float32 x) { - return __l2math_lnf(x); - } - /// Return logarithm of x. - constexpr const inline Float64 log(Float64 x) { - return __l2math_log(x); - } - /// Return logarithm of x (Float32). - constexpr const inline Float32 log(Float32 x) { - return __l2math_logf(x); - } - /// Return logarithm of x to base 10. - constexpr const inline Float64 log10(Float64 x) { - return __l2math_log10(x); - } - /// Return logarithm of x to base 10 (Float32). - constexpr const inline Float32 log10(Float32 x) { - return __l2math_log10f(x); - } - /// Return logarithm of x to base 2. - constexpr const inline Float64 log2(Float64 x) { - return __l2math_log2(x); - } - /// Return logarithm of x to base 2 (Float32). - constexpr const inline Float32 log2(Float32 x) { - return __l2math_log2f(x); - } - /// Return the natural logarithm of one plus x. - constexpr const inline Float64 log1p(Float64 x) { - return __l2math_log1p(x); - } - /// Return the natural logarithm of one plus x (Float32). - constexpr const inline Float32 log1p(Float32 x) { - return __l2math_log1pf(x); - } - /// Breaks the given number into an integral and a fractional part. - constexpr const inline Tuple mod(Float64 x) { - __l2math_Tuple_Float64_Float64 res = __l2math_modf(x); - return Tuple(res.f1, res.f2); - } - /// Breaks the given number into an integral and a fractional part (Float32). - constexpr const inline Tuple mod(Float32 x) { - __l2math_Tuple_Float32_Float32 res = __l2math_modff(x); - return Tuple(res.f1, res.f2); - } - /// Returns the next representable floating-point value following x in the direction of y. - constexpr const inline Float64 nextafter(Float64 x, Float64 y) { - return __l2math_nextafter(x, y); - } - /// Returns the next representable floating-point value following x in the direction of y. (Float32) - constexpr const inline Float32 nextafter(Float32 x, Float32 y) { - return __l2math_nextafterf(x, y); - } - /// Returns x raised to the power y. - constexpr const inline Float64 pow(Float64 x, Float64 y) { - return __l2math_pow(x, y); - } - /// Returns x raised to the power y. (Float32) - constexpr const inline Float32 pow(Float32 x, Float32 y) { - return __l2math_powf(x, y); - } - /// Returns the remainder of x/y. - constexpr const inline Float64 remainder(Float64 x, Float64 y) { - return __l2math_remainder(x, y); - } - /// Returns the remainder of x/y. (Float32) - constexpr const inline Float32 remainder(Float32 x, Float32 y) { - return __l2math_remainderf(x, y); - } - /// Return the remainder and part of the quotient of x and y. - constexpr const inline Tuple remquo(Float64 x, Float64 y) { - __l2math_Tuple_Float64_Int res = __l2math_remquo(x, y); - return Tuple(res.f, res.i); - } - /// Return the remainder and part of the quotient of x and y. (Float32) - constexpr const inline Tuple remquo(Float32 x, Float32 y) { - __l2math_Tuple_Float32_Int res = __l2math_remquof(x, y); - return Tuple(res.f, res.i); - } - /// Round to nearest integer, rounding halfway cases away from zero. - constexpr const inline Float64 rint(Float64 x) { - return __l2math_rint(x); - } - /// Round to nearest integer, rounding halfway cases away from zero. (Float32) - constexpr const inline Float32 rint(Float32 x) { - return __l2math_rintf(x); - } - /// Rounds x to the nearest integer in the direction of the current rounding mode. - constexpr const inline Float64 round(Float64 x) { - return __l2math_round(x); - } - /// Rounds x to the nearest integer in the direction of the current rounding mode. (Float32) - constexpr const inline Float32 round(Float32 x) { - return __l2math_roundf(x); - } - /// Rounds x to a number of digits after the decimal point. - constexpr const inline Float64 round(Float64 x, Float64 to) { - return round(x / to) * to; - } - /// Rounds x to a number of digits after the decimal point. (Float32) - constexpr const inline Float32 round(Float32 x, Float32 to) { - return round(x / to) * to; - } - /// Returns x * 2^n - constexpr const inline Float64 scalbn(Float64 x, Int n) { - return __l2math_scalbn(x, n); - } - /// Returns x * 2^n (Float32) - constexpr const inline Float32 scalbn(Float32 x, Int n) { - return __l2math_scalbnf(x, n); - } - /// Returns the sine function of x. - constexpr const inline Float64 sin(Radian64 x) { - return __l2math_sin(x); - } - /// Simultaneously computes the sine and cosine of the argument x. - constexpr const inline Tuple sincos(Radian64 x) { - __l2math_Tuple_Float64_Float64 res = __l2math_sincos(x); - return Tuple(res.f1, res.f2); - } - /// Simultaneously computes the sine and cosine of the argument x. (Float32) - constexpr const inline Tuple sincos(Radian32 x) { - __l2math_Tuple_Float32_Float32 res = __l2math_sincosf(x); - return Tuple(res.f1, res.f2); - } - /// Returns the sine of the argument x. - constexpr const inline Float32 sin(Radian32 x) { - return __l2math_sinf(x); - } - /// Returns the hyperbolic sine of x. - constexpr const inline Float64 sinh(Float64 x) { - return __l2math_sinh(x); - } - /// Returns the hyperbolic sine of x. (Float32) - constexpr const inline Float32 sinh(Float32 x) { - return __l2math_sinhf(x); - } - /// Returns the square root of x. - constexpr const inline Float64 sqrt(Float64 x) { - return __l2math_sqrt(x); - } - /// Returns the square root of x. (Float32) - constexpr const inline Float32 sqrt(Float32 x) { - return __l2math_sqrtf(x); - } - /// Returns tangent of x. - constexpr const inline Float64 tan(Radian64 x) { - return __l2math_tan(x); - } - /// Returns tangent of x. (Float32) - constexpr const inline Float32 tan(Radian32 x) { - return __l2math_tanf(x); - } - /// Returns the hyperbolic tangent of x. - constexpr const inline Float64 tanh(Float64 x) { - return __l2math_tanh(x); - } - /// Returns the hyperbolic tangent of x. (Float32) - constexpr const inline Float32 tanh(Float32 x) { - return __l2math_tanhf(x); - } - /// Returns the gamma function of x. - constexpr const inline Float64 tgamma(Float64 x) { - return __l2math_tgamma(x); - } - /// Returns the gamma function of x. (Float32) - constexpr const inline Float32 tgamma(Float32 x) { - return __l2math_tgammaf(x); - } - /// Returns the integer part of self. This means that non-integer numbers are always truncated towards zero. - constexpr const inline Float64 trunc(Float64 x) { - return __l2math_trunc(x); - } - /// Returns the integer part of self. This means that non-integer numbers are always truncated towards zero. (Float32) - constexpr const inline Float32 trunc(Float32 x) { - return __l2math_truncf(x); - } - /// Returns the value of the least significant bit of the given floating point number. - constexpr const inline Float64 ulp(Float64 x) { - return __l2math_ulp(x); - } - /// Bessel function of the second kind of order zero - constexpr const inline Float64 y0(Float64 x) { - return __l2math_y0(x); - } - /// Bessel function of the second kind of order zero (Float32) - constexpr const inline Float32 y0(Float32 x) { - return __l2math_y0f(x); - } - /// Bessel function of the second kind of order one - constexpr const inline Float64 y1(Float64 x) { - return __l2math_y1(x); - } - /// Bessel function of the second kind of order one (Float32) - constexpr const inline Float32 y1(Float32 x) { - return __l2math_y1f(x); - } - /// Bessel function of the second kind of order n - constexpr const inline Float64 yn(Int n, Float64 x) { - return __l2math_yn(n, x); - } - /// Bessel function of the second kind of order n (Float32) - constexpr const inline Float32 yn(Int n, Float32 x) { - return __l2math_ynf(n, x); - } -} -#endif // __cplusplus - -#endif // __L2MATH_BINDINGS_H diff --git a/libs/l2math/bindings/l2math_test.cpp b/libs/l2math/bindings/l2math_test.cpp deleted file mode 100644 index 3a138a8..0000000 --- a/libs/l2math/bindings/l2math_test.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "l2math.h" -#include "EZtest" - -#include - -using namespace l2math; - -constexpr const Float64 THIRTY_DEGREES = 0.5235987756; -constexpr const Float64 SIXTY_DEGREES = 1.0471975512; - -TEST(main_test) { - Float64 thirty = DEG2RAD(30.0); - Float64 sixty = DEG2RAD(60.0); - - ASSERT_EQ( - round(thirty, 10), - round(THIRTY_DEGREES, 10) - ); - ASSERT_EQ( - round(sixty, 10), - round(SIXTY_DEGREES, 10) - ); - - Float64 one_half_1 = l2math::sin(thirty); - Float64 one_half_2 = l2math::cos(sixty); - one_half_1 = round(one_half_1, 10); - one_half_2 = round(one_half_2, 10); - - ASSERT_EQ(one_half_1, one_half_2); - OK -} - -int main(int argc, char** argv) { - return RUN_TESTS; -} diff --git a/libs/l2math/bindings/lib.rs b/libs/l2math/bindings/lib.rs deleted file mode 100644 index 1424675..0000000 --- a/libs/l2math/bindings/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! For Documentation please refer [L2Math](../l2math) - -#![cfg_attr(feature = "no_std", no_std)] - -#[doc(hidden)] -pub use l2math::*; - -#[no_mangle] -#[panic_handler] -#[rustfmt::skip] -#[cfg(feature = "no_std")] -pub extern "C" fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/libs/l2math/bindings/tests.py b/libs/l2math/bindings/tests.py deleted file mode 100644 index 43cea41..0000000 --- a/libs/l2math/bindings/tests.py +++ /dev/null @@ -1,104 +0,0 @@ -from libs.l2math.bindings.bindings import build_l2math_bindings - -def get_current_target_triplet() -> str | None: - target_triplet = "" - import subprocess - res = subprocess.run(["rustc", "-vV"], capture_output = True) - if res.returncode != 0: return - for line in res.stdout.decode().split("\n"): - if line.startswith("host:"): - target_triplet = line.split(" ")[1] - break - return target_triplet - -def test_with_clang(cd: str, args: list[str]) -> str | int | None: - import subprocess, os - - target_triplet = get_current_target_triplet() - if target_triplet is None: - return "Failed to get target triplet" - - # Build bindings for current target triplet just in case - res = build_l2math_bindings(cd, []) - if res != None: return res - - bin_name = "l2mathtestbin" - if "windows" in target_triplet: - bin_name += ".exe" - - BIN_PATH = f"{cd}/libs/l2math/bindings/{bin_name}" - LIBS_PATH = f"{cd}/libs/l2math/bindings/.build/" - - cmd = [ - "clang++", # Compiler - "-I", f"{cd}/libs/eztest/", # Include eztest headers - "-Wall", # Enable all warnings - "-std=c++14", # Use c++14 - "-L", LIBS_PATH, # Include build directory during linking - f"-ll2math-{target_triplet}", # Link to l2math-{target_triplet} - "-o", BIN_PATH, # Output binary - f"{cd}/libs/l2math/bindings/l2math_test.cpp", # Include test source - f"{cd}/libs/eztest/eztest.cpp", # Include eztest source - ] - - #print("cmd:", " ".join(cmd)) - - print("Compiling test binary") - - res = subprocess.run(cmd, cwd = cd) - if res.returncode != 0: - if res.returncode == 1: - print("Compilation failed") - print(res.stderr.decode()) - else: - print("Compilation failed with error code", res.returncode) - return res.returncode - - print("Running test binary") - - res = os.system(BIN_PATH) - if res != 0: return res - - os.remove(BIN_PATH) - - print("Done!") - -def test_with_gcc(cd: str, args: list[str]) -> str | int | None: - return "GCC is not supported yet" - -def test_with_msvc(cd: str, args: list[str]) -> str | int | None: - return "MSVC is not supported yet" - -def bindings_test(cd: str, args: list[str]) -> str | int | None: - import subprocess - - print("Identifying c++ compiler") - # Identify the c++ compiler - res = subprocess.run( - ["clang++", "--version"], - capture_output = True - ) - - if res.returncode == 0: - print("Found clang++") - return test_with_clang(cd, args) - - res = subprocess.run( - ["g++", "--version"], - capture_output = True - ) - - if res.returncode == 0: - print("Found g++") - return test_with_gcc(cd, args) - - res = subprocess.run( - ["cl", "/?"], - capture_output = True - ) - - if res.returncode == 0: - print("Found cl") - return test_with_msvc(cd, args) - - return "No supported c++ compiler found" diff --git a/libs/libodo/Geometry.kt b/libs/libodo/Geometry.kt deleted file mode 100644 index a137c69..0000000 --- a/libs/libodo/Geometry.kt +++ /dev/null @@ -1,297 +0,0 @@ -/* -MIT License - -Copyright (c) 2018 ACME Robotics - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -@file:JvmName("Geometry") - -package com.acmerobotics.roadrunner - -import kotlin.math.atan2 -import kotlin.math.cos -import kotlin.math.sin -import kotlin.math.sqrt -import kotlin.math.tan - -/** - * @usesMathJax - * - * Vector \((x, y)\) - */ -data class Vector2d(@JvmField val x: Double, @JvmField val y: Double) { - operator fun plus(v: Vector2d) = Vector2d(x + v.x, y + v.y) - operator fun minus(v: Vector2d) = Vector2d(x - v.x, y - v.y) - operator fun unaryMinus() = Vector2d(-x, -y) - - operator fun times(z: Double) = Vector2d(x * z, y * z) - operator fun div(z: Double) = Vector2d(x / z, y / z) - - infix fun dot(v: Vector2d) = x * v.x + y * v.y - fun sqrNorm() = this dot this - fun norm() = sqrt(sqrNorm()) - - // precondition: this is normalized - fun angleCast() = Rotation2d(x, y) -} - -/** - * Dual version of [Vector2d]. - */ -data class Vector2dDual(@JvmField val x: DualNum, @JvmField val y: DualNum) { - companion object { - @JvmStatic - fun constant(v: Vector2d, n: Int) = - Vector2dDual(DualNum.constant(v.x, n), DualNum.constant(v.y, n)) - } - - operator fun plus(v: Vector2d) = Vector2dDual(x + v.x, y + v.y) - operator fun plus(v: Vector2dDual) = Vector2dDual(x + v.x, y + v.y) - operator fun minus(v: Vector2dDual) = Vector2dDual(x - v.x, y - v.y) - operator fun unaryMinus() = Vector2dDual(-x, -y) - - operator fun div(z: Double) = Vector2dDual(x / z, y / z) - - infix fun dot(v: Vector2dDual) = x * v.x + y * v.y - fun sqrNorm() = this dot this - fun norm() = sqrNorm().sqrt() - - fun bind() = Vector2dDual(x, y) - - fun reparam(oldParam: DualNum) = - Vector2dDual(x.reparam(oldParam), y.reparam(oldParam)) - - fun drop(n: Int) = Vector2dDual(x.drop(n), y.drop(n)) - fun value() = Vector2d(x.value(), y.value()) - - // precondition: this is normalized - fun angleCast() = Rotation2dDual(x, y) -} - -/** - * @usesMathJax - * - * Rotation \(\theta\) represented by the unit circle point \((\cos \theta, \sin \theta)\) or unit-modulus complex - * number \(\cos \theta + i \sin \theta\). - * - * Advanced: Rotations in two dimensions comprise a Lie group referred to as SO(2). The terminology [exp] and [log] - * comes from the Lie theory, and [this paper](https://arxiv.org/abs/1812.01537) gives a targeted exposition of the key - * fundamentals. - */ -data class Rotation2d(@JvmField val real: Double, @JvmField val imag: Double) { - companion object { - /** - * Turns an unnormalized angle into a rotation. - */ - @JvmStatic - fun exp(theta: Double) = Rotation2d(cos(theta), sin(theta)) - } - - operator fun plus(x: Double) = this * exp(x) - operator fun minus(r: Rotation2d) = (r.inverse() * this).log() - - operator fun times(v: Vector2d) = Vector2d(real * v.x - imag * v.y, imag * v.x + real * v.y) - operator fun times(pv: PoseVelocity2d) = PoseVelocity2d(this * pv.linearVel, pv.angVel) - operator fun times(r: Rotation2d) = - Rotation2d(real * r.real - imag * r.imag, real * r.imag + imag * r.real) - - fun vec() = Vector2d(real, imag) - - fun inverse() = Rotation2d(real, -imag) - - /** - * Get the rotation as a normalized [Double]. - */ - fun log() = atan2(imag, real) -} - -/** - * Dual version of [Rotation2d]. - */ -data class Rotation2dDual(@JvmField val real: DualNum, @JvmField val imag: DualNum) { - init { - require(real.size() == imag.size()) - require(real.size() <= 3) - } - - companion object { - @JvmStatic - fun exp(theta: DualNum) = Rotation2dDual(theta.cos(), theta.sin()) - - @JvmStatic - fun constant(r: Rotation2d, n: Int) = - Rotation2dDual(DualNum.constant(r.real, n), DualNum.constant(r.imag, n)) - } - - fun size() = real.size() - - operator fun plus(x: Double) = this * Rotation2d.exp(x) - operator fun plus(d: DualNum) = this * exp(d) - - operator fun times(pv: PoseVelocity2dDual) = PoseVelocity2dDual(this * pv.linearVel, pv.angVel) - operator fun times(v: Vector2dDual) = Vector2dDual(real * v.x - imag * v.y, imag * v.x + real * v.y) - operator fun times(v: Vector2d) = Vector2dDual(real * v.x - imag * v.y, imag * v.x + real * v.y) - operator fun times(r: Rotation2dDual) = - Rotation2dDual(real * r.real - imag * r.imag, real * r.imag + imag * r.real) - operator fun times(r: Rotation2d) = - Rotation2dDual(real * r.real - imag * r.imag, real * r.imag + imag * r.real) - operator fun times(p: Pose2d) = Pose2dDual(this * p.position, this * p.heading) - - fun inverse() = Rotation2dDual(real, -imag) - - fun reparam(oldParam: DualNum) = - Rotation2dDual(real.reparam(oldParam), imag.reparam(oldParam)) - - // derivative of atan2 under unit norm assumption - fun velocity() = real * imag.drop(1) - imag * real.drop(1) - fun value() = Rotation2d(real.value(), imag.value()) -} - -/** - * @usesMathJax - * - * 2D rigid transform comprised of [heading] followed by [position]. - * - * The pose `destPoseSource` denotes the transform from frame `Source` into frame `Dest`. It can be applied with - * `times()` to change the coordinates of `xSource` into `xDest` where `x` is a vector, twist, or even another pose: - * `xDest = destPoseSource * xSource`. The awkward names take some getting used to, but they avoid many routine errors. - * - * Transforms into the world frame are common enough to warrant a shorthand. The pose `worldPoseSource` can be shortened - * to `poseSource` for any frame `Source`. - * - * Advanced: Transforms in two dimensions comprise a Lie group referred to as SE(2). The terminology [exp] and [log] - * comes from the Lie theory, and [this paper](https://arxiv.org/abs/1812.01537) gives a targeted exposition of the key - * fundamentals. - */ -data class Pose2d( - @JvmField - val position: Vector2d, - @JvmField - val heading: Rotation2d, -) { - constructor(position: Vector2d, heading: Double) : this(position, Rotation2d.exp(heading)) - constructor(positionX: Double, positionY: Double, heading: Double) : this(Vector2d(positionX, positionY), heading) - - companion object { - @JvmStatic - fun exp(t: Twist2d): Pose2d { - val heading = Rotation2d.exp(t.angle) - - val u = t.angle + snz(t.angle) - val c = 1 - cos(u) - val s = sin(u) - val translation = Vector2d( - (s * t.line.x - c * t.line.y) / u, - (c * t.line.x + s * t.line.y) / u - ) - - return Pose2d(translation, heading) - } - } - - operator fun plus(t: Twist2d) = this * exp(t) - fun minusExp(t: Pose2d) = t.inverse() * this - operator fun minus(t: Pose2d) = minusExp(t).log() - - operator fun times(p: Pose2d) = Pose2d(heading * p.position + position, heading * p.heading) - operator fun times(v: Vector2d) = heading * v + position - operator fun times(pv: PoseVelocity2d) = PoseVelocity2d(heading * pv.linearVel, pv.angVel) - - fun inverse() = Pose2d(heading.inverse() * -position, heading.inverse()) - - fun log(): Twist2d { - val theta = heading.log() - - val halfu = 0.5 * theta + snz(theta) - val v = halfu / tan(halfu) - return Twist2d( - Vector2d( - v * position.x + halfu * position.y, - -halfu * position.x + v * position.y, - ), - theta, - ) - } -} - -/** - * Dual version of [Pose2d]. - */ -data class Pose2dDual( - @JvmField - val position: Vector2dDual, - @JvmField - val heading: Rotation2dDual, -) { - companion object { - @JvmStatic - fun constant(p: Pose2d, n: Int) = - Pose2dDual(Vector2dDual.constant(p.position, n), Rotation2dDual.constant(p.heading, n)) - } - - operator fun plus(t: Twist2d) = this * Pose2d.exp(t) - - operator fun times(p: Pose2d) = Pose2dDual(heading * p.position + position, heading * p.heading) - operator fun times(p: Pose2dDual) = Pose2dDual(heading * p.position + position, heading * p.heading) - operator fun times(pv: PoseVelocity2dDual) = PoseVelocity2dDual(heading * pv.linearVel, pv.angVel) - - fun inverse() = heading.inverse().let { - Pose2dDual(it * -position, it) - } - - fun reparam(oldParam: DualNum) = - Pose2dDual(position.reparam(oldParam), heading.reparam(oldParam)) - - fun value() = Pose2d(position.value(), heading.value()) - fun velocity() = PoseVelocity2dDual(position.drop(1), heading.velocity()) -} - -data class PoseVelocity2d(@JvmField val linearVel: Vector2d, @JvmField val angVel: Double) { - operator fun minus(pv: PoseVelocity2d) = PoseVelocity2d(linearVel - pv.linearVel, angVel - pv.angVel) -} - -/** - * Dual version of [PoseVelocity2d]. - */ -data class PoseVelocity2dDual( - @JvmField val linearVel: Vector2dDual, - @JvmField val angVel: DualNum -) { - companion object { - @JvmStatic - fun constant(pv: PoseVelocity2d, n: Int) = - PoseVelocity2dDual(Vector2dDual.constant(pv.linearVel, n), DualNum.constant(pv.angVel, n)) - } - - operator fun plus(other: PoseVelocity2d) = PoseVelocity2dDual(linearVel + other.linearVel, angVel + other.angVel) - - fun value() = PoseVelocity2d(linearVel.value(), angVel.value()) -} - -data class Twist2d(@JvmField val line: Vector2d, @JvmField val angle: Double) - -data class Twist2dDual( - @JvmField val line: Vector2dDual, - @JvmField val angle: DualNum -) { - fun value() = Twist2d(line.value(), angle.value()) - fun velocity() = PoseVelocity2dDual(line.drop(1), angle.drop(1)) -} diff --git a/libs/libodo/dualnum.rs b/libs/libodo/dualnum.rs deleted file mode 100644 index 4345907..0000000 --- a/libs/libodo/dualnum.rs +++ /dev/null @@ -1,475 +0,0 @@ -use core::marker::PhantomData; -use libtrig::prelude::*; -use libtrig::*; - -type Array = alloc::vec::Vec; - -/// [Dual number](https://en.wikipedia.org/wiki/Dual_number) -/// to implement forward autodifferentiation. -#[derive(Debug, Clone, PartialEq, PartialOrd, Default)] -pub struct DualNum(Array, PhantomData); - -impl DualNum { - #[inline(always)] - #[must_use = "this returns the dual number (new)"] - pub(crate) const fn constructor(array: Array) -> Self { - Self(array, PhantomData) - } - - /// Makes dual number (c, 0, ..., 0) with size [n] representing a constant function (c). - pub fn constant(c: Float64, n: usize) -> Self { - let mut array = Array::with_capacity(n); - for i in 0..n { - array.push(if i == 0 { c } else { 0.0 }); - } - debug_assert!(array.len() <= 4); - Self::constructor(array) - } - - /// Makes dual number (x0, 1, 0, ..., 0) with size [n] representing a variable function (x) at (x = x0). - pub fn variable(x0: Float64, n: usize) -> Self { - let mut array = Array::with_capacity(n); - for i in 0..n { - array.push(if i == 0 { - x0 - } else if i == 1 { - 1.0 - } else { - 0.0 - }); - } - debug_assert!(array.len() <= 4); - Self::constructor(array) - } - - /// Constructs a dual number (x, d[0], d[1], ..., d[n-1]) with size [n] representing a constant function (x). - pub fn cons(x: Float64, d: Self) -> Self { - let mut array = Array::with_capacity(d.size() + 1); - for i in 0..array.capacity() { - array.push(if i == 0 { x } else { d.values()[i - 1] }); - } - debug_assert!(array.len() <= 4); - Self::constructor(array) - } - - /// Returns the size of the dual number. - #[inline(always)] - pub fn size(&self) -> usize { - self.0.len() as usize - } - - /// Returns the values of the dual number. - #[inline(always)] - pub fn values(&self) -> &[Float64] { - &self.0 - } - - /// Returns the value of the dual number. - #[inline(always)] - #[must_use = "this returns the first component of the dual number"] - pub fn value(&self) -> Float64 { - self.0[0] - } - - /// Drops the first [n] components of the dual number. - /// - /// # Panics - /// - /// Panics if [n] is greater than the size of the dual number. - #[must_use = "this returns a new dual number"] - pub fn drop(&self, n: usize) -> Self { - let mut array = Array::with_capacity(self.size() - n); - for i in 0..array.capacity() { - array[i] = self.0[i + n]; - } - debug_assert!(array.len() <= 4); - Self::constructor(array) - } - - /// Calculates the reciprocal of the dual number. - #[must_use = "this returns the reciprocal of the dual number (new)"] - pub fn recip(&self) -> Self { - let mut array = Array::with_capacity(self.size()); - if array.capacity() == 0 { - return Self::constructor(array); - } - - let recip = 1.0 / self.0[0]; - array[0] = recip; - if array.capacity() == 1 { - return Self::constructor(array); - } - - let neg_recip = -recip; - let neg_recip2 = recip * neg_recip; - let deriv = neg_recip2 * self.0[1]; - array[1] = deriv; - if array.capacity() == 2 { - return Self::constructor(array); - } - - let int1 = 2.0 * neg_recip * deriv; - let deriv2 = int1 * self.0[1] + neg_recip2 * self.0[2]; - array[2] = deriv2; - if array.capacity() == 3 { - return Self::constructor(array); - } - - let int2 = int1 * self.0[2]; - array[3] = - int2 + neg_recip2 * self.0[3] + - int2 - 2.0 * (deriv * deriv + recip * deriv2) * self.0[1]; - Self::constructor(array) - } - - /// Reparameterizes (x, dx/du, d^2x/du^2, ..., d^(n - 1) x/du^(n - 1)) into - /// (x, dx/dt, d^2x/dt^2, ..., d^(n - 1) x/dt^(n - 1)) using [old_param] and - /// the chain rule. - pub fn reparam(&self, old_param: DualNum) -> DualNum { - let mut array = Array::with_capacity(self.size().min(old_param.size())); - if array.capacity() == 0 { - return DualNum::::constructor(array); - } - - array[0] = self[0]; - if array.capacity() == 1 { - return DualNum::::constructor(array); - } - - array[1] = self[1] * old_param[1]; - if array.capacity() == 2 { - return DualNum::::constructor(array); - } - - let old_deriv2 = old_param[1] * old_param[1]; - array[2] = old_deriv2 * self[2] + old_param[2] * self[1]; - if array.capacity() == 3 { - return DualNum::::constructor(array); - } - - array[3] = self[1] * old_param[3] + - (3.0 * self[2] * old_param[2] + self[3] * old_deriv2) * old_param[1]; - DualNum::::constructor(array) - } -} - -impl Sqrt for DualNum { - /// Calculates the square root of the dual number. - #[must_use = "this returns the square root of the dual number (new)"] - fn sqrt(&self) -> Self { - let mut array = Array::with_capacity(self.size()); - if array.capacity() == 0 { - return Self::constructor(array); - } - - let sqrt = l2math::sqrt(self.0[0]); - array[0] = sqrt; - if array.capacity() == 1 { - return Self::constructor(array); - } - - let recip = 1.0 / (2.0 * sqrt); - let deriv = recip * self.0[1]; - array[1] = deriv; - if array.capacity() == 2 { - return Self::constructor(array); - } - - let neg_recip = -2.0 * recip; - let neg_recip2 = recip * neg_recip; - let int1 = neg_recip2 * deriv; - let second_deriv = int1 * self.0[1] + recip * self.0[2]; - array[2] = second_deriv; - if array.capacity() == 3 { - return Self::constructor(array); - } - - let int2 = 2.0 * int1; - array[3] = recip * self.0[3] + int2 * self.0[2] + - (deriv * neg_recip * int2 + neg_recip2 * second_deriv) * self.0[1]; - Self::constructor(array) - } -} - -impl Sin for DualNum { - /// Calculates the sine of the dual number. - #[must_use = "this returns the sine of the dual number (new)"] - fn sin(&self) -> Self { - let mut array = Array::with_capacity(self.size()); - if array.capacity() == 0 { - return Self::constructor(array); - } - - let sin = l2math::sin(self.0[0]); - array[0] = sin; - if array.capacity() == 1 { - return Self::constructor(array); - } - - let cos = l2math::cos(self.0[0]); - let deriv = cos * self.0[1]; - array[1] = deriv; - if array.capacity() == 2 { - return Self::constructor(array); - } - - let deriv2 = self.0[1] * self.0[1]; - array[2] = cos * self.0[2] - sin * deriv2; - if array.capacity() == 3 { - return Self::constructor(array); - } - - array[3] = cos * self.0[3] - - 3.0 * sin * self.0[1] * self.0[2] - - deriv * deriv2; - Self::constructor(array) - } -} - -impl Cos for DualNum { - /// Calculates the cosine of the dual number. - #[must_use = "this returns the cosine of the dual number (new)"] - fn cos(&self) -> Self { - let mut array = Array::with_capacity(self.size()); - if array.capacity() == 0 { - return Self::constructor(array); - } - - let cos = l2math::cos(self.0[0]); - array[0] = cos; - if array.capacity() == 1 { - return Self::constructor(array); - } - - let sin = l2math::sin(self.0[0]); - let neg_in_eriv = -self.0[1]; - let deriv = sin * neg_in_eriv; - array[1] = deriv; - if array.capacity() == 2 { - return Self::constructor(array); - } - - let int = cos * neg_in_eriv; - array[2] = int * self.0[1] - sin * self.0[2]; - if array.capacity() == 3 { - return Self::constructor(array); - } - - array[3] = deriv * neg_in_eriv * self.0[1] + - 3.0 * int * self.0[2] - - sin * self.0[3]; - Self::constructor(array) - } -} - -impl core::ops::Add for DualNum { - type Output = Self; - #[must_use = "this returns the sum of the dual numbers (new)"] - fn add(self, rhs: Self) -> Self::Output { - let mut array = Array::with_capacity(self.size().min(rhs.size())); - for i in 0..array.capacity() { - array[i] = self.0[i] + rhs.0[i]; - } - debug_assert!(array.len() <= 4); - Self::constructor(array) - } -} - -impl core::ops::Add for DualNum { - type Output = Self; - #[must_use = "this returns the sum of the dual numbers (new)"] - fn add(self, rhs: Float64) -> Self::Output { - let mut array = Array::with_capacity(self.size()); - for i in 0..array.capacity() { - array[i] = self.0[i] + rhs; - } - debug_assert!(array.len() <= 4); - Self::constructor(array) - } -} - -impl core::ops::AddAssign for DualNum { - fn add_assign(&mut self, rhs: Self) { - for i in 0..self.size().min(rhs.size()) { - self.0[i] += rhs.0[i]; - } - } -} - -impl core::ops::Sub for DualNum { - type Output = Self; - #[must_use = "this returns the difference of the dual numbers (new)"] - fn sub(self, rhs: Self) -> Self::Output { - let mut array = Array::with_capacity(self.size().min(rhs.size())); - for i in 0..array.capacity() { - array[i] = self.0[i] - rhs.0[i]; - } - debug_assert!(array.len() <= 4); - Self::constructor(array) - } -} - -impl core::ops::Sub for DualNum { - type Output = Self; - #[must_use = "this returns the difference of the dual numbers (new)"] - fn sub(self, rhs: Float64) -> Self::Output { - let mut array = Array::with_capacity(self.size()); - for i in 0..array.capacity() { - array[i] = self.0[i] - rhs; - } - debug_assert!(array.len() <= 4); - Self::constructor(array) - } -} - -impl core::ops::SubAssign for DualNum { - fn sub_assign(&mut self, rhs: Self) { - for i in 0..self.size().min(rhs.size()) { - self.0[i] -= rhs.0[i]; - } - } -} - -impl core::ops::Mul for DualNum { - type Output = Self; - #[rustfmt::skip] - #[must_use = "this returns the product of the dual numbers (new)"] - fn mul(self, rhs: Self) -> Self::Output { - let mut array = Array::with_capacity(self.size().min(rhs.size())); - if array.capacity() == 0 { - return Self::constructor(array); - } - - array[0] = self[0] * rhs[0]; - if array.capacity() == 1 { - return Self::constructor(array); - } - - array[1] = self[0] * rhs[1] + self[1] * rhs[0]; - if array.capacity() == 2 { - return Self::constructor(array); - } - - array[2] = self[0] * rhs[2] + self[2] * rhs[0] + 2.0 * self[1] * rhs[1]; - if array.capacity() == 3 { - return Self::constructor(array); - } - - array[3] = self[0] * rhs[3] + self[3] * rhs[0] + - 3.0 * (self[2] * rhs[1] + self[1] * rhs[2]); - - return Self::constructor(array); - } -} - -impl core::ops::Mul for DualNum { - type Output = Self; - #[must_use = "this returns the product of the dual numbers (new)"] - fn mul(self, rhs: Float64) -> Self::Output { - let mut array = Array::with_capacity(self.size()); - for i in 0..array.capacity() { - array[i] = self.0[i] * rhs; - } - debug_assert!(array.len() <= 4); - Self::constructor(array) - } -} - -impl core::ops::Neg for DualNum { - type Output = Self; - - #[must_use = "this returns the negation of the dual number (new)"] - fn neg(self) -> Self::Output { - let mut array = Array::with_capacity(self.size()); - for i in 0..array.capacity() { - array[i] = -self.0[i]; - } - debug_assert!(array.len() <= 4); - Self::constructor(array) - } -} - -impl core::ops::Div for DualNum { - type Output = Self; - #[inline] - #[must_use = "this returns the quotient of the dual numbers (new)"] - fn div(self, rhs: Self) -> Self::Output { - self * rhs.recip() - } -} - -impl core::ops::Div for DualNum { - type Output = Self; - #[inline] - #[must_use = "this returns the quotient of the dual numbers (new)"] - fn div(self, rhs: Float64) -> Self::Output { - let mut array = Array::with_capacity(self.size()); - for i in 0..array.capacity() { - array[i] = self.0[i] / rhs; - } - debug_assert!(array.len() <= 4); - Self::constructor(array) - } -} - -impl core::ops::Index for DualNum { - type Output = Float64; - #[inline(always)] - #[must_use = "this returns the first component of the dual number"] - fn index(&self, i: usize) -> &Self::Output { - &self.0[i] - } -} - -impl core::ops::Index for &DualNum { - type Output = Float64; - #[inline(always)] - #[must_use = "this returns the first component of the dual number"] - fn index(&self, i: usize) -> &Self::Output { - &self.0[i] - } -} - -impl core::ops::Index for &mut DualNum { - type Output = Float64; - #[inline(always)] - #[must_use = "this returns the first component of the dual number"] - fn index(&self, i: usize) -> &Self::Output { - &self.0[i] - } -} - -impl core::ops::IndexMut for DualNum { - #[inline(always)] - #[must_use = "this returns the first component of the dual number"] - fn index_mut(&mut self, i: usize) -> &mut Self::Output { - &mut self.0[i] - } -} - -impl core::ops::IndexMut for &mut DualNum { - #[inline(always)] - #[must_use = "this returns the first component of the dual number"] - fn index_mut(&mut self, i: usize) -> &mut Self::Output { - &mut self.0[i] - } -} - -impl core::ops::Mul for DualNum { - type Output = crate::Vec2DDual; - #[inline] - fn mul(self, rhs: Vec2D) -> Self::Output { - let size = self.size(); - let mut x_array = Array::with_capacity(size); - let mut y_array = Array::with_capacity(size); - for i in 0..size { - x_array[i] = self.0[i] * rhs.x(); - y_array[i] = self.0[i] * rhs.y(); - } - debug_assert!(x_array.len() <= 4); - debug_assert!(y_array.len() <= 4); - let x = Self::constructor(x_array); - let y = Self::constructor(y_array); - crate::Vec2DDual::new(x, y) - } -} diff --git a/libs/libodo/lib.rs b/libs/libodo/lib.rs deleted file mode 100644 index 09af16d..0000000 --- a/libs/libodo/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![no_std] -#![feature(core_intrinsics)] -#![warn(missing_docs, unused, clippy::all)] -#![doc = include_str!("./README.md")] - -extern crate alloc; - -mod dualnum; -// mod rotation2d; -mod vec2ddual; - -pub use dualnum::DualNum; -// pub use rotation2d::Rotation2D; -pub use vec2ddual::Vec2DDual; diff --git a/libs/libodo/rotation2d.rs b/libs/libodo/rotation2d.rs deleted file mode 100644 index 23c607a..0000000 --- a/libs/libodo/rotation2d.rs +++ /dev/null @@ -1,69 +0,0 @@ -use l2math::{Float64, Radian64}; - -pub struct Rotation2D { - pub real: Float64, - pub imag: Float64, -} - -impl Rotation2D { - pub const fn new(real: Float64, imag: Float64) -> Self { - Self { real, imag } - } - pub fn log(self) -> Float64 { - l2math::atan2(self.imag, self.real) - } -} - -impl From for Rotation2D { - fn from(angle: libtrig::Angle2D) -> Self { - use libtrig::prelude::*; - Self::new(angle.cos(), angle.sin()) - } -} - -impl From for Rotation2D { - fn from(angle: Radian64) -> Self { - use libtrig::prelude::*; - Self::new(angle.cos(), angle.sin()) - } -} - -impl core::ops::Neg for Rotation2D { - type Output = Self; - fn neg(self) -> Self::Output { - Self::new(self.real, -self.imag) - } -} - -impl From for libtrig::Vec2D { - fn from(rot: Rotation2D) -> Self { - Self::new(rot.real, rot.imag) - } -} - -impl core::ops::Mul for Rotation2D { - type Output = Rotation2D; - fn mul(self, rhs: Rotation2D) -> Self::Output { - Self::new( - self.real * rhs.real - self.imag * rhs.imag, - self.real * rhs.imag + self.imag * rhs.real, - ) - } -} - -impl core::ops::Mul for Rotation2D { - type Output = libtrig::Vec2D; - fn mul(self, rhs: libtrig::Vec2D) -> Self::Output { - libtrig::Vec2D::new( - self.real * rhs.x() - self.imag * rhs.y(), - self.real * rhs.y() + self.imag * rhs.x(), - ) - } -} - -impl core::ops::Add for Rotation2D { - type Output = Self; - fn add(self, rhs: Float64) -> Self::Output { - self * Self::from(rhs) - } -} diff --git a/libs/libodo/vec2ddual.rs b/libs/libodo/vec2ddual.rs deleted file mode 100644 index 95e6712..0000000 --- a/libs/libodo/vec2ddual.rs +++ /dev/null @@ -1,84 +0,0 @@ -#[allow(unused_imports)] -use libtrig::prelude::*; -use libtrig::*; - -use crate::DualNum; - -/// Dual version of a 2D vector. -pub struct Vec2DDual { - /// The x component of the vector. - pub x: DualNum, - /// The y component of the vector. - pub y: DualNum, -} - -impl Vec2DDual { - /// Construct a new Vec2DDual. - #[inline] - #[must_use = "This function creates a new Vec2DDual"] - pub const fn new(x: DualNum, y: DualNum) -> Self { - Self { x, y } - } - /// Construct a new Vec2DDual from a Vec2D. - #[inline] - #[must_use = "This function creates a new Vec2DDual"] - pub fn constant(v: Vec2D, n: usize) -> Self { - Self::new(DualNum::constant(v.x(), n), DualNum::constant(v.y(), n)) - } -} - -impl core::ops::Add for Vec2DDual { - type Output = Self; - #[inline] - #[must_use = "This function creates a new Vec2DDual"] - fn add(self, rhs: Vec2D) -> Self::Output { - Self::new(self.x + rhs.x(), self.y + rhs.y()) - } -} - -impl core::ops::Add> for Vec2DDual { - type Output = Self; - #[inline] - #[must_use = "This function creates a new Vec2DDual"] - fn add(self, rhs: Vec2DDual) -> Self::Output { - Self::new(self.x + rhs.x, self.y + rhs.y) - } -} - -impl core::ops::Sub for Vec2DDual { - type Output = Self; - #[inline] - #[must_use = "This function creates a new Vec2DDual"] - fn sub(self, rhs: Vec2D) -> Self::Output { - Self::new(self.x - rhs.x(), self.y - rhs.y()) - } -} - -impl core::ops::Sub> for Vec2DDual { - type Output = Self; - #[inline] - #[must_use = "This function creates a new Vec2DDual"] - fn sub(self, rhs: Vec2DDual) -> Self::Output { - Self::new(self.x - rhs.x, self.y - rhs.y) - } -} - -impl core::ops::Neg for Vec2DDual { - type Output = Self; - #[inline] - #[must_use = "This function creates a new Vec2DDual"] - fn neg(self) -> Self::Output { - Self::new(-self.x, -self.y) - } -} - -impl core::ops::Div for Vec2DDual { - type Output = Self; - #[inline] - #[must_use = "This function creates a new Vec2DDual"] - fn div(self, rhs: Float64) -> Self::Output { - Self::new(self.x / rhs, self.y / rhs) - } -} - -// impl Dot for diff --git a/libs/libpath/Cargo.toml b/libs/libpath/Cargo.toml deleted file mode 100644 index b47a8ad..0000000 --- a/libs/libpath/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "libpath" -description = "Pathing" -repository.workspace = true -version.workspace = true -edition.workspace = true -authors.workspace = true -license.workspace = true - -[dependencies.libtrig] -path = "../libtrig" - -[dependencies.libodo] -path = "../libodo" - -[dependencies.l2math] -path = "../l2math" - -[lib] -path = "lib.rs" diff --git a/libs/libpath/control.rs b/libs/libpath/control.rs deleted file mode 100644 index d9f23c4..0000000 --- a/libs/libpath/control.rs +++ /dev/null @@ -1,110 +0,0 @@ -use l2math::Float64; -use libtrig::Vec2D; - -/// Kinematic motor feedforward -#[derive(Debug, Clone, Copy, PartialEq, Default)] -pub struct MotorFeedforward { - /// The static gain, or the voltage required to overcome static friction. - pub k_s: Float64, - /// The velocity gain, or the voltage required to maintain a given velocity. - pub k_v: Float64, - /// The acceleration gain, or the voltage required to produce a given acceleration. - pub k_a: Float64, -} - -impl Eq for MotorFeedforward {} - -impl MotorFeedforward { - /// Creates a new motor feedforward. - pub const fn new(k_s: Float64, k_v: Float64, k_a: Float64) -> Self { - Self { k_s, k_v, k_a } - } - /// Computes the (normalized) voltage: - /// ```text,no_run,ignore - /// |kₛ| · (v / |v|) + kᵥ · v + kₐ · a - /// ``` - pub fn compute(&self, vel: Float64, accel: Float64) -> Float64 { - use libtrig::prelude::*; - self.k_s.signof(vel) + self.k_v * vel + self.k_a * accel - } -} - -/// Proportional position-velocity controller for a holonomic robot. -#[derive(Debug, Clone, Copy, PartialEq, Default)] -pub struct HolonomicController { - axial_pos_gain: Float64, - lateral_pos_gain: Float64, - heading_gain: Float64, - axial_vel_gain: Float64, - lateral_vel_gain: Float64, - heading_vel_gain: Float64, -} - -impl Eq for HolonomicController {} - -impl HolonomicController { - pub const fn new( - axial_pos_gain: Float64, - lateral_pos_gain: Float64, - heading_gain: Float64, - ) -> Self { - Self { - axial_pos_gain, - lateral_pos_gain, - heading_gain, - axial_vel_gain: 0.0, - lateral_vel_gain: 0.0, - heading_vel_gain: 0.0, - } - } - /* - fun compute( - targetPose: Pose2dDual