Version:

Calculate the distance between two sets of coordinates (points).

name | type | description |
---|---|---|

x1 | number |
The x coordinate of the first point. |

y1 | number |
The y coordinate of the first point. |

x2 | number |
The x coordinate of the second point. |

y2 | number |
The y coordinate of the second point. |

The distance between each point.

- number

Since: 3.0.0

Calculate the distance between two points.

name | type | description |
---|---|---|

a | Phaser.Types.Math.Vector2Like |
The first point. |

b | Phaser.Types.Math.Vector2Like |
The second point. |

The distance between the points.

- number

Since: 3.22.0

Calculate the squared distance between two points.

name | type | description |
---|---|---|

a | Phaser.Types.Math.Vector2Like |
The first point. |

b | Phaser.Types.Math.Vector2Like |
The second point. |

The squared distance between the points.

- number

Since: 3.22.0

Calculate the Chebyshev distance between two sets of coordinates (points).

Chebyshev distance (or chessboard distance) is the maximum of the horizontal and vertical distances. It's the effective distance when movement can be horizontal, vertical, or diagonal.

name | type | description |
---|---|---|

x1 | number |
The x coordinate of the first point. |

y1 | number |
The y coordinate of the first point. |

x2 | number |
The x coordinate of the second point. |

y2 | number |
The y coordinate of the second point. |

The distance between each point.

- number

Since: 3.22.0

Calculate the distance between two sets of coordinates (points) to the power of `pow`

.

name | type | description |
---|---|---|

x1 | number |
The x coordinate of the first point. |

y1 | number |
The y coordinate of the first point. |

x2 | number |
The x coordinate of the second point. |

y2 | number |
The y coordinate of the second point. |

pow | number |
The exponent. |

The distance between each point.

- number

Since: 3.0.0

Calculate the snake distance between two sets of coordinates (points).

Snake distance (rectilinear distance, Manhattan distance) is the sum of the horizontal and vertical distances. It's the effective distance when movement is allowed only horizontally or vertically (but not both).

name | type | description |
---|---|---|

x1 | number |
The x coordinate of the first point. |

y1 | number |
The y coordinate of the first point. |

x2 | number |
The x coordinate of the second point. |

y2 | number |
The y coordinate of the second point. |

The distance between each point.

- number

Since: 3.22.0

Calculate the distance between two sets of coordinates (points), squared.

name | type | description |
---|---|---|

x1 | number |
The x coordinate of the first point. |

y1 | number |
The y coordinate of the first point. |

x2 | number |
The x coordinate of the second point. |

y2 | number |
The y coordinate of the second point. |

The distance between each point, squared.

- number

Since: 3.0.0