crmaris
Newbie level 1
Hello. This is my first post to this community. The problem i face is the follow. I designed a network simulation program in Delphi. Lets say i have a node(root) with two child nodes. When i want to know what child is left and what child is right (i already know the x,y coordinates of the root and two childs) i use the following code in Delphi. My question is how i must change the following code in order to orientate multiple child nodes with reference one root node.Thanks.
function Orientation(x1, y1, x2, y2, Px, Py: Double): Integer;
var
Orin: Double;
begin
(* Linear determinant of the 3 points *)
Orin := (x2 - x1) * (py - y1) - (px - x1) * (y2 - y1);
if Orin > 0.0 then Result := +1 (* Orientaion is to the right-hand side *)
else if Orin < 0.0 then Result := -1 (* Orientaion is to the left-hand side *)
else
Result := 0; (* Orientaion is neutral if result is 0 *)
end;
function Orientation(x1, y1, x2, y2, Px, Py: Double): Integer;
var
Orin: Double;
begin
(* Linear determinant of the 3 points *)
Orin := (x2 - x1) * (py - y1) - (px - x1) * (y2 - y1);
if Orin > 0.0 then Result := +1 (* Orientaion is to the right-hand side *)
else if Orin < 0.0 then Result := -1 (* Orientaion is to the left-hand side *)
else
Result := 0; (* Orientaion is neutral if result is 0 *)
end;