/[gzz]/gzz/gfx/libcoords/Coords.cxx
ViewVC logotype

Diff of /gzz/gfx/libcoords/Coords.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.29 by tjl, Thu Oct 3 12:12:53 2002 UTC revision 1.30 by tjl, Thu Oct 3 16:50:30 2002 UTC
# Line 274  namespace Coords { Line 274  namespace Coords {
274       * can't be implemented as a TransformCoordSys.       * can't be implemented as a TransformCoordSys.
275       * <p>       * <p>
276       * Parameter layout:       * Parameter layout:
277       *  x_circle, y_circle, radius, x_projpoint, y_projpoint       *  x_circle, y_circle, radius, x_projpoint, y_projpoint, pointdir
278         *  <p>
279         *  Pointdir = 0 -> place at center, pointdir = 1, place
280         *  normally, -1, place with projpoint = center+(center-projpoint)
281         *  Linear interp between 0..1, 0..-1
282       */       */
283      class BuoyOnCircleCoords : public CoordSys {      class BuoyOnCircleCoords : public CoordSys {
284          ZVec tr;          ZVec tr;
285      public:      public:
286          BuoyOnCircleCoords() : tr() { }          BuoyOnCircleCoords() : tr() { }
287          BuoyOnCircleCoords(ZVec tr) : tr(tr) { }          BuoyOnCircleCoords(ZVec tr) : tr(tr) { }
288          enum { NParams = 5 };          enum { NParams = 6 };
289          virtual void setParams(float *params) {          virtual void setParams(float *params) {
290                float pointdir = params[5];
291              ZVec ctr(params[0], params[1], 0);              ZVec ctr(params[0], params[1], 0);
292              ZVec proj(params[3], params[4], 0);              ZVec proj(params[3], params[4], 0);
293              float radius = params[2];              float radius = params[2];
294    
295                if(pointdir < 0) {
296                    proj = ctr + (ctr - proj);
297                    pointdir = -pointdir;
298                }
299    
300              // Get the anchor of the buoy              // Get the anchor of the buoy
301              ZPt anchor = super->transform(ZPt(0,0,0));              ZPt anchor = super->transform(ZPt(0,0,0));
302              // Now that we have the anchor, project              // Now that we have the anchor, project
# Line 302  namespace Coords { Line 312  namespace Coords {
312    
313              DBG(dbg_buoy) << "eq: "<<anchor<<" "<<amc<<" "<<v<<" "<<a<<" "<<b<<" "<<c<<"\n";              DBG(dbg_buoy) << "eq: "<<anchor<<" "<<amc<<" "<<v<<" "<<a<<" "<<b<<" "<<c<<"\n";
314    
315                ZPt pt;
316              if(det <= 0) {              if(det <= 0) {
317                  tr = ZVec(0,0,0);                  pt = ZVec(0,0,0);
318                  DBG(dbg_buoy) << "No solution - zero\n";                  DBG(dbg_buoy) << "No solution - zero\n";
319                  return;              }  else {
320              }                  float ans = (-b + sqrt(det)) / (2*a);
321              float ans = (-b + sqrt(det)) / (2*a);                  pt = proj + ans * v;
322              ZPt pt = proj + ans * v;                  DBG(dbg_buoy) << "solution: "<<pt<<"\n";
323                }
324    
325                tr = ctr + pointdir * (pt-ctr);
326                DBG(dbg_buoy) << "final: "<<tr<<"\n";
327    
             DBG(dbg_buoy) << "solution: "<<pt<<"\n";  
             tr = pt;  
328          }          }
329          virtual CoordSys *createInverse() {          virtual CoordSys *createInverse() {
330              return new BuoyOnCircleCoords(-tr);              return new BuoyOnCircleCoords(-tr);

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26