mini_collide/line.rs
1use mini_math::{Point, Vector3};
2
3/// An infinite line.
4#[derive(Debug)]
5pub struct Line {
6 /// An arbitrary point on the line.
7 pub point: Point,
8 /// The direction of the line.
9 pub direction: Vector3,
10}
11
12impl Line {
13 /// Construct a line from a point on the line and its direction.
14 pub fn new(point: Point, direction: Vector3) -> Self {
15 Self { point, direction }
16 }
17
18 /// Construct a line from two points on the line.
19 pub fn from_points(start: Point, end: Point) -> Self {
20 Self {
21 point: start,
22 direction: (end - start).normalized(),
23 }
24 }
25}