Struct tile_net::Line

source ·
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

source

pub fn from_origin(p: Vector) -> Line

Create a line using its end-point, starting in (0, 0)

source

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 Clone for Line

source§

fn clone(&self) -> Line

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Line

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<Line> for Line

source§

fn eq(&self, other: &Line) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Line

source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.