2 Replies Latest reply: Oct 25, 2005 5:44 AM by Luc Van Linden

# distance and direction

Hi

How can I find distance and direction one point far from another? fro example point one is 32m north of point 2.

Thank you
Ali Taha

Message was edited by:
ataha
• ###### 1. Re: distance and direction
Ali,

As far as I know there is no built-in function to do this, although it would be a very handy addition and complement to the SDO_UTIL.POINT_AT_BEARING function. Doing this on a cartesian coord system is not very hard. But doing it on a geodetic system is beyond my experience.

Bryan
• ###### 2. Re: distance and direction
I do not have the time for testing but this should help you out:

This is a small piece out of the "centroid for a polyline function"
Re: Centroid of a Polyline

Luc

For non-geodetic 2D - points:

input my_geometry1, my_geometry2

DECLARE

my_XCoord2 REAL;
my_YCoord2 REAL;
my_XCoord1 REAL;
my_YCoord1 REAL;
pi CONSTANT REAL := 4 * ATAN(1);
my_DeltaX REAL;
my_DeltaY REAL;
my_Argument REAL;
my_TGOmega REAL;

BEGIN

my_XCoord1 := my_geometry1.SDO_POINT.X;
my_YCoord1 := my_geometry1.SDO_POINT.Y;
my_XCoord2 := my_geometry2.SDO_POINT.X;
my_yCoord2 := my_geometry2.SDO_POINT.Y;

my_DeltaX := my_XCoord2 - my_XCoord1;
my_DeltaY := my_YCoord2 - my_YCoord1;

IF (my_DeltaY = 0) THEN
IF (my_DeltaX > 0) THEN
my_Argument := pi / 2;
ELSE
my_Argument := 3 * (pi / 2);
END IF;
ELSE
my_TGOmega := ABS(my_DELTAX) / ABS(my_DeltaY);
IF (my_DeltaX > 0) THEN
IF (my_DeltaY > 0) THEN
my_Argument := ATAN(my_TGOmega);
ELSE
my_Argument := pi - ATAN(my_TGOmega);
END IF;
ELSE
IF (my_DeltaY > 0) THEN
my_Argument := 2 * pi - ATAN(my_TGOmega);
ELSE
my_Argument := pi + ATAN(my_TGOmega);
END IF;
END IF;
END IF;

return my_Argument;

END