Advertisement

help with distance formula when converting line equation in bisector form to implicit form

Started by March 05, 2016 08:13 PM
3 comments, last by snead 8 years, 11 months ago

I'm working my way through 3D Math Primer for Graphics and Game development 2nd edition and have a question about the following step at the end of section 9.2.3.

Can someone decipher what the following is doing for me?

d=(q+r)/2 dot [a b]

More details

The method starts off assuming you have a line defined as follows

distance(p,q) = distance(p,r)

where q and r are points that anchor the line such that the line is all points equidistant from q and r.

Towards converting this to implicit form, ax+by=d, the steps are:

a = q_y - r_y

b = r_x = q_x

d = (q+r)/2 dot [a b]

...

It's not clear to me what the dot product is doing here.

a = q_y - r_y looks like a scalar to me (which doesn't make sense for a dot product). Maybe you could post a screenshot of the page you're reading?

Advertisement

Hi Randy,

Attached is an image which preserves the math notation. Can you explain what the first d equation is doing?

Thanks

Oh now it makes sense, thanks for the image smile.png

a and b are scalars that form the vector rq, where rq = q - r, and points from r to q. If we do q + r / 2 we get the midpoint, which is on the bisector. If we dot rq with the midpoint we can solve for d in the equation ax + by = d. You can think of d as the distance of the plane to the origin along the normal [a, b], scaled by the length of [a, b].

Since we know the bisector is perpendicular to rq we can treat rq as the normal of the plane equation [a, b]. To solve for d, we just need to plug in any point on the bisector into the plane equation ax + by = d. x and y are chosen as the midpoint of r and q, since it is easy to calculate this midpoint.

Does this make sense?

Edit:

ax + by = [a, b] dot [x, y] = d

where [x, y] = (q + r) / 2

It does make sense now. Thanks!

For me to understand what they are doing more fully, I used your statement here

Since we know the bisector is perpendicular to rq we can treat rq as the normal of the plane equation [a, b]. To solve for d, we just need to plug in any point on the bisector into the plane equation ax + by = d. x and y are chosen as the midpoint of r and q, since it is easy to calculate this midpoint.

Expanded the details to the following:

Since we know the bisector is perpendicular to qr we can treat qr as one of the the normals n=[a,b] of the line equation. To solve for a,b we can calculate the normal as either (-dy,dx) or (dy,-dx) of qr. In the text they use (-dy,dx) hence

a = -(r_y-q_y) =q_y-r_y (as stated in text)

b = r_x - q_x (as stated in text)

So now at this point we have a normal and just need to calculate d. To solve for d, we just need to plug in any point on the bisector into the plane equation ax + by = d. x and y are chosen as the midpoint of r and q, since it is easy to calculate this midpoint.

ie

we have everything we need except d in:

ax + by = d or it's equivalent

p dot n = d

choosing the midpoint for p and [a b] above for n, d becomes:

d=(q+r)/2 dot [q_y-r_y, r_x-q_x] (as stated in text)

This topic is closed to new replies.

Advertisement