coord 0.6.1

A simple, ergonomic vector mathematics crate
Documentation

Coord

Build Status Crates.io Downloads Docs

Description

Coord is a simple, ergonomic vector mathematics crate for Rust designed for use in game development, physics engines and other programs that deal with general-purpose multi-variable mathematics.

Coord is now no_std compatible!

Example

#[macro_use]
extern crate coord;
use coord::prelude::*;

fn main() {
	// Coord supports 4 multi-variable vector types: Vec1, Vec2, Vec3 and Vec4
	let mut v = vec3!(1.0, 2.5, 3.0);

	// Coord supports common mathematical operations for both primitive and vector types
	v += vec3![1.0; 3] * 5.0;
	let _ = v * vec3!([10.0, 10.0, 10.0]);

	// Coord implements many common mathematic functions
	let _ = v.length();
	let _ = v.normalize();

	// Coord supports debug and display printing of vectors
	println!("Debug => {:?}", v);
	println!("Display => {}", v);

	// Coord allows arbitrary vector component types
	let _ = vec2!(true, false); // Create a boolean vector
}

For more examples, visit https://docs.rs/coord

Features

  • Generic Vec1, Vec2, Vec3 and Vec4 types
  • Utility macros to make vector manipulation simpler
  • VecXu, VecXi and VecXf default type definitions
  • Basic mathematic operations (Add, Sub, Mul, Div)
  • Mathematic functions (i.e: .length(), .normalize(), etc.)

Coming Soon

  • Bitwise operations
  • More mathematic functions
  • Modulo operator for integer vector types

Using Coord

To use Coord in your Rust project, add the following line beneath the [dependencies] section in your Cargo.toml file.

coord = "0.7.0"

If you want to enable 64-bit defaults (i.e: types like Vec3i contains i64 instead of i32), you should specify the dependency like the following line instead.

[dependencies.coord]
version = "0.7.0"
features = ["large_defaults"]

FAQ

Why does Coord exist?

Coord came about as a result of a general dissatisfaction with existing vector mathematics libraries during development of the Veloren Project. Existing solutions were either too complicated, awkward to use, or required too many dependencies.

Does Coord aim to eventually implement feature X?

Coord does not aim to be a fully-blown N-dimensional mathematics library. It aims to implement a small yet elegant set of features that make it suitable for applications where simple multi-variable mathematics is required.

If you think feature X falls within that scope, and is not yet on the project todo list, you can open an issue on GitHub and I'll consider implementing it.

Why does Coord not have a general-purpose vec! macro?

Such a macro would conflict with the vec! macro within Rust's standard library.

Why does Coord not rely on the standard library?

It doesn't need to. Why limit the use cases of the library by requiring std?

Bug! Bug! I've found a bug!

Open an issue on Github and I'll fix it as soon as possible.

You can open an issue here

License

Coord is open source software, licensed under the MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)