Skip to content

Commit

Permalink
Librarified
Browse files Browse the repository at this point in the history
  • Loading branch information
ecton committed Aug 15, 2024
1 parent 6b908bf commit dca6ef3
Show file tree
Hide file tree
Showing 8 changed files with 1,028 additions and 728 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [ecton]
28 changes: 28 additions & 0 deletions .github/workflows/docs.yml
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
33 changes: 33 additions & 0 deletions .github/workflows/rust.yml
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
16 changes: 9 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 21 additions & 2 deletions Cargo.toml
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"
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# FunnyBones

Check warning on line 1 in README.md

View workflow job for this annotation

GitHub Actions / test

item in documentation is missing backticks

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

Check warning on line 17 in README.md

View workflow job for this annotation

GitHub Actions / test

item in documentation is missing backticks

FunnyBones has two main concepts: joints and bones.

Check warning on line 19 in README.md

View workflow job for this annotation

GitHub Actions / test

item in documentation is missing backticks

- *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

Check warning on line 22 in README.md

View workflow job for this annotation

GitHub Actions / test

doc list item missing indentation
kinematics* to create the angle using the two associated bones.

Check warning on line 23 in README.md

View workflow job for this annotation

GitHub Actions / test

doc list item missing indentation
- *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:

Check warning on line 29 in README.md

View workflow job for this annotation

GitHub Actions / test

item in documentation is missing backticks

- *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.
Loading

0 comments on commit dca6ef3

Please sign in to comment.