-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,028 additions
and
728 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: [ecton] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Docs | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Rust | ||
uses: hecrj/setup-rust-action@v1 | ||
with: | ||
rust-version: nightly | ||
|
||
- uses: actions/checkout@v3 | ||
- name: Generate Docs | ||
run: | | ||
cargo +nightly doc --no-deps --all-features --workspace | ||
- name: Deploy Docs | ||
if: github.ref == 'refs/heads/main' | ||
uses: JamesIves/github-pages-deploy-action@releases/v4 | ||
with: | ||
branch: gh-pages | ||
folder: target/doc/ | ||
git-config-name: kl-botsu | ||
git-config-email: [email protected] | ||
target-folder: /main/ | ||
clean: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Rust | ||
uses: hecrj/setup-rust-action@v1 | ||
|
||
- name: Run clippy | ||
run: | | ||
cargo clippy | ||
- name: Run unit tests | ||
run: | | ||
cargo test | ||
build-msrv: | ||
name: Test on MSRV | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install Rust | ||
uses: hecrj/setup-rust-action@v1 | ||
with: | ||
rust-version: 1.65.0 | ||
- name: Run unit tests | ||
run: cargo test |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
[package] | ||
name = "skeleton" | ||
name = "funnybones" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[features] | ||
|
||
[[example]] | ||
name = "toy" | ||
required-features = ["cushy"] | ||
|
||
[dependencies] | ||
cushy = { path = "../cushy" } | ||
cushy = { git = "https://github.com/khonsulabs/cushy", optional = true } | ||
|
||
[dev-dependencies] | ||
cushy = { git = "https://github.com/khonsulabs/cushy" } | ||
|
||
[lints.clippy] | ||
pedantic = { level = "warn", priority = -1 } | ||
module_name_repetitions = "allow" | ||
missing_errors_doc = "allow" | ||
missing_panics_doc = "allow" | ||
|
||
[lints.rust] | ||
unsafe_code = "forbid" | ||
missing_docs = "warn" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# FunnyBones | ||
|
||
A simple 2D kinematics library for Rust | ||
|
||
## Motivation and Goals | ||
|
||
When looking at the libraries that support inverse kinematics in Rust in 2024, | ||
there are several fairly mature solutions that focus on 3D and robotics. For | ||
someone interested in 2D only, a lot of these libraries seemed like overkill for | ||
basic 2D games. | ||
|
||
This library implements a simplified forward and inverse kinematics model that | ||
only uses basic trigonometry and can be solved in one pass across the bone | ||
structure with no smoothing algorithms necessary. The initial implementation of | ||
this library was under 600 lines of code with no required dependencies. | ||
|
||
## How FunnyBones works | ||
|
||
FunnyBones has two main concepts: joints and bones. | ||
|
||
- *Joints* are used to connect a specific end of one bone to a specific end of | ||
another bone. Each joint can be assigned an angle which is applied as *forward | ||
kinematics* to create the angle using the two associated bones. | ||
- *Bones* are one-dimensional line segments that have a required length. Bones | ||
can have a *desired position* for the end of the bone positioned furthest from | ||
the skeleton root. If the desired position is set, it is applied as *inverse | ||
kinematics*. | ||
|
||
In FunnyBones, bones come in two varieties: | ||
|
||
- *Rigid* bones are a single line segment of a fixed length. An example of a | ||
rigid bone in a simple human skeleton might be a single bone representing | ||
the spine. | ||
- *Flexible* bones are two line segments of fixed lengths that bend and rotate | ||
automatically (ignoring the connecting joint's angle) to ensure that both | ||
leg segments are always the correct length. An example of a flexible bone in | ||
a simple human skeleton might be a leg or an arm. | ||
|
||
A `Skeleton` is a collection of joints and bones. The first bone pushed is | ||
considered the root bone. When solving for updated positions, the algorithm | ||
starts by evaluating all joints connected to both ends of the root bone and | ||
continues until all reachable bones have been evaluated. The algorithm is | ||
single-pass and produces stable results. |
Oops, something went wrong.