[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

missing function for LinRegChannels



PureBytes Links

Trading Reference Links

Hi 

Here is the missing function for the LinearRegresionChannels.



Have fun


Hans-Peter Moeckli
anatop@xxxxxxxxxxx


{Function name "pnt2line"
------------------------------------------------}
input: x1(numericsimple), y1(numericsimple), 
          x2(numericsimple), y2(numericsimple),
          x(numericsimple),   y(numericsimple);

{ returns the distance from (x,y) to the line formed by (x1,y1) (x2, y2) }

var: qq(0), m1(0), m2(0);

if x-x2 <> 0 then begin
m1 = (y1-y2) / (x1-x2);
m2 = (y-y2) / (x-x2);
qq = SquareRoot(Square(y-y2)+Square(x-x2));
value1 = qq * sine( arctangent( (m2-m1) / (1 + m1*m2)));
end else
value1 = 0;

pnt2line = value1;