Is there an integer version of CompareAngle that avoids using floats?

I’ve implemented a method that compares the angles formed at root between the vector to reference and two other points p1 and p2:

// Compares the angles formed at ‘root’ between the vector to ‘reference’ and two other points ‘p1’ and ‘p2’.
// Returns:
// 0 => delta angles are equal
// -1 => delta angle to ‘p1’ is smaller than angle to ‘p2’
// +1 => delta angle to ‘p1’ is larger than angle to ‘p2’

int CompareAngle(Int2 root, Int2 reference, Int2 p1, Int2 p2)
{
    // Vectors from root to p1 and p2
    var vx1 = p1.x - root.x;
    var vy1 = p1.y - root.y;

    var vx2 = p2.x - root.x;
    var vy2 = p2.y - root.y;

    // Reference vector
    var vrx = reference.x - root.x;
    var vry = reference.y - root.y;

    // Compute signed angles relative to reference vector using atan2
    var angle1 = Math.Atan2(vy1 * vrx - vx1 * vry, vx1 * vrx + vy1 * vry); // angle between reference and p1
    var angle2 = Math.Atan2(vy2 * vrx - vx2 * vry, vx2 * vrx + vy2 * vry); // angle between reference and p2

    // Compare absolute angles
    var diff = Math.Abs(angle1) - Math.Abs(angle2);

    if (Math.Abs(diff) < double.Epsilon)
        return 0;

    return diff < 0 ? -1 : 1;
}

All inputs are integer-based (Int2), and I’d like the calculation to avoid using floats or atan2 for performance and precision reasons.

Does A* provide an integer-based version of CompareAngle,

If there isn’t an existing integer-based version of CompareAngle, can you provide some ideas on how to implement it?

This is not really related to A*, but you can use

VectorMath.Right(root, p1, p2) or VectorMath.RightOrColinear(root, p1, p2)

Check the source code for them, it’s a very simple one-line implementation.

It’s not just about using Right or RightOrCollinear, since this involves comparing the delta angles.

For example:
root = (0, 0)
reference = (1, 1)
p1 = (0, 1)
p2 = (1, 0)

In this case, the method should return 0, because both delta angles are 45°, even though they are in opposite directions.

I suggest you seek answers on some general programming forum. As I said, this is not related to the A* package.

There’s nothing built-in for this in the package.