pub struct Line(pub Vector, pub Vector);
Expand description
Describe a line by its start and end Vector
respectively
A line can be constructed and used with tuples
use tile_net::{Line, Vector};
let start = Vector(0.5, 1.0);
let finish = Vector(1.2, -1.0);
let line = Line(start, finish);
assert_eq!(line.0, start);
assert_eq!(line.1, finish);
Tuple Fields§
§0: Vector
§1: Vector
Implementations§
source§impl Line
impl Line
sourcepub fn from_origin(p: Vector) -> Line
pub fn from_origin(p: Vector) -> Line
Create a line using its end-point, starting in (0, 0)
sourcepub fn supercover(&self) -> SuperCover ⓘ
pub fn supercover(&self) -> SuperCover ⓘ
Create a supercover line iterator
The supercover line covers all discrete blocks. It’s similar to Bresenham’s algorithm, but it includes the blocks that have been overlapped by a small portion of the line. The blocks are given by an integer boundary.
This particular algorithm is based off http://lodev.org/cgtutor/raycasting.html It is a ray tracer.
The created iterator leaps from the start to the end node. The intended use for this iterator is in finding a collision between a tile and a moving object.
Trait Implementations§
source§impl PartialEq<Line> for Line
impl PartialEq<Line> for Line
impl Copy for Line
impl StructuralPartialEq for Line
Auto Trait Implementations§
impl RefUnwindSafe for Line
impl Send for Line
impl Sync for Line
impl Unpin for Line
impl UnwindSafe for Line
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more