Class TriadCoords
java.lang.Object
uk.ac.manchester.spinnaker.machine.board.TriadCoords
- All Implemented Interfaces:
Comparable<TriadCoords>
public final class TriadCoords extends Object implements Comparable<TriadCoords>
Triad coordinates.
Boards are in groups of three (triads) that group together in a rectangular
grid. The
x
and y
coordinates say which group of three in the
grid, and the z
coordinate says which board within the group. The
group is not itself rectangular, but tesselates on a rectangular grid.
To understand how the triad coordinate system works, consider this board layout (a classic 24 board machine, with wrap-arounds not shown):
Serialisation Formats
Defaults to being serialised as a JSON object:{"x": 3, "y": 2, "z": 1}and can also be deserialized from that, but can also accept being deserialised from a JSON array:
[3, 2, 1]and can also be deserialized from its string form:
[x:3,y:2,z:1]
- Author:
- Donal Fellows
-
Field Summary
-
Constructor Summary
Constructors Constructor Description TriadCoords(int x, int y, int z)
Create an instance.TriadCoords(String serialForm)
Create an instance from its serial form. -
Method Summary
Modifier and Type Method Description ChipLocation
asChipLocation()
Convert these coordinates into a machine-global chip location.int
compareTo(TriadCoords other)
boolean
equals(Object obj)
int
hashCode()
String
toString()
-
Field Details
-
Constructor Details
-
TriadCoords
public TriadCoords(int x, int y, int z)Create an instance.- Parameters:
x
- X coordinate.y
- Y coordinate.z
- Z coordinate.
-
TriadCoords
Create an instance from its serial form. The serial form (where the numbers may vary) is:[x:3,y:5,z:2]
- Parameters:
serialForm
- The form to deserialise.- Throws:
IllegalArgumentException
- If the string is not in the right form.
-
-
Method Details
-
asChipLocation
Convert these coordinates into a machine-global chip location.- Returns:
- The chip location relative to the root of the machine.
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<TriadCoords>
-