// // $Id: HelicalSurface.cpp,v 1.8 2004/04/16 23:10:46 mikeh Exp $ // // File: CylindricalSurface.cpp // Purpose: // Created: 14-JUL-1999 A. Mayorov // // $Revision: 1.8 $ // // // Include files #include #include #include #include #include #include #include #include using namespace dgs; using namespace std; SpacePoint HelicalSurface::local_to_global(const HelicalCoordinate& lpt) const // // Purpose: Convert a local point to its equivalent in D0 space. // { CylindricalCoordinate pos(get_radius(),lpt.phi()+lpt.z()*_dphidz,lpt.z()); return GeometryElement::local_to_global(pos); } HelicalCoordinate HelicalSurface::global_to_local(const SpacePoint &gpt) const // // Purpose: Convert a global D0 point to its local equivalent // // mods: added a two-fiber slop to deciding whether or not a position is part // of this helical surface. Takes care of edge fuzziness in CFT ribbons // when using "real" misaligned geometry. Mike Hildreth 4/15/04 // { PureCylindricalCoordinate pos = GeometryElement::global_to_local(gpt); if(CylindricalSurface::onSurface(pos)) { double radius = pos.rxy(); double z = pos.z(); double phi0=_dphidz*z; double phi=pos.phi()-phi0; if(fabs(phi)<=_dphi+0.0016/radius) return HelicalCoordinate(phi,z); } return HelicalCoordinate(0.,-999); // throw OutOfSurface; } HelicalCoordinate HelicalSurface::global_to_local(double phi,double z) const // // Purpose: Convert a global D0 point to its local equivalent // { CylindricalPoint pos(get_r(phi,z),phi,z); return global_to_local(pos); } HelicalCoordinate HelicalSurface::xform_to_local(const GeometryXform& xf) const // // Purpose: Support positioning children on my surface. // { CartesianCoordinate offset(xf[0],xf[1],xf[2]); return global_to_local(offset); } GeometryXform HelicalSurface::local_to_xform(const HelicalCoordinate& lpt) const // // Purpose: Convert a point on myself to a geometry transform. The rotataion // portion gives a plane tangent to the surface. // { double phi=lpt.phi()+_dphidz*lpt.z(); double x=get_radius()*cos(phi); double y=get_radius()*sin(phi); // return GeometryXform(x,y,lpt.z(),halfpi+phi,halfpi,0.0); return GeometryXform(x,y,lpt.z(),phi,0.0,0.0); } bool HelicalSurface::resize(const double dr, const double dzhalf,const double dphi, const double ddphidz) // // Purpose: Change the size of the cylinder. If there are dependents, // move them if the radius changes. // States: // { if( CylindricalSurface::resize(dr,dzhalf)) { _dphi+=dphi; _dphidz+=ddphidz; return true; } return false; } bool HelicalSurface::position_child_at(const HelicalCoordinate& lpt, GeometryElement& kid) // // Purpose: Set a child's reference position // { if(onSurface(lpt)) { GeometryXform gxf = local_to_xform(lpt); gxf = get_position().apply(gxf); kid.set_position(gxf); return true; } return false; } bool HelicalSurface::onSurface(const HelicalCoordinate& lpt) const { PureCylindricalCoordinate pos(get_radius(),lpt.phi()+_dphidz*lpt.z(),lpt.z()); if(CylindricalSurface::onSurface(pos)&& ( fabs(lpt.phi())<=_dphi) ) return true; return false; } bool HelicalSurface::onSurface(const SpacePoint &gpt) const { PureCylindricalCoordinate pos = GeometryElement::global_to_local(gpt); if(CylindricalSurface::onSurface(pos)) { double z = pos.z(); double phi0=_dphidz*z; double phi=pos.phi()-phi0; if(fabs(phi)<=_dphi) return true; } return false; } //////////////////////////////////////////////////////////////////////// // std::ostream& dgs::operator <<(std::ostream& os, const HelicalSurface& me) // // Purpose: Text dump this instance. // States: // { os << "HelicalSurface, (radius,Zlen/2,phiWidth,dphi/dz)=(" << me.get_radius() << "," << me.get_zhalf() <<","<