Compare commits
17 commits
Author | SHA1 | Date | |
---|---|---|---|
9b43f84f5a | |||
69290b63ae | |||
cd64103705 | |||
f525de02aa | |||
51ce6bcc39 | |||
476726e162 | |||
9fc4671bec | |||
4ae6400711 | |||
3cdce36947 | |||
267ae3ecf6 | |||
ab046fe22e | |||
9d97a45a78 | |||
cafcff139f | |||
c9a9e83438 | |||
d750e3a70c | |||
947c7ab0bd | |||
e3335800d8 |
13 changed files with 536 additions and 19 deletions
|
@ -23,12 +23,13 @@ jobs:
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d "{
|
-d "{
|
||||||
\"name\": \"3d_collision_helpers version ${GITHUB_REF_NAME}\",
|
\"name\": \"3d_collision_helpers version ${GITHUB_REF_NAME}\",
|
||||||
\"tag_name\": \"${GITHUB_REF_NAME}\"
|
\"tag_name\": \"${GITHUB_REF_NAME}\",
|
||||||
|
\"body\": \" SHA256SUMS\"
|
||||||
}" >&/dev/null
|
}" >&/dev/null
|
||||||
|
|
||||||
assets-release-x86_64:
|
assets-release-x86_64:
|
||||||
needs: ensure-release-exists
|
needs: ensure-release-exists
|
||||||
runs-on: any_archLinux
|
runs-on: x86_64_archLinux
|
||||||
steps:
|
steps:
|
||||||
- name: Check and push assets
|
- name: Check and push assets
|
||||||
id: check_release_assets_x86_64
|
id: check_release_assets_x86_64
|
||||||
|
@ -63,6 +64,19 @@ jobs:
|
||||||
cd out_shared
|
cd out_shared
|
||||||
fakeroot tar --sort=name -cv usr | zstd --ultra -20 > "$THE_CURRENT_WORKING_DIRECTORY/$SHARED_LIB_ASSET_NAME"
|
fakeroot tar --sort=name -cv usr | zstd --ultra -20 > "$THE_CURRENT_WORKING_DIRECTORY/$SHARED_LIB_ASSET_NAME"
|
||||||
popd
|
popd
|
||||||
|
curl --fail-with-body -X GET \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < $THE_CURRENT_WORKING_DIRECTORY/release_info.json)" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-o current_release_info.json 2>/dev/null
|
||||||
|
curl --fail-with-body -X PATCH \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < $THE_CURRENT_WORKING_DIRECTORY/release_info.json)" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d "{
|
||||||
|
\"body\":\"$(jq .body < current_release_info.json | sed -e 's/^"//' -e 's/"$//')
|
||||||
|
$(find "$THE_CURRENT_WORKING_DIRECTORY" -maxdepth 1 -name "*$SHARED_LIB_ASSET_NAME" -execdir sha256sum '{}' ';' | sed -e 's|\./3d_collision|3d_collision|')\"
|
||||||
|
}" >&/dev/null
|
||||||
curl --fail-with-body -X POST \
|
curl --fail-with-body -X POST \
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < $THE_CURRENT_WORKING_DIRECTORY/release_info.json)/assets" \
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < $THE_CURRENT_WORKING_DIRECTORY/release_info.json)/assets" \
|
||||||
-H 'accept: application/json' \
|
-H 'accept: application/json' \
|
||||||
|
@ -80,6 +94,19 @@ jobs:
|
||||||
cd out_static
|
cd out_static
|
||||||
fakeroot tar --sort=name -cv usr | zstd --ultra -20 > "$THE_CURRENT_WORKING_DIRECTORY/$STATIC_LIB_ASSET_NAME"
|
fakeroot tar --sort=name -cv usr | zstd --ultra -20 > "$THE_CURRENT_WORKING_DIRECTORY/$STATIC_LIB_ASSET_NAME"
|
||||||
popd
|
popd
|
||||||
|
curl --fail-with-body -X GET \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < $THE_CURRENT_WORKING_DIRECTORY/release_info.json)" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-o current_release_info.json 2>/dev/null
|
||||||
|
curl --fail-with-body -X PATCH \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < $THE_CURRENT_WORKING_DIRECTORY/release_info.json)" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d "{
|
||||||
|
\"body\":\"$(jq .body < current_release_info.json | sed -e 's/^"//' -e 's/"$//')
|
||||||
|
$(find "$THE_CURRENT_WORKING_DIRECTORY" -maxdepth 1 -name "*$STATIC_LIB_ASSET_NAME" -execdir sha256sum '{}' ';' | sed -e 's|\./3d_collision|3d_collision|')\"
|
||||||
|
}" >&/dev/null
|
||||||
curl --fail-with-body -X POST \
|
curl --fail-with-body -X POST \
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < $THE_CURRENT_WORKING_DIRECTORY/release_info.json)/assets" \
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < $THE_CURRENT_WORKING_DIRECTORY/release_info.json)/assets" \
|
||||||
-H 'accept: application/json' \
|
-H 'accept: application/json' \
|
||||||
|
@ -87,3 +114,110 @@ jobs:
|
||||||
-H 'Content-Type: multipart/form-data' \
|
-H 'Content-Type: multipart/form-data' \
|
||||||
-F "attachment=@${THE_CURRENT_WORKING_DIRECTORY}/$STATIC_LIB_ASSET_NAME;type=application/zstd" > client_attach.json
|
-F "attachment=@${THE_CURRENT_WORKING_DIRECTORY}/$STATIC_LIB_ASSET_NAME;type=application/zstd" > client_attach.json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
assets-release-x86_64-debian:
|
||||||
|
needs: assets-release-x86_64
|
||||||
|
if: ${{ always() }}
|
||||||
|
runs-on: docker_debian_bookworm
|
||||||
|
env:
|
||||||
|
SHARED_LIB_ASSET_NAME: "3d_collision_helpers_${{ github.ref_name }}_debian_shared.tar.zst"
|
||||||
|
STATIC_LIB_ASSET_NAME: "3d_collision_helpers_${{ github.ref_name }}_debian_static.tar.zst"
|
||||||
|
steps:
|
||||||
|
- name: Update and upgrade with apt
|
||||||
|
run: apt-get --yes update && apt-get --yes upgrade
|
||||||
|
- name: Get necessary packages
|
||||||
|
run: apt-get --yes install gcc g++ jq curl cmake make zstd sed git
|
||||||
|
- name: Get release info
|
||||||
|
run: |
|
||||||
|
curl -X GET \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/tags/${GITHUB_REF_NAME}" \
|
||||||
|
-H 'accept: application/json' -o release_info.json
|
||||||
|
- name: Check if asset exists
|
||||||
|
run: |
|
||||||
|
for asset in $(jq '.assets[].name' < release_info.json | tr -d '"'); do
|
||||||
|
if [[ "$asset" == "$SHARED_LIB_ASSET_NAME" ]]; then
|
||||||
|
touch shared_lib_exists
|
||||||
|
elif [[ "$asset" == "$STATIC_LIB_ASSET_NAME" ]]; then
|
||||||
|
touch static_lib_exists
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
- name: Build shared if asset does not exist
|
||||||
|
run: |
|
||||||
|
if ! [[ -e shared_lib_exists ]]; then
|
||||||
|
if ! [[ -d 3dch_cloned ]]; then
|
||||||
|
git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/3d_collision_helpers.git 3dch_cloned
|
||||||
|
fi
|
||||||
|
pushd 3dch_cloned >&/dev/null && git restore . && git checkout "${GITHUB_REF_NAME}" && popd >&/dev/null
|
||||||
|
# Debian's gcc doesn't know about "-fstrict-flex-arrays=3".
|
||||||
|
sed -i -e 's/-fstrict-flex-arrays=3//g' 3dch_cloned/CMakeLists.txt
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=On -DCMAKE_INSTALL_PREFIX=/usr -S 3dch_cloned -B buildReleaseShared
|
||||||
|
make -C buildReleaseShared
|
||||||
|
make DESTDIR=$(pwd)/sharedOut -C buildReleaseShared install
|
||||||
|
|
||||||
|
pushd sharedOut >&/dev/null
|
||||||
|
|
||||||
|
tar --sort=name -I'zstd --compress -T0 --ultra -20' -cf "$SHARED_LIB_ASSET_NAME" usr
|
||||||
|
|
||||||
|
popd >&/dev/null
|
||||||
|
|
||||||
|
curl -X GET \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/tags/${GITHUB_REF_NAME}" \
|
||||||
|
-H 'accept: application/json' -o release_info_latest.json
|
||||||
|
|
||||||
|
curl --fail-with-body -X PATCH \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < release_info_latest.json)" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d "{
|
||||||
|
\"body\": \"$(jq .body < release_info_latest.json | sed -e 's/^"//' -e 's/"$//')
|
||||||
|
$(cd sharedOut && sha256sum "$SHARED_LIB_ASSET_NAME")\"
|
||||||
|
"} >&/dev/null
|
||||||
|
|
||||||
|
curl --fail-with-body -X POST \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < release_info_latest.json)/assets" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: multipart/form-data' \
|
||||||
|
-F "attachment=@sharedOut/${SHARED_LIB_ASSET_NAME};type=application/zstd" >&/dev/null
|
||||||
|
fi
|
||||||
|
- name: Build static if asset does not exist
|
||||||
|
run: |
|
||||||
|
if ! [[ -e static_lib_exists ]]; then
|
||||||
|
if ! [[ -d 3dch_cloned ]]; then
|
||||||
|
git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/3d_collision_helpers.git 3dch_cloned
|
||||||
|
fi
|
||||||
|
pushd 3dch_cloned >&/dev/null && git restore . && git checkout "${GITHUB_REF_NAME}" && popd >&/dev/null
|
||||||
|
# Debian's gcc doesn't know about "-fstrict-flex-arrays=3".
|
||||||
|
sed -i -e 's/-fstrict-flex-arrays=3//g' 3dch_cloned/CMakeLists.txt
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=Off -DCMAKE_INSTALL_PREFIX=/usr -S 3dch_cloned -B buildReleaseStatic
|
||||||
|
make -C buildReleaseStatic
|
||||||
|
make DESTDIR=$(pwd)/staticOut -C buildReleaseStatic install
|
||||||
|
|
||||||
|
pushd staticOut >&/dev/null
|
||||||
|
|
||||||
|
tar --sort=name -I'zstd --compress -T0 --ultra -20' -cf "$STATIC_LIB_ASSET_NAME" usr
|
||||||
|
|
||||||
|
popd >&/dev/null
|
||||||
|
|
||||||
|
curl -X GET \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/tags/${GITHUB_REF_NAME}" \
|
||||||
|
-H 'accept: application/json' -o release_info_latest.json
|
||||||
|
|
||||||
|
curl --fail-with-body -X PATCH \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < release_info_latest.json)" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d "{
|
||||||
|
\"body\": \"$(jq .body < release_info_latest.json | sed -e 's/^"//' -e 's/"$//')
|
||||||
|
$(cd staticOut && sha256sum "$STATIC_LIB_ASSET_NAME")\"
|
||||||
|
"} >&/dev/null
|
||||||
|
|
||||||
|
curl --fail-with-body -X POST \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < release_info_latest.json)/assets" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: multipart/form-data' \
|
||||||
|
-F "attachment=@staticOut/${STATIC_LIB_ASSET_NAME};type=application/zstd" >&/dev/null
|
||||||
|
fi
|
||||||
|
|
|
@ -6,7 +6,7 @@ set(SC_3D_CollisionDetectionHelpers_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/src/sc_
|
||||||
|
|
||||||
add_library(SC_3D_CollisionDetectionHelpers ${SC_3D_CollisionDetectionHelpers_SOURCES})
|
add_library(SC_3D_CollisionDetectionHelpers ${SC_3D_CollisionDetectionHelpers_SOURCES})
|
||||||
|
|
||||||
set_target_properties(SC_3D_CollisionDetectionHelpers PROPERTIES VERSION 3.2.1 SOVERSION 3)
|
set_target_properties(SC_3D_CollisionDetectionHelpers PROPERTIES VERSION 3.3.0 SOVERSION 3)
|
||||||
target_compile_features(SC_3D_CollisionDetectionHelpers PUBLIC cxx_std_20)
|
target_compile_features(SC_3D_CollisionDetectionHelpers PUBLIC cxx_std_20)
|
||||||
|
|
||||||
if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")
|
if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||||
|
|
13
Changelog.md
13
Changelog.md
|
@ -1,5 +1,18 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Upcoming Changes
|
||||||
|
|
||||||
|
## Version 3.3.0
|
||||||
|
|
||||||
|
Refactor some internal operators for Vec3/Mat4 operations (like mult., sum,
|
||||||
|
etc.)
|
||||||
|
|
||||||
|
Added Mat3 and helper functions related to Mat3.
|
||||||
|
|
||||||
|
Implemented conversion from axis/angle to rotation matrix (Mat3).
|
||||||
|
|
||||||
|
Implemented conversion from rotation matrix (mat3) to axis/angle.
|
||||||
|
|
||||||
## Version 3.2.1
|
## Version 3.2.1
|
||||||
|
|
||||||
Add workflow to build shared/static libs available
|
Add workflow to build shared/static libs available
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 3D Collision Helpers
|
# 3D Collision Helpers
|
||||||
|
|
||||||
|
[C++ conan package](https://git.seodisparate.com/stephenseo/-/packages/conan/3d_collision_helpers/versions)
|
||||||
|
|
||||||
Things to note:
|
Things to note:
|
||||||
|
|
||||||
- `main` is the stable branch. Expect things to not break unless the major
|
- `main` is the stable branch. Expect things to not break unless the major
|
||||||
|
|
56
conanfile.py
Normal file
56
conanfile.py
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
from conan import ConanFile
|
||||||
|
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
class SC_3D_collision_helpersRecipe(ConanFile):
|
||||||
|
name = "3d_collision_helpers"
|
||||||
|
version = "3.3.0"
|
||||||
|
package_type = "library"
|
||||||
|
|
||||||
|
# Optional metadata
|
||||||
|
license = "MIT"
|
||||||
|
author = "Stephen Seo stephen@seodisparate.com"
|
||||||
|
url = "https://git.seodisparate.com/stephenseo/3d_collision_helpers"
|
||||||
|
description = "A library with helpers for 3d space"
|
||||||
|
topics = ("3D", "collision", "matrix", "vector")
|
||||||
|
|
||||||
|
# Binary configuration
|
||||||
|
settings = "os", "compiler", "build_type", "arch"
|
||||||
|
options = {"shared": [True, False], "fPIC": [True, False]}
|
||||||
|
default_options = {"shared": False, "fPIC": True}
|
||||||
|
|
||||||
|
# Sources are located in the same place as this recipe, copy them to the recipe
|
||||||
|
exports_sources = "CMakeLists.txt", "src/*"
|
||||||
|
|
||||||
|
def config_options(self):
|
||||||
|
if self.settings.os == "Windows":
|
||||||
|
self.options.rm_safe("fPIC")
|
||||||
|
|
||||||
|
def configure(self):
|
||||||
|
if self.options.shared:
|
||||||
|
self.options.rm_safe("fPIC")
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
cmake_layout(self)
|
||||||
|
|
||||||
|
def generate(self):
|
||||||
|
deps = CMakeDeps(self)
|
||||||
|
deps.generate()
|
||||||
|
tc = CMakeToolchain(self)
|
||||||
|
tc.generate()
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
cmake = CMake(self)
|
||||||
|
cmake.configure()
|
||||||
|
cmake.build()
|
||||||
|
if not self.conf.get("tools.build:skip_test", default=False):
|
||||||
|
self.run(os.path.join(self.build_folder, "UnitTest"))
|
||||||
|
|
||||||
|
def package(self):
|
||||||
|
cmake = CMake(self)
|
||||||
|
cmake.install()
|
||||||
|
|
||||||
|
def package_info(self):
|
||||||
|
self.cpp_info.libs = ["SC_3D_CollisionDetectionHelpers"]
|
||||||
|
|
165
src/sc_sacd.cpp
165
src/sc_sacd.cpp
|
@ -12,23 +12,30 @@
|
||||||
|
|
||||||
constexpr float INV_SQRT2 = 0.70710678118654752440F;
|
constexpr float INV_SQRT2 = 0.70710678118654752440F;
|
||||||
|
|
||||||
SC_SACD_Vec3 operator+(const SC_SACD_Vec3 &a, const SC_SACD_Vec3 &b) {
|
SC_SACD_Vec3 operator+(SC_SACD_Vec3 a, SC_SACD_Vec3 b) {
|
||||||
return SC_SACD_Vec3{a.x + b.x, a.y + b.y, a.z + b.z};
|
return SC_SACD_Vec3{a.x + b.x, a.y + b.y, a.z + b.z};
|
||||||
}
|
}
|
||||||
|
|
||||||
SC_SACD_Vec3 operator-(const SC_SACD_Vec3 &a, const SC_SACD_Vec3 &b) {
|
SC_SACD_Vec3 operator-(SC_SACD_Vec3 a, SC_SACD_Vec3 b) {
|
||||||
return SC_SACD_Vec3{a.x - b.x, a.y - b.y, a.z - b.z};
|
return SC_SACD_Vec3{a.x - b.x, a.y - b.y, a.z - b.z};
|
||||||
}
|
}
|
||||||
|
|
||||||
SC_SACD_Vec3 operator*(const SC_SACD_Vec3 &a, float scalar) {
|
SC_SACD_Vec3 operator*(SC_SACD_Vec3 a, float scalar) {
|
||||||
return SC_SACD_Vec3{a.x * scalar, a.y * scalar, a.z * scalar};
|
return SC_SACD_Vec3{a.x * scalar, a.y * scalar, a.z * scalar};
|
||||||
}
|
}
|
||||||
|
|
||||||
SC_SACD_Vec3 operator/(const SC_SACD_Vec3 &a, float scalar) {
|
SC_SACD_Vec3 operator/(SC_SACD_Vec3 a, float scalar) {
|
||||||
return SC_SACD_Vec3{a.x / scalar, a.y / scalar, a.z / scalar};
|
return SC_SACD_Vec3{a.x / scalar, a.y / scalar, a.z / scalar};
|
||||||
}
|
}
|
||||||
|
|
||||||
SC_SACD_Mat4 operator*(const SC_SACD_Mat4 &a, const SC_SACD_Mat4 &b) {
|
SC_SACD_Mat4 operator+(SC_SACD_Mat4 a, SC_SACD_Mat4 b) {
|
||||||
|
return SC_SACD_Mat4{a.x0 + b.x0, a.x1 + b.x1, a.x2 + b.x2, a.x3 + b.x3,
|
||||||
|
a.y0 + b.y0, a.y1 + b.y1, a.y2 + b.y2, a.y3 + b.y3,
|
||||||
|
a.z0 + b.z0, a.z1 + b.z1, a.z2 + b.z2, a.z3 + b.z3,
|
||||||
|
a.w0 + b.w0, a.w1 + b.w1, a.w2 + b.w2, a.w3 + b.w3};
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat4 operator*(SC_SACD_Mat4 a, SC_SACD_Mat4 b) {
|
||||||
SC_SACD_Mat4 mat;
|
SC_SACD_Mat4 mat;
|
||||||
|
|
||||||
mat.x0 = b.x0 * a.x0 + b.y0 * a.x1 + b.z0 * a.x2 + b.w0 * a.x3;
|
mat.x0 = b.x0 * a.x0 + b.y0 * a.x1 + b.z0 * a.x2 + b.w0 * a.x3;
|
||||||
|
@ -54,13 +61,58 @@ SC_SACD_Mat4 operator*(const SC_SACD_Mat4 &a, const SC_SACD_Mat4 &b) {
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
SC_SACD_Vec3 operator*(const SC_SACD_Mat4 &mat, const SC_SACD_Vec3 &vec) {
|
SC_SACD_Vec3 operator*(SC_SACD_Mat4 mat, SC_SACD_Vec3 vec) {
|
||||||
return SC_SACD_Vec3{
|
return SC_SACD_Vec3{
|
||||||
vec.x * mat.x0 + vec.y * mat.x1 + vec.z * mat.x2 + mat.x3,
|
vec.x * mat.x0 + vec.y * mat.x1 + vec.z * mat.x2 + mat.x3,
|
||||||
vec.x * mat.y0 + vec.y * mat.y1 + vec.z * mat.y2 + mat.y3,
|
vec.x * mat.y0 + vec.y * mat.y1 + vec.z * mat.y2 + mat.y3,
|
||||||
vec.x * mat.z0 + vec.y * mat.z1 + vec.z * mat.z2 + mat.z3};
|
vec.x * mat.z0 + vec.y * mat.z1 + vec.z * mat.z2 + mat.z3};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat3 operator+(SC_SACD_Mat3 a, SC_SACD_Mat3 b) {
|
||||||
|
return SC_SACD_Mat3{a.x0 + b.x0, a.x1 + b.x1, a.x2 + b.x2,
|
||||||
|
a.y0 + b.y0, a.y1 + b.y1, a.y2 + b.y2,
|
||||||
|
a.z0 + b.z0, a.z1 + b.z1, a.z2 + b.z2};
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat3 operator*(SC_SACD_Mat3 a, SC_SACD_Mat3 b) {
|
||||||
|
return SC_SACD_Mat3{// x0
|
||||||
|
a.x0 * b.x0 + a.x1 * b.y0 + a.x2 * b.z0,
|
||||||
|
// x1
|
||||||
|
a.x0 * b.x1 + a.x1 * b.y1 + a.x2 * b.z1,
|
||||||
|
// x2
|
||||||
|
a.x0 * b.x2 + a.x1 * b.y2 + a.x2 * b.z2,
|
||||||
|
// y0
|
||||||
|
a.y0 * b.x0 + a.y1 * b.y0 + a.y2 * b.z0,
|
||||||
|
// y1
|
||||||
|
a.y0 * b.x1 + a.y1 * b.y1 + a.y2 * b.z1,
|
||||||
|
// y2
|
||||||
|
a.y0 * b.x2 + a.y1 * b.y2 + a.y2 * b.z2,
|
||||||
|
// z0
|
||||||
|
a.z0 * b.x0 + a.z1 * b.y0 + a.z2 * b.z0,
|
||||||
|
// z1
|
||||||
|
a.z0 * b.x1 + a.z1 * b.y1 + a.z2 * b.z1,
|
||||||
|
// z2
|
||||||
|
a.z0 * b.x2 + a.z1 * b.y2 + a.z2 * b.z2};
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Vec3 operator*(SC_SACD_Mat3 mat3, SC_SACD_Vec3 vec) {
|
||||||
|
return SC_SACD_Vec3{
|
||||||
|
mat3.x0 * vec.x + mat3.x1 * vec.y + mat3.x2 * vec.z,
|
||||||
|
mat3.y0 * vec.x + mat3.y1 * vec.y + mat3.y2 * vec.z,
|
||||||
|
mat3.z0 * vec.x + mat3.z1 * vec.y + mat3.z2 * vec.z,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat3 operator*(SC_SACD_Mat3 mat3, float scalar) {
|
||||||
|
return SC_SACD_Mat3{mat3.x0 * scalar, mat3.x1 * scalar, mat3.x2 * scalar,
|
||||||
|
mat3.y0 * scalar, mat3.y1 * scalar, mat3.y2 * scalar,
|
||||||
|
mat3.z0 * scalar, mat3.z1 * scalar, mat3.z2 * scalar};
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat3 UHat_Mat3(float x, float y, float z) {
|
||||||
|
return SC_SACD_Mat3{0.0F, -z, y, z, 0.0F, -x, -y, x, 0.0F};
|
||||||
|
}
|
||||||
|
|
||||||
std::array<SC_SACD_Vec3, 3> SC_SACD_Get_Box_Normals(SC_SACD_Generic_Box box) {
|
std::array<SC_SACD_Vec3, 3> SC_SACD_Get_Box_Normals(SC_SACD_Generic_Box box) {
|
||||||
SC_SACD_Vec3 a, b, c;
|
SC_SACD_Vec3 a, b, c;
|
||||||
|
|
||||||
|
@ -413,6 +465,8 @@ SC_SACD_Mat4 SC_SACD_Mat4_Identity(void) {
|
||||||
0.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F};
|
0.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat4 SC_SACD_Mat4_Sum(SC_SACD_Mat4 a, SC_SACD_Mat4 b) { return a + b; }
|
||||||
|
|
||||||
SC_SACD_Mat4 SC_SACD_Mat4_Mult(SC_SACD_Mat4 a, SC_SACD_Mat4 b) { return a * b; }
|
SC_SACD_Mat4 SC_SACD_Mat4_Mult(SC_SACD_Mat4 a, SC_SACD_Mat4 b) { return a * b; }
|
||||||
|
|
||||||
SC_SACD_Vec3 SC_SACD_Mat4_Vec3_Mult(SC_SACD_Mat4 mat, SC_SACD_Vec3 vec) {
|
SC_SACD_Vec3 SC_SACD_Mat4_Vec3_Mult(SC_SACD_Mat4 mat, SC_SACD_Vec3 vec) {
|
||||||
|
@ -703,3 +757,102 @@ SC_SACD_Vec3 SC_SACD_Vec3_Reflect(SC_SACD_Vec3 vec, SC_SACD_Vec3 target) {
|
||||||
SC_SACD_Vec3 proj = SC_SACD_Vec3_Project(vec, target);
|
SC_SACD_Vec3 proj = SC_SACD_Vec3_Project(vec, target);
|
||||||
return proj * 2.0F - vec;
|
return proj * 2.0F - vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat4 SC_SACD_Mat3_Promote(SC_SACD_Mat3 mat3) {
|
||||||
|
return SC_SACD_Mat4{mat3.x0, mat3.x1, mat3.x2, 0.0F, mat3.y0, mat3.y1,
|
||||||
|
mat3.y2, 0.0F, mat3.z0, mat3.z1, mat3.z2, 0.0F,
|
||||||
|
0.0F, 0.0F, 0.0F, 1.0F};
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat3 SC_SACD_Mat4_Demote(SC_SACD_Mat4 mat4) {
|
||||||
|
return SC_SACD_Mat3{mat4.x0, mat4.x1, mat4.x2, mat4.y0, mat4.y1,
|
||||||
|
mat4.y2, mat4.z0, mat4.z1, mat4.z2};
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat3 SC_SACD_Mat3_Identity() {
|
||||||
|
return SC_SACD_Mat3{1.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 1.0F};
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat3 SC_SACD_Mat3_Sum(SC_SACD_Mat3 a, SC_SACD_Mat3 b) { return a + b; }
|
||||||
|
|
||||||
|
SC_SACD_Mat3 SC_SACD_Mat3_Mult(SC_SACD_Mat3 a, SC_SACD_Mat3 b) { return a * b; }
|
||||||
|
|
||||||
|
SC_SACD_Vec3 SC_SACD_Mat3_Vec3_Mult(SC_SACD_Mat3 mat3, SC_SACD_Vec3 vec) {
|
||||||
|
return mat3 * vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat3 SC_SACD_Rotation_Mat3_XAxis(float x_radians) {
|
||||||
|
SC_SACD_Mat3 mat;
|
||||||
|
|
||||||
|
mat.x0 = 1.0F;
|
||||||
|
mat.x1 = 0.0F;
|
||||||
|
mat.x2 = 0.0F;
|
||||||
|
|
||||||
|
mat.y0 = 0.0F;
|
||||||
|
mat.y1 = std::cos(x_radians);
|
||||||
|
mat.y2 = -std::sin(x_radians);
|
||||||
|
|
||||||
|
mat.z0 = 0.0F;
|
||||||
|
mat.z1 = -mat.y2;
|
||||||
|
mat.z2 = mat.y1;
|
||||||
|
|
||||||
|
return mat;
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat3 SC_SACD_Rotation_Mat3_YAxis(float y_radians) {
|
||||||
|
SC_SACD_Mat3 mat;
|
||||||
|
|
||||||
|
mat.x0 = std::cos(y_radians);
|
||||||
|
mat.x1 = 0.0F;
|
||||||
|
mat.x2 = std::sin(y_radians);
|
||||||
|
|
||||||
|
mat.y0 = 0.0F;
|
||||||
|
mat.y1 = 1.0F;
|
||||||
|
mat.y2 = 0.0F;
|
||||||
|
|
||||||
|
mat.z0 = -mat.x2;
|
||||||
|
mat.z1 = 0.0F;
|
||||||
|
mat.z2 = mat.x0;
|
||||||
|
|
||||||
|
return mat;
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat3 SC_SACD_Rotation_Mat3_ZAxis(float z_radians) {
|
||||||
|
SC_SACD_Mat3 mat;
|
||||||
|
|
||||||
|
mat.x0 = std::cos(z_radians);
|
||||||
|
mat.x1 = -std::sin(z_radians);
|
||||||
|
mat.x2 = 0.0F;
|
||||||
|
|
||||||
|
mat.y0 = -mat.x1;
|
||||||
|
mat.y1 = mat.x0;
|
||||||
|
mat.y2 = 0.0F;
|
||||||
|
|
||||||
|
mat.z0 = 0.0F;
|
||||||
|
mat.z1 = 0.0F;
|
||||||
|
mat.z2 = 1.0F;
|
||||||
|
|
||||||
|
return mat;
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat3 SC_SACD_Scale_Mat3(float x, float y, float z) {
|
||||||
|
return SC_SACD_Mat3{x, 0.0f, 0.0f, 0.0f, y, 0.0f, 0.0f, 0.0f, z};
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Mat3 SC_SACD_ExpMap(SC_SACD_Vec3 axis, float angle) {
|
||||||
|
axis = SC_SACD_Vec3_Normalize(axis);
|
||||||
|
auto uhat = UHat_Mat3(axis.x, axis.y, axis.z);
|
||||||
|
auto uhat_squared = uhat * uhat;
|
||||||
|
return SC_SACD_Mat3_Identity() + uhat * std::sin(angle) +
|
||||||
|
uhat_squared * (1 - std::cos(angle));
|
||||||
|
}
|
||||||
|
|
||||||
|
float SC_SACD_LogMap_Angle(SC_SACD_Mat3 mat3) {
|
||||||
|
float trace = mat3.x0 + mat3.y1 + mat3.z2;
|
||||||
|
return std::acos((trace - 1.0F) / 2.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
SC_SACD_Vec3 SC_SACD_LogMap_Axis(SC_SACD_Mat3 mat3, float angle) {
|
||||||
|
return SC_SACD_Vec3{mat3.z1 - mat3.y2, mat3.x2 - mat3.z0, mat3.y0 - mat3.x1} *
|
||||||
|
(1.0F / (2.0F * std::sin(angle)));
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,12 @@ typedef struct SC_SACD_EXPORT SC_SACD_Vec3 {
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
} SC_SACD_Vec3;
|
} SC_SACD_Vec3;
|
||||||
|
|
||||||
|
typedef struct SC_SACD_EXPORT SC_SACD_Mat3 {
|
||||||
|
float x0, x1, x2;
|
||||||
|
float y0, y1, y2;
|
||||||
|
float z0, z1, z2;
|
||||||
|
} SC_SACD_Mat3;
|
||||||
|
|
||||||
typedef struct SC_SACD_EXPORT SC_SACD_Mat4 {
|
typedef struct SC_SACD_EXPORT SC_SACD_Mat4 {
|
||||||
float x0, x1, x2, x3;
|
float x0, x1, x2, x3;
|
||||||
float y0, y1, y2, y3;
|
float y0, y1, y2, y3;
|
||||||
|
@ -100,6 +106,8 @@ SC_SACD_EXPORT SC_SACD_Vec3 SC_SACD_Cross_Product(SC_SACD_Vec3 a,
|
||||||
|
|
||||||
SC_SACD_EXPORT SC_SACD_Mat4 SC_SACD_Mat4_Identity(void);
|
SC_SACD_EXPORT SC_SACD_Mat4 SC_SACD_Mat4_Identity(void);
|
||||||
|
|
||||||
|
SC_SACD_EXPORT SC_SACD_Mat4 SC_SACD_Mat4_Sum(SC_SACD_Mat4 a, SC_SACD_Mat4 b);
|
||||||
|
|
||||||
SC_SACD_EXPORT SC_SACD_Mat4 SC_SACD_Mat4_Mult(SC_SACD_Mat4 a, SC_SACD_Mat4 b);
|
SC_SACD_EXPORT SC_SACD_Mat4 SC_SACD_Mat4_Mult(SC_SACD_Mat4 a, SC_SACD_Mat4 b);
|
||||||
|
|
||||||
SC_SACD_EXPORT SC_SACD_Vec3 SC_SACD_Mat4_Vec3_Mult(SC_SACD_Mat4 mat,
|
SC_SACD_EXPORT SC_SACD_Vec3 SC_SACD_Mat4_Vec3_Mult(SC_SACD_Mat4 mat,
|
||||||
|
@ -155,6 +163,23 @@ SC_SACD_EXPORT SC_SACD_Vec3 SC_SACD_Vec3_Project(SC_SACD_Vec3 vec,
|
||||||
SC_SACD_EXPORT SC_SACD_Vec3 SC_SACD_Vec3_Reflect(SC_SACD_Vec3 vec,
|
SC_SACD_EXPORT SC_SACD_Vec3 SC_SACD_Vec3_Reflect(SC_SACD_Vec3 vec,
|
||||||
SC_SACD_Vec3 target);
|
SC_SACD_Vec3 target);
|
||||||
|
|
||||||
|
SC_SACD_EXPORT SC_SACD_Mat4 SC_SACD_Mat3_Promote(SC_SACD_Mat3 mat3);
|
||||||
|
SC_SACD_EXPORT SC_SACD_Mat3 SC_SACD_Mat4_Demote(SC_SACD_Mat4 mat4);
|
||||||
|
|
||||||
|
SC_SACD_EXPORT SC_SACD_Mat3 SC_SACD_Mat3_Identity(void);
|
||||||
|
SC_SACD_EXPORT SC_SACD_Mat3 SC_SACD_Mat3_Sum(SC_SACD_Mat3 a, SC_SACD_Mat3 b);
|
||||||
|
SC_SACD_EXPORT SC_SACD_Mat3 SC_SACD_Mat3_Mult(SC_SACD_Mat3 a, SC_SACD_Mat3 b);
|
||||||
|
SC_SACD_EXPORT SC_SACD_Vec3 SC_SACD_Mat3_Vec3_Mult(SC_SACD_Mat3 mat3,
|
||||||
|
SC_SACD_Vec3 vec);
|
||||||
|
SC_SACD_EXPORT SC_SACD_Mat3 SC_SACD_Rotation_Mat3_XAxis(float x_radians);
|
||||||
|
SC_SACD_EXPORT SC_SACD_Mat3 SC_SACD_Rotation_Mat3_YAxis(float y_radians);
|
||||||
|
SC_SACD_EXPORT SC_SACD_Mat3 SC_SACD_Rotation_Mat3_ZAxis(float z_radians);
|
||||||
|
SC_SACD_EXPORT SC_SACD_Mat3 SC_SACD_Scale_Mat3(float x, float y, float z);
|
||||||
|
|
||||||
|
SC_SACD_EXPORT SC_SACD_Mat3 SC_SACD_ExpMap(SC_SACD_Vec3 axis, float angle);
|
||||||
|
SC_SACD_EXPORT float SC_SACD_LogMap_Angle(SC_SACD_Mat3 mat3);
|
||||||
|
SC_SACD_EXPORT SC_SACD_Vec3 SC_SACD_LogMap_Axis(SC_SACD_Mat3 mat3, float angle);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
105
src/test.cpp
105
src/test.cpp
|
@ -11,19 +11,21 @@ static int checks_passed = 0;
|
||||||
do { \
|
do { \
|
||||||
++checks_checked; \
|
++checks_checked; \
|
||||||
if (!(x)) { \
|
if (!(x)) { \
|
||||||
std::cout << "CHECK_TRUE at line " << __LINE__ << " failed!\n"; \
|
std::cout << "CHECK_TRUE at line " << __LINE__ << " failed: " \
|
||||||
|
<< #x << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
++checks_passed; \
|
++checks_passed; \
|
||||||
} \
|
} \
|
||||||
} while (false);
|
} while (false);
|
||||||
#define CHECK_FALSE(x) \
|
#define CHECK_FALSE(x) \
|
||||||
do { \
|
do { \
|
||||||
++checks_checked; \
|
++checks_checked; \
|
||||||
if (x) { \
|
if (x) { \
|
||||||
std::cout << "CHECK_FALSE at line " << __LINE__ << " failed!\n"; \
|
std::cout << "CHECK_FALSE at line " << __LINE__ << " failed: " \
|
||||||
} else { \
|
<< #x << '\n'; \
|
||||||
++checks_passed; \
|
} else { \
|
||||||
} \
|
++checks_passed; \
|
||||||
|
} \
|
||||||
} while (false);
|
} while (false);
|
||||||
|
|
||||||
#define CHECK_FLOAT(var, value) \
|
#define CHECK_FLOAT(var, value) \
|
||||||
|
@ -32,7 +34,8 @@ static int checks_passed = 0;
|
||||||
if ((var) > (value)-0.0001F && (var) < (value) + 0.0001F) { \
|
if ((var) > (value)-0.0001F && (var) < (value) + 0.0001F) { \
|
||||||
++checks_passed; \
|
++checks_passed; \
|
||||||
} else { \
|
} else { \
|
||||||
std::cout << "CHECK_FLOAT at line " << __LINE__ << " failed!\n"; \
|
std::cout << "CHECK_FLOAT at line " << __LINE__ << " failed: " \
|
||||||
|
<< #var << " != " << #value << '\n'; \
|
||||||
} \
|
} \
|
||||||
} while (false);
|
} while (false);
|
||||||
|
|
||||||
|
@ -902,6 +905,88 @@ int main() {
|
||||||
CHECK_FLOAT(vec.z, std::sqrt(9.0F / 14.0F));
|
CHECK_FLOAT(vec.z, std::sqrt(9.0F / 14.0F));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test axis-angle to rotation matrix.
|
||||||
|
{
|
||||||
|
// About Z-axis.
|
||||||
|
SC_SACD_Vec3 axis{0.0F, 0.0F, 1.0F};
|
||||||
|
float angle = std::numbers::pi_v<float> / 2.0F;
|
||||||
|
|
||||||
|
SC_SACD_Mat3 rot_from_axis_angle = SC_SACD_ExpMap(axis, angle);
|
||||||
|
SC_SACD_Mat3 rotation_mat = SC_SACD_Rotation_Mat3_ZAxis(angle);
|
||||||
|
|
||||||
|
SC_SACD_Vec3 vec{1.0F, 1.0F, 1.0F};
|
||||||
|
|
||||||
|
SC_SACD_Vec3 transformed_vec0 = SC_SACD_Mat3_Vec3_Mult(rot_from_axis_angle, vec);
|
||||||
|
SC_SACD_Vec3 transformed_vec1 = SC_SACD_Mat3_Vec3_Mult(rotation_mat, vec);
|
||||||
|
|
||||||
|
CHECK_FLOAT(transformed_vec0.x, transformed_vec1.x);
|
||||||
|
CHECK_FLOAT(transformed_vec0.y, transformed_vec1.y);
|
||||||
|
CHECK_FLOAT(transformed_vec0.z, transformed_vec1.z);
|
||||||
|
|
||||||
|
// About X-axis.
|
||||||
|
axis = SC_SACD_Vec3{1.0F, 0.0F, 0.0F};
|
||||||
|
|
||||||
|
rot_from_axis_angle = SC_SACD_ExpMap(axis, angle);
|
||||||
|
rotation_mat = SC_SACD_Rotation_Mat3_XAxis(angle);
|
||||||
|
|
||||||
|
transformed_vec0 = SC_SACD_Mat3_Vec3_Mult(rot_from_axis_angle, vec);
|
||||||
|
transformed_vec1 = SC_SACD_Mat3_Vec3_Mult(rotation_mat, vec);
|
||||||
|
|
||||||
|
CHECK_FLOAT(transformed_vec0.x, transformed_vec1.x);
|
||||||
|
CHECK_FLOAT(transformed_vec0.y, transformed_vec1.y);
|
||||||
|
CHECK_FLOAT(transformed_vec0.z, transformed_vec1.z);
|
||||||
|
|
||||||
|
// About Y-axis.
|
||||||
|
axis = SC_SACD_Vec3{0.0F, 1.0F, 0.0F};
|
||||||
|
|
||||||
|
rot_from_axis_angle = SC_SACD_ExpMap(axis, angle);
|
||||||
|
rotation_mat = SC_SACD_Rotation_Mat3_YAxis(angle);
|
||||||
|
|
||||||
|
transformed_vec0 = SC_SACD_Mat3_Vec3_Mult(rot_from_axis_angle, vec);
|
||||||
|
transformed_vec1 = SC_SACD_Mat3_Vec3_Mult(rotation_mat, vec);
|
||||||
|
|
||||||
|
CHECK_FLOAT(transformed_vec0.x, transformed_vec1.x);
|
||||||
|
CHECK_FLOAT(transformed_vec0.y, transformed_vec1.y);
|
||||||
|
CHECK_FLOAT(transformed_vec0.z, transformed_vec1.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test rotation matrix to axis-angle.
|
||||||
|
{
|
||||||
|
// X-axis.
|
||||||
|
float angle = std::numbers::pi_v<float> / 2.0F;
|
||||||
|
SC_SACD_Mat3 rot_mat = SC_SACD_Rotation_Mat3_XAxis(angle);
|
||||||
|
|
||||||
|
float derived_angle = SC_SACD_LogMap_Angle(rot_mat);
|
||||||
|
CHECK_FLOAT(derived_angle, angle);
|
||||||
|
|
||||||
|
SC_SACD_Vec3 derived_axis = SC_SACD_LogMap_Axis(rot_mat, angle);
|
||||||
|
CHECK_FLOAT(derived_axis.x, 1.0F);
|
||||||
|
CHECK_FLOAT(derived_axis.y, 0.0F);
|
||||||
|
CHECK_FLOAT(derived_axis.z, 0.0F);
|
||||||
|
|
||||||
|
// Y-axis.
|
||||||
|
rot_mat = SC_SACD_Rotation_Mat3_YAxis(angle);
|
||||||
|
|
||||||
|
derived_angle = SC_SACD_LogMap_Angle(rot_mat);
|
||||||
|
CHECK_FLOAT(derived_angle, angle);
|
||||||
|
|
||||||
|
derived_axis = SC_SACD_LogMap_Axis(rot_mat, angle);
|
||||||
|
CHECK_FLOAT(derived_axis.x, 0.0F);
|
||||||
|
CHECK_FLOAT(derived_axis.y, 1.0F);
|
||||||
|
CHECK_FLOAT(derived_axis.z, 0.0F);
|
||||||
|
|
||||||
|
// Z-axis.
|
||||||
|
rot_mat = SC_SACD_Rotation_Mat3_ZAxis(angle);
|
||||||
|
|
||||||
|
derived_angle = SC_SACD_LogMap_Angle(rot_mat);
|
||||||
|
CHECK_FLOAT(derived_angle, angle);
|
||||||
|
|
||||||
|
derived_axis = SC_SACD_LogMap_Axis(rot_mat, angle);
|
||||||
|
CHECK_FLOAT(derived_axis.x, 0.0F);
|
||||||
|
CHECK_FLOAT(derived_axis.y, 0.0F);
|
||||||
|
CHECK_FLOAT(derived_axis.z, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << "Checks checked: " << checks_checked << '\n'
|
std::cout << "Checks checked: " << checks_checked << '\n'
|
||||||
<< "Checks passed: " << checks_passed << '\n';
|
<< "Checks passed: " << checks_passed << '\n';
|
||||||
|
|
||||||
|
|
1
test_package/.gitignore
vendored
Normal file
1
test_package/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/build/
|
7
test_package/CMakeLists.txt
Normal file
7
test_package/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
project(PackageTest CXX)
|
||||||
|
|
||||||
|
find_package(3d_collision_helpers CONFIG REQUIRED)
|
||||||
|
|
||||||
|
add_executable(example src/example.cpp)
|
||||||
|
target_link_libraries(example 3d_collision_helpers::3d_collision_helpers)
|
9
test_package/CMakeUserPresets.json
Normal file
9
test_package/CMakeUserPresets.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"version": 4,
|
||||||
|
"vendor": {
|
||||||
|
"conan": {}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"build/gcc-14-x86_64-gnu17-release/generators/CMakePresets.json"
|
||||||
|
]
|
||||||
|
}
|
26
test_package/conanfile.py
Normal file
26
test_package/conanfile.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
from conan import ConanFile
|
||||||
|
from conan.tools.cmake import CMake, cmake_layout
|
||||||
|
from conan.tools.build import can_run
|
||||||
|
|
||||||
|
|
||||||
|
class SC_3D_collision_helpersTestConan(ConanFile):
|
||||||
|
settings = "os", "compiler", "build_type", "arch"
|
||||||
|
generators = "CMakeDeps", "CMakeToolchain"
|
||||||
|
|
||||||
|
def requirements(self):
|
||||||
|
self.requires(self.tested_reference_str)
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
cmake = CMake(self)
|
||||||
|
cmake.configure()
|
||||||
|
cmake.build()
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
cmake_layout(self)
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
if can_run(self):
|
||||||
|
cmd = os.path.join(self.cpp.build.bindir, "example")
|
||||||
|
self.run(cmd, env="conanrun")
|
6
test_package/src/example.cpp
Normal file
6
test_package/src/example.cpp
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#include "sc_sacd.h"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
auto mat3 = SC_SACD_Mat3_Identity();
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue