Tiny BASIC

Interpreter and Compiler Project

Euclidean Distance Calculation

Download: distance.bas
Size 0kb, downloads 714.

This subroutine calculates the Euclidean distance ("as the crow flies") between two points on a flat plane. The coordinates should be in the variables V, W, X and Y, representing the points (v,w) and (x,y). The variable U will be trashed for temporary workspace, and Z will hold the distance.

It is important to note that because of TinyBASIC's reliance on integer arithmetic, and the lack for mathematical functions like square root, the result will be approximate.

Comments

New Comment

Yes No