Given two line equations in the form y = mx + c all of the points that are not in between of the two lines must be filtered out.
Currently I'm using a pass through filter, which approximately filters out the points. Instead, could this be done more precisely using the two line equations?
Suppose you have a line defined by
y = mx + c1and another, defined byy = mx + c2. As you can see, I assume themcoefficient to be identical for both lines, for otherwise the phrasewould be senseless.
Now, sort the lines so that
c2 <= c1, that isNow you're sure that the
c1line is equivalent to or above thec2line.Take any point (
xx,yy). Plugxxinto the equation of the 1st line,y = m * xx + c1. If the result is smaller thanyy, then (xx,yy) lies above thec1line. You should remove it from the cloud.Do the same with the c2 line:
y = m * xx + c2. If the result is larger than yy, the point (xx,yy) lies below linec2and should be removed from the set.In other words, you should keep those and only those points (x, y) that satisfy
Example:
Suppose you have
y = x + 3and y =x + 1. Suppose you have a point (2,4). Should you keep it or filter out?We have
c1= 3,c2= 1. Let's insert 2 to the first line. y = 1*2 + c1 = 5. 5 >= 4. The first test is passed.Now the second line. y = 1*2 + 1 = 3. 3 <= 4. The second condition is also satisfied. Conclusion: keep it, in full agreement with t he figure.