dartsmanMember Posts: 484 From: Queensland, Australia Registered: 03-16-2006 |
I'm trying to write a function for returning the closest point on 2D implicit line... I have an equation from "3D Math Primer for Graphics and Game Development", but it doesn't seem to mention a certain variable... equation is (Equation 13.1 in the book): q' = q + (d - q.n)n where q is the point to test to the line the issue is that d is not explained, if I had d then I could easily project it from q with (n * -1) to get the point on the line... but it doesn't explain d. in chapter 13.3 "Closest point on Plane" it says that "We learned how to compute the distance from a point to a plane in Section 12.5.4" but when I checked out 12.5.4 it gives me the equation (12.14): a = q.n - d but again, doesn't explain what d is... any help would be good thanks, I'm sure I'm just missing something. I've read through the sections but I couldn't find anything, except for... "If we assume n is a unit vector, then the distance from p to q (and thus, the distance from q to the plane) is simply a." but to get a, I need d?? this is weird... lol ------------------ |

HanClintoAdministrator Posts: 1828 From: Indiana Registered: 10-11-2004 |
Hey Dartsman! Crazy -- I've read your post a couple of times, and I'm having a bit of trouble understanding it (though I'm not sure any worse than you are). It sounds like you've got a line in 3d space, and you have another point that is your target, and so you're trying to solve for the nearest point to the target that is a point on the original line. If that's the case, you may find the Mathworld explanation helpful: I've learned a fair bit of math from that site -- particularly having to do with things like fractals and soddy circles. Really great stuff, I highly recommend it. Does that help at all? Or am I completely off base? --clint Edit: Oh yeah -- BTW, here's their formula for [This message has been edited by HanClinto (edited July 31, 2006).] |

dartsmanMember Posts: 484 From: Queensland, Australia Registered: 03-16-2006 |
close clint... though with that line, it is illustrated via two points. which would be fine I guess, except I'm wanting to do it via a point (point on the line) and then a normal, and for 2d if that helps make it any easier... so a line would look something like this: vector2d point; // vector2d would just be a float x, y; and then the point would just be a vector2d. you could think of it as like a 2d plane of sorts... sort of like a ray, but bi-directional. I was considering just doing 2 ray checks, but it would be a lot better if I could just figure out what that 'd' from "3D Math Primer..." was on about. Would you happen to have an equation for closest point to 3d plane?? where the plane is illustrated as similar to the line (above) but with vector3d (float x, y, z) for the point and normal. I'm checking out that site atm, thanks for the link. When you going on your trip? Hope you have a great time. ------------------ |

HanClintoAdministrator Posts: 1828 From: Indiana Registered: 10-11-2004 |
Hey Dartsman! Though there is also: Leaving for Ghana tomorrow evening -- pretty exciting schtuff. --clint |

dartsmanMember Posts: 484 From: Queensland, Australia Registered: 03-16-2006 |
Ah, problem solved... Thanks for you help clint, but I just backtracked through the book (3D Math Primer) to section 12.2.3 to discover d is the "signed distance from the origin to the line"... Thanks again though for your help. Have a great holiday!!! ------------------ |