Hi all!
I have square of size 2*hl with a center in (0,0).
A--------B
| |
| O |
| |
D--------C
And i have the minimal signed distance between A B C D and line. Can i find the cartesian représentation of this line only from these distances?
Hi all!
I have square of size 2*hl with a center in (0,0).
A--------B
| |
| O |
| |
D--------C
And i have the minimal signed distance between A B C D and line. Can i find the cartesian représentation of this line only from these distances?
Last edited by __bob__; 03-10-2016 at 02:39 AM.
If the line is defined by the implicit equation a*x+b*y=c (i.e. a*x+b*y-c=0) and the the normal vector (a,b) is normalised (i.e. a^{2}+b^{2}=1) then the signed distance of a point x,y from the line is just d=a*x+b*y-c.
If the distances from A,B,C,D are dA,dB,dC,dD, then you have
Subtracting 1 from 2Code :-a*hl + b*hl - c = dA (1) a*hl + b*hl - c = dB (2) a*hl - b*hl - c = dC (3) -a*hl - b*hl - c = dD (4)
Subtracting 3 from 2Code :2*a*hl = dB - dA => a = (dB - dA) / (2*hl)
Adding 1 and 3Code :2*b*hl = dB - dC => b = (dB - dC) / (2*hl)
Alternatively, adding 2 and 4 gives the same result:Code :-2*c = dA + dC => c = -(dA + dC) / 2
I.e. one of the distances is redundant; the mean of the distances for opposite corners must be equal (and is equal to the distance of the line from the origin).Code :-2*c = dD + dB => c = -(dB + dC) / 2
Note that if a^{2}+b^{2} isn't equal to 1, you still have the correct equation for the line; it just means that your signed "distances" include a scale factor.