From 9b9d4cdc460a4fab20ce36cc53a79c3e42a6fdc5 Mon Sep 17 00:00:00 2001 From: William Joye Date: Thu, 25 Jan 2018 17:11:07 -0500 Subject: issue with 3d az_||el_ at 90deg --- tksao/frame/fr3dmap.C | 35 +++++++++++++++++++++-------------- tksao/frame/frmap.C | 3 ++- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/tksao/frame/fr3dmap.C b/tksao/frame/fr3dmap.C index 53fc2c8..5e6a8c6 100644 --- a/tksao/frame/fr3dmap.C +++ b/tksao/frame/fr3dmap.C @@ -66,16 +66,6 @@ Vector3d Frame3dBase::mapToRef3d(const Vector& vv, Coord::InternalSystem sys, break; } - // note: sl is in REF=DATA coordinates - Vector3d xx = Vector3d(1,0,sl)*refToWidget3d; - Vector3d yy = Vector3d(0,1,sl)*refToWidget3d; - Vector3d oo = Vector3d(0,0,sl)*refToWidget3d; - - Vector3d ii=xx-oo; - Vector3d jj=yy-oo; - Vector3d nn = cross(jj,ii).normalize(); - double dd = -(nn*xx); - Vector ww; switch (sys) { case Coord::WIDGET: @@ -94,11 +84,28 @@ Vector3d Frame3dBase::mapToRef3d(const Vector& vv, Coord::InternalSystem sys, ww = vv*magnifierToWidget; break; default: - // na - break; + // should not happen + return Vector3d(); } + // note: sl is in REF=DATA coordinates + Vector3d xx = Vector3d(1,0,sl)*refToWidget3d; + Vector3d yy = Vector3d(0,1,sl)*refToWidget3d; + Vector3d oo = Vector3d(0,0,sl)*refToWidget3d; + + Vector3d ii=xx-oo; + Vector3d jj=yy-oo; + Vector3d nn = cross(jj,ii).normalize(); + double dd = -(nn*xx); + double zz = (-nn[0]*ww[0]-nn[1]*ww[1]-dd) / nn[2]; - return Vector3d(ww,zz)*widgetToRef3d; -} + Vector3d rr = Vector3d(ww,zz)*widgetToRef3d; + + // if othogonal, set to center + if (teq(az_,M_PI_2,.001) || teq(az_,3*M_PI_2,.001)) + rr[0] = vp_[0]; + if (teq(el_,M_PI_2,.001) || teq(el_,3*M_PI_2,.001)) + rr[1] = vp_[1]; + return rr; +} diff --git a/tksao/frame/frmap.C b/tksao/frame/frmap.C index a305914..93f9b96 100644 --- a/tksao/frame/frmap.C +++ b/tksao/frame/frmap.C @@ -133,7 +133,8 @@ Vector FrameBase::mapFromRef(const Vector& vv, Coord::InternalSystem sys) return vv * refToPanner; case Coord::MAGNIFIER: return vv * refToMagnifier; - default: + case Coord::PS: + // should not happen return Vector(); } } -- cgit v0.12