|
|
@ -0,0 +1,70 @@ |
|
|
|
|
|
# Rust playground |
|
|
|
|
|
|
|
|
|
|
|
Things I have recently done while learning the Rust programming language. |
|
|
|
|
|
|
|
|
|
|
|
## Synopsis |
|
|
|
|
|
|
|
|
|
|
|
Change in one of the toplevel subdirectories and try `cargo build` or |
|
|
|
|
|
`cargo run`. Maybe not everything is working oob. Feel free to fix whatever |
|
|
|
|
|
you want. |
|
|
|
|
|
|
|
|
|
|
|
## Description |
|
|
|
|
|
|
|
|
|
|
|
Various small examples I have tried while learning rust. The biggest and |
|
|
|
|
|
currently most active project is **fractional** which started as an |
|
|
|
|
|
implamentation of a rational number data type and then switched to a 3D |
|
|
|
|
|
math playground visualizing using **XCB** (in future it might also use |
|
|
|
|
|
a **HTML5 Canvas** for drawing as WebAssembly application. |
|
|
|
|
|
Using fractions with 3D math has several drawbacks: |
|
|
|
|
|
|
|
|
|
|
|
1. A huge part of 3D math is non rational, like sin, cos, tan and sqrt. |
|
|
|
|
|
2. The numerator and denominator tend to become very huge while nearing to non |
|
|
|
|
|
rational numbers and reduction is difficult and time consuming. |
|
|
|
|
|
3. Because of 2 it is way slower than the floating point calculation (at least |
|
|
|
|
|
with a decent coprocessor). |
|
|
|
|
|
|
|
|
|
|
|
Anyway, implementing the vector math stuff for both fractions and floating |
|
|
|
|
|
point was a nice playground for generics and traits. In future I might add |
|
|
|
|
|
another data type which implements the math as done by David Braben for the |
|
|
|
|
|
elite computer game. |
|
|
|
|
|
|
|
|
|
|
|
## Requirements |
|
|
|
|
|
|
|
|
|
|
|
### Always |
|
|
|
|
|
|
|
|
|
|
|
- A recent version of the Rust programming language as well as tooling. |
|
|
|
|
|
Currently I use Rust 1.39.0. |
|
|
|
|
|
|
|
|
|
|
|
### For fractional |
|
|
|
|
|
|
|
|
|
|
|
- A running X Server with **XCB** and **X11-SHM** extentions |
|
|
|
|
|
|
|
|
|
|
|
## Dependencies |
|
|
|
|
|
|
|
|
|
|
|
... |
|
|
|
|
|
|
|
|
|
|
|
## Contributing |
|
|
|
|
|
|
|
|
|
|
|
Feel free to make pull requests as you like, no guarantee that the will be |
|
|
|
|
|
added. |
|
|
|
|
|
|
|
|
|
|
|
## License |
|
|
|
|
|
|
|
|
|
|
|
Copyright © 2020 Georg Hopp |
|
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify |
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
|
|
|
|
(at your option) any later version. |
|
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
|
|
GNU General Public License for more details. |
|
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
|
|
|
|
|
|
|
|
## Author |
|
|
|
|
|
|
|
|
|
|
|
Georg Hopp <georg@steffers.org> |