4 |
|
|
5 |
namespace Coords { |
namespace Coords { |
6 |
DBGVAR(dbg, "Coords.general"); |
DBGVAR(dbg, "Coords.general"); |
7 |
|
DBGVAR(dbg_buoy, "Coords.buoy"); |
8 |
|
|
9 |
// The (STL-like) concept of transform: |
// The (STL-like) concept of transform: |
10 |
// enum { NParams = n }; |
// enum { NParams = n }; |
299 |
float c = amc.dot(amc) - radius*radius; |
float c = amc.dot(amc) - radius*radius; |
300 |
|
|
301 |
float det = b*b - 4*a*c; |
float det = b*b - 4*a*c; |
302 |
|
|
303 |
|
DBG(dbg_buoy) << "eq: "<<anchor<<" "<<amc<<" "<<v<<" "<<a<<" "<<b<<" "<<c<<"\n"; |
304 |
|
|
305 |
if(det <= 0) { |
if(det <= 0) { |
306 |
tr = ZVec(0,0,0); |
tr = ZVec(0,0,0); |
307 |
|
DBG(dbg_buoy) << "No solution - zero\n"; |
308 |
return; |
return; |
309 |
} |
} |
310 |
float ans = (-b + sqrt(det)) / (2*a); |
float ans = (-b + sqrt(det)) / (2*a); |
311 |
ZPt pt = proj + ans * v; |
ZPt pt = proj + ans * v; |
312 |
|
|
313 |
|
DBG(dbg_buoy) << "solution: "<<pt<<"\n"; |
314 |
tr = pt; |
tr = pt; |
315 |
} |
} |
316 |
virtual CoordSys *createInverse() { |
virtual CoordSys *createInverse() { |