Skip to content

Commit

Permalink
Adding example to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ecton committed Aug 15, 2024
1 parent 14d1d08 commit f290765
Show file tree
Hide file tree
Showing 12 changed files with 800 additions and 45 deletions.
60 changes: 60 additions & 0 deletions .rustme/config.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Configuration(
files: {
"../README.md": (
for_docs: false,
sections: [
"header.md",
"docs.md",
"https://github.com/khonsulabs/.github/raw/main/snippets/readme-footer.md",
],
),
"../src/.crate-docs.md": (
for_docs: true,
sections: [
"docs.md",
"https://github.com/khonsulabs/.github/raw/main/snippets/readme-footer.md",
],
),
"../CONTRIBUTING.md": [
"https://github.com/khonsulabs/.github/raw/main/docs/CONTRIBUTING.md",
],
"../CODE_OF_CONDUCT.md": [
"https://github.com/khonsulabs/.github/raw/main/docs/CODE_OF_CONDUCT.md",
],
"../LICENSE-APACHE": [
"https://github.com/khonsulabs/.github/raw/main/licenses/LICENSE-APACHE",
],
"../LICENSE-MIT": [
"https://github.com/khonsulabs/.github/raw/main/licenses/LICENSE-MIT",
],
},
glossaries: [
"https://github.com/khonsulabs/.github/raw/main/snippets/glossary.ron",
{
"msrv": "1.65",
"ref-name": (
default: "main",
release: "v0.1.0",
),
"docs": (
default: "https://khonsulabs.github.io/FunnyBones/main/funnybones/",
release: "https://docs.rs/funnybones/",
),
"skeleton": (
default: "https://khonsulabs.github.io/FunnyBones/main/funnybones/struct.Skeleton.html",
release: "https://docs.rs/funnybones/*/funnybones/struct.Skeleton.html",
for_docs: "crate::Skeleton",
),
"joint": (
default: "https://khonsulabs.github.io/FunnyBones/main/funnybones/struct.Joint.html",
release: "https://docs.rs/funnybones/*/funnybones/struct.Joint.html",
for_docs: "crate::Joint",
),
"bone": (
default: "https://khonsulabs.github.io/FunnyBones/main/funnybones/struct.Bone.html",
release: "https://docs.rs/funnybones/*/funnybones/struct.Bone.html",
for_docs: "crate::Bone",
),
},
],
)
69 changes: 69 additions & 0 deletions .rustme/docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!-- This file is generated by `rustme`. Ensure you're editing the source in the .rustme/ directory --!>
<!-- markdownlint-disable first-line-h1 -->

![FunnyBones is considered experimental and unsupported](https://img.shields.io/badge/status-experimental-purple)
[![crate version](https://img.shields.io/crates/v/muse.svg)](https://crates.io/crates/funnybones)
[![Documentation for `$ref-name$`](https://img.shields.io/badge/docs-main-informational)]($docs$)

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][joint] 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][bone] 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`][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.

## FunnyBones in Action

The [`skeleton` example][skeleton-example] in the repository uses
[Cushy](https://github.com/khonsulabs/cushy) to draw and allow changing various
settings of a basic humanoid skeleton:

```rust,ignore
$../examples/skeleton.rs:readme$
```

<video src="https://raw.githubusercontent.com/khonsulabs/FunnyBones/gh-pages/20240815-1619-47.3700715.mp4" controls="true" autoplay="true" loop="true" muted="true"></video>

The example draws a small white circle where a desired location for a joint is.
FunnyBones ensures that all bones remain their original lengths while solving
the kinematics.

[skeleton]: $skeleton$
[joint]: $joint$
[bone]: $bone$
[skeleton-example]: https://github.com/khonsulabs/FunnyBones/tree/$ref-name$/examples/skeleton.rs
1 change: 1 addition & 0 deletions .rustme/header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# FunnyBones
128 changes: 128 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing to our projects

Thank you for your interest in contributing to one of our projects. We want
everyone to have a positive experience contributing, so please carefully review
our only requirements for contributing:

- All contributors must agree to [our Contributor License
Agreement](https://gist.github.com/ecton/b2e1e72abfa122da5e69ed30164f739e).
This will be asked for during your first pull request.
- All contributors must uphold the standards of our [Code of
Conduct](./CODE_OF_CONDUCT.md).

The rest of this document is recommendations/guidelines to help consistency and
communication within our projects.

## Creating Issues

### Reporting Bugs

To us, if something isn't behaving as you expect it to, that's a bug. Even if
it's misbehaving due to a misunderstanding, that means there's an opportunity to
improve our documentation or examples. Please don't hesitate to let us know if
you run into any issues while working with one of our projects.

### Requesting New Features

When requesting new features, please include details about what problem you're
trying to solve, not just a solution to your problem. By helping the community
understand the underlying problem, we can better evaluate what the best solution
to the problem might be.

## Contributing Changes

We openly welcome pull requests on our projects. We don't like bugs, and if
you've found one and wish to submit a fix, we greatly appreciate it.

If you find that fixing a bug requires a significant change, or you are wanting
to add a somewhat large feature, please submit a proposal as an issue first. We
want to make sure that your efforts have the highest chance of success, and a
short discussion before starting can go a long way towards a pull request being
merged with less revisions.

When working on an existing issue, update the issue to reflect that you're
working on it. This will help prevent duplicated efforts.

If you begin working on something but need some assistance, don't hesitate to
reach out inside of the issue, on [our
forums](https://community.khonsulabs.com/), or in [our
Discord](https://discord.khonsulabs.com/). We will do our best to help you.

### Project-specific requirements

Be sure to check if a project's README contains additional contributing
guidelines. Each project may have different tools and commands that should be
run to validate that changes pass all requirements.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[features]

[[example]]
name = "toy"
name = "skeleton"
required-features = ["cushy"]

[dependencies]
Expand Down
Loading

0 comments on commit f290765

Please sign in to comment.