Home > Software engineering >  Beginner, teacher write a function that won't do.
Beginner, teacher write a function that won't do.

Time:09-22

The function FlowG () {
This. Nodes=Array (
{id: "node1," name: "01", "left" : 10, "top" : 110, "type" : "task", "width" : 104, "height" : 26, "marked" : true, "Alt" : true},
{id: "2", "name" : "02", "left" : 0, "top" : 0, "type" : "task", "width" : 104, "height" : 26, "marked" : true, "Alt" : true},
{id: "node3", "name" : "3", "left" : 364, "top" : 40, "type" : "task", "width" : 104, "height" : 26, "Alt" : true}
);
How to create a function LineNode ({x1, y1}, {x2, y2}, node), to determine line {x1, y1} {x2, y2} fellowship with whether the node,

CodePudding user response:

This is more like a c # code, their thinking is circular Nodes table, is actually three rectangular, judge the two points is a, a, if it is, intersection, if not, don't want to pay,
Judgment method: x & gt;=left & amp; & X & lt; Right & amp; & Y & gt;=top & amp; & Y & lt; Bottom;
C # and MFC seem to have PTinRect this function, use directly is more simple,

CodePudding user response:

A straight line to plane is divided into two areas A and B, if all four vertices A rectangular area is located in A region or B, then the straight line and rectangular disjoint, otherwise for fellowship, judge line starting point of the ends in A straight line on the same side or both sides, vector structure, calculate the cross product can,