# Distance to Nearest Quad Edge

1. Jan 24, 2010

### rebeka

From this example

Anti-Aliasing section 22.4.1
http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter22.html [Broken]

what does the following equation represent and how was it derived?

$$k = \frac{2}{(2r+w)\sqrt{(x_0 - x_1)^2 - (y_0 - y_1)^2}}$$

I assume the 4 sets of linear equation coefficients are slope formula derivatives but I can't quite work it out! I assume there is something of a dot product going on in there but I'm really having a hard time putting it together and I won't use something in code(home project) until I understand it completely!

Thanks for any input,

Last edited by a moderator: May 4, 2017
2. Jan 25, 2010

### rebeka

I mean just for starters $$\frac{2}{r+2w} = \frac{1}{w}$$ looks to be $$\frac{1}{|\vec{U}|}$$ and $$\frac{1}{\sqrt{(x_0-x_1)^2 - (y_0-y_1)^2}}$$ looks to be $$\frac{1}{|\vec{V}|}$$ except that there's a negative in there??? A few thoughts on that, inverted y screen coordinate <= probably not -.- ok one thought....

So then with $$\vec{e}$$ plugging the k into the first two coefficients of each looks to be just missing the $$\vec{U}$$ or $$\vec{V}$$ from a $$cos\theta$$! The missing is obviously filled in when $$d_n = (x,y,1)\cdot\vec{e}$$ is expanded(proper wording??)..... but what is the determinant of the major line doing being added to one and divided by the product of the magnitudes??? And why is the resultant like two rotations and a magnitude(guessing)....

The one text I have Linear Algebra and Differential Equations says the following about a distance to a point:

The distance to a point $$d(U,V) = |\vec{U}-\vec{V}|$$ and well I have a really hard time reading Bernsteins Matrix Mathematics but if anyone knows something I should read in there :D

I could be on this one for a while.....

3. Jan 25, 2010

### Zaphos

re the negative -- that equation is going to put a negative number in the square root whenever the line changes more in y than x? So, I'm guessing it's a typo and they mean + not - ...

4. Jan 26, 2010

### rebeka

'tis true.... o-o