Jump to content

isDiagonal


Recommended Posts

Posted

 

Checking if a position is diagonal from you current position

   boolean isDiagonal(Position position) {
        return Math.abs(position.getY() - position.getX()) == Math.abs(myPosition().getY() - myPosition().getX());
    }

Checking if two supplied positions are diagonal from each other

   boolean isDiagonal(Position one, Position two) {
        return Math.abs(one.getY() - one.getX()) == Math.abs(two.getY() - two.getX());
    }

 

This will return true if the positions are diagonal from each other(ignoring the plane)

  • Like 4

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...