Skip to content

Instantly share code, notes, and snippets.

@DavidMcLaughlin208
DavidMcLaughlin208 / IterateBetweenTwoPointsOnMatrix.java
Last active June 9, 2024 16:49
Algorithm to move from one point on a 2D matrix to another in the shortest most logical route
public void iterateAndApplyMethodBetweenTwoPoints(Vector2 pos1, Vector2 pos2, Supplier<FunctionInput> function) {
// If the two points are the same no need to iterate. Just run the provided function
if (pos1.epsilonEquals(pos2)) {
function.invoke();
return;
}
int matrixX1 = pos1.x;
int matrixY1 = pos1.y;
int matrixX2 = pos2.x;
@ciembor
ciembor / gist:1494530
Created December 18, 2011 21:28
RGB to HSL and HSL to RGB conversion functions
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
typedef struct rgb {
float r, g, b;
} RGB;
typedef struct hsl {
float h, s, l;
} HSL;