# Collide: Ray
[](https://crates.io/crates/collide-ray)
[](https://docs.rs/collide-ray)
Ray type for the [collide](https://crates.io/crates/collide) ecosystem. Dimension-generic (2D/3D/N-D).
Defines a ray (origin + direction) with sphere intersection support. Shape crates implement `Collider<Ray>` for their types via the `ray` feature flag.
## Usage
```rust
use collide_ray::Ray;
let ray = Ray::new(origin, direction);
if let Some((parameter, info)) = ray.intersect_sphere(center, radius) {
// parameter is the distance along the ray
}
```
## Ray Support in Shape Crates
Enable `ray` feature on shape crates to get `Collider<Ray>` implementations:
```toml
collide-capsule = { version = "...", features = ["ray"] }
collide-convex = { version = "...", features = ["ray"] }
collide-sphere = { version = "...", features = ["ray"] }
```