16 lines
613 B
Zig
16 lines
613 B
Zig
const st = @import("structures.zig");
|
|
const Node = @import("infrastructure/node.zig").Node;
|
|
|
|
pub fn compareIntersections(ctx: *const Node, inter_a: st.IntersectionData, inter_b: st.IntersectionData) bool {
|
|
const distance_a = getRelativeInterDistance(ctx, inter_a);
|
|
const distance_b = getRelativeInterDistance(ctx, inter_b);
|
|
|
|
return distance_a < distance_b;
|
|
}
|
|
|
|
fn getRelativeInterDistance(ctx: *const Node, intersection: st.IntersectionData) f32 {
|
|
const x_diff = intersection.point.x - ctx.pos.x;
|
|
const y_diff = intersection.point.y - ctx.pos.y;
|
|
|
|
return x_diff * x_diff + y_diff * y_diff;
|
|
} |