pub struct Torus {
pub num_orbs: u8,
pub num_sats: u8,
}Expand description
A 2D toroidal grid.
Fields§
§num_orbs: u8Number of orbital planes.
num_sats: u8Number of satellites per orbital plane.
Implementations§
Source§impl Torus
impl Torus
Sourcepub const fn new(num_orbs: u8, num_sats: u8) -> Self
pub const fn new(num_orbs: u8, num_sats: u8) -> Self
Creates a new torus with the given dimensions.
Sourcepub fn neighbor(&self, point: Point, direction: Direction) -> Point
pub fn neighbor(&self, point: Point, direction: Direction) -> Point
Calculates the position of a neighbor in a given direction from a starting point.
Sourcepub fn prev(index: u8, modulus: u8) -> u8
pub fn prev(index: u8, modulus: u8) -> u8
Returns the previous index, wrapping around at modulus.
Sourcepub fn distance(from: u8, to: u8, modulus: u8) -> u8
pub fn distance(from: u8, to: u8, modulus: u8) -> u8
Returns the forward distance from from to to on a circular axis.
Sourcepub fn next_sat(&self, p: Point) -> u8
pub fn next_sat(&self, p: Point) -> u8
Returns the satellite index after p.sat, wrapping around.
Sourcepub fn prev_sat(&self, p: Point) -> u8
pub fn prev_sat(&self, p: Point) -> u8
Returns the satellite index before p.sat, wrapping around.
Sourcepub fn next_orb(&self, p: Point) -> u8
pub fn next_orb(&self, p: Point) -> u8
Returns the orbital plane index after p.orb, wrapping around.
Sourcepub fn prev_orb(&self, p: Point) -> u8
pub fn prev_orb(&self, p: Point) -> u8
Returns the orbital plane index before p.orb, wrapping around.
Sourcepub fn distance_orb(&self, from: Point, to: Point) -> u8
pub fn distance_orb(&self, from: Point, to: Point) -> u8
Returns the distance between two orbits.
Sourcepub fn distance_sat(&self, from: Point, to: Point) -> u8
pub fn distance_sat(&self, from: Point, to: Point) -> u8
Returns the distance between two satellites.
Sourcepub fn direction_to_sat(&self, from: Point, to: Point) -> Direction
pub fn direction_to_sat(&self, from: Point, to: Point) -> Direction
Returns the direction to move from from to to along the satellite axis.
Sourcepub fn direction_to_orb(&self, from: Point, to: Point) -> Direction
pub fn direction_to_orb(&self, from: Point, to: Point) -> Direction
Returns the direction to move from from to to along the orbital plane axis.