Dposline(Function)
Get the shortest distance between the specified line and 2 points.
Dposline(<X Coordinate>, <Y Coordinate>, <Straight Line Component>)
Parameters
<X Coordinate>
|
X coordinate of the points to get the distance (double-precision).
|
<Y Coordinate>
|
Y coordinate of the points to get the distance (double-precision).
|
<Straight Line Component>
|
Parameter array of the straight line to get the distance (double-precision type array).
|
Return Value
Returns the value of the double-precision type number.
The content of the value is the shortest distance between the points and straight line.
Description
Specify the points to get the distance in <X Coordinate> and <Y Coordinate>.
The parameters a, b and c that make up the straight line ax+by+c=0 are stored in <Straight Line Component>."a" to "c" are each stored in array elements 0 to 2.
This is mainly used to get the variance and deviation of the basic points with regard to lines gotten by
the Lsqumeth command.
Example
Get the variance and deviation with respect to the straight lines gotten from the 4 points.(Please refer to the Lsqumeth command for the method of determining a straight line).)
Dim POSX#(3),POSY#(3),PARM#(2),DIST#(3)
'Initialize the line
For I&=0 To 3
GetUnitData I&+1,"X",POSX#(I&)
GetUnitData I&+1,"Y",POSY#(I&)
Next
'Calculate the component of line
Lsqumeth 4,POSX#(),POSY#(),PARM#()
SUMDIST#=0
For I&=0 To 3
'Calculate the shortest distance between the straight line and point.
DIST#(I&)=Dposline(POSX#(I&),POSY#(I&),PARM#())
SUMDIST#=SUMDIST#+DIST#(I&)
Next
'Output the average distance between the straight line and point.
DrawTextG "Distance Variance:",100,100,0
DrawTextG Str2$(SUMDIST#*SUMDIST#,5,3,0,0),280,100,0
DrawTextG "Distance Deviation:",100,150,0
DrawTextG Str2$(SUMDIST#,3,3,0,0),280,150,0
Erase POSX#(),POSY#(),PARM#(),DIST#()