# Thread: Find a cartesian line from distance of 4 points

1. ## Find a cartesian line from distance of 4 points

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?

2. 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. a2+b2=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
Code :
```-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 1 from 2
Code :
```2*a*hl = dB - dA
=> a = (dB - dA) / (2*hl)```
Subtracting 3 from 2
Code :
```2*b*hl = dB - dC
=> b = (dB - dC) / (2*hl)```
Code :
```-2*c = dA + dC
=> c = -(dA + dC) / 2```
Alternatively, adding 2 and 4 gives the same result:
Code :
```-2*c = dD + dB
=> c = -(dB + 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).

Note that if a2+b2 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.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•