Class ChainCodesDirection
Object
ChainCodesDirection
Maps directions to chain codes and vice versa.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The maximum value for a chain code, corresponding to code 0. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
chainCode
(int x, int y, int z) Encodes a direction into a chain code.static Point3i
decode
(int chainCode) Decodes a chain-code into a point.static int
xFromChainCode
(int chainCode) Extracts the x-component from a chain code.static int
yFromChainCode
(int chainCode) Extracts the y-component from a chain code.static int
zFromChainCode
(int chainCode) Extracts the z-component from a chain code.
-
Field Details
-
MAX_VALUE
public static final int MAX_VALUEThe maximum value for a chain code, corresponding to code 0.- See Also:
-
-
Method Details
-
decode
Decodes a chain-code into a point.TODO is it a good idea to cache the creation of chain codes, to avoid work on the heap? There is a finite number.
- Parameters:
chainCode
- the chain-code to decode- Returns:
- a new
Point3i
(always newly created) for the given chain-code
-
chainCode
public static int chainCode(int x, int y, int z) Encodes a direction into a chain code.- Parameters:
x
- the x-component of the direction (-1, 0, or 1)y
- the y-component of the direction (-1, 0, or 1)z
- the z-component of the direction (-1, 0, or 1)- Returns:
- the encoded chain code
-
xFromChainCode
public static int xFromChainCode(int chainCode) Extracts the x-component from a chain code.- Parameters:
chainCode
- the chain code to decode- Returns:
- the x-component of the direction (-1, 0, or 1)
-
yFromChainCode
public static int yFromChainCode(int chainCode) Extracts the y-component from a chain code.- Parameters:
chainCode
- the chain code to decode- Returns:
- the y-component of the direction (-1, 0, or 1)
-
zFromChainCode
public static int zFromChainCode(int chainCode) Extracts the z-component from a chain code.- Parameters:
chainCode
- the chain code to decode- Returns:
- the z-component of the direction (-1, 0, or 1)
-