You are here: Surpac Concepts > Macros > SCL > Geometry and Maths > SclBearingDistance
GEOVIA Surpac

SclBearingDistance

Overview

You can use SclBearingDistance to calculate the bearing (in radians) and distance between two points defined by their X and Y coordinates.

Synopsis

SclBearingDistance $x1 $y1 $x2 $y2 bearing distance

Description

Calculate the bearing and distance between the points defined by the coordinates x1,y1 and x2,y2.

Arguments

  • x1, y1
  • Pass by value. The X and Y coordinates of the first point.

  • x2, y2
  • Pass by value. The X and Y coordinates of the second point.

  • bearing
  • Pass by reference. This variable is assigned the bearing from the first point to the second point. Note that the variable is expressed in radians and will be in the range of 0 to 2 PI radians.

  • distance
  • Pass by reference. This variable is assigned the distance between the two points.

Returns

Nothing.

Examples

set x1 0.0
set y1 0.0
set x2 100.0
set y2 0.0
SclBearingDistance $x1 $y1 $x2 $y2 brg dist
puts "The bearing from ($x1,$y1) to ($x2,$y2) = [SclExpr $brg / $SCL_PI * 180.0] degrees, \
distance = $dist"