// // $Id: AnnularSurfaceSection.cpp,v 1.8 2000/04/01 23:09:34 hobbs Exp $ // // File: AnnularSurfaceSection.cc // Purpose: Implement a phi slice on an annulus // Created: 08-OCT-1997 John Hobbs // // $Revision: 1.8 $ // // // Include files #include #include #include #include using namespace std; using namespace dgs; const double PI = 3.1415927; // Global definitions SpacePoint AnnularSurfaceSection::local_to_global(const CylindricalCoordinate& lpt) const // // Purpose: // { return GeometryElement::local_to_global(lpt); } CylindricalCoordinate AnnularSurfaceSection::global_to_local(const SpacePoint& gpt) const // // Purpose: // { CylindricalCoordinate undone = get_position().invert(gpt); double radius = undone.rxy(); double phi=undone.phi(); // Check radius if( radius>_rmax || radius<_rmin ) { std::cerr << "AnnularSurfaceSection::global_to_local, radius = " << radius << "outside range of [" << _rmin << "," << _rmax << "]" << endl; return CylindricalCoordinate(0.0,0.0,0.0); } // Check phi if( phi>_phimax ) { std::cerr << "AnnularSurfaceSection::global_to_local, phi = " << radius << "larger than maximum of " << _phimax << endl; return CylindricalCoordinate(0.0,0.0,0.0); } // OK return CylindricalCoordinate(radius,phi,0.0); } CylindricalCoordinate AnnularSurfaceSection::xform_to_local(const GeometryXform& xf) const // // Purpose: Convert a (local)transformation describing point on the disk to its // cylindrical coordinate equivalent // States: // { double radius = sqrt(xf[0]*xf[0]+xf[1]*xf[1]); double phi=atan2(xf[1],xf[0]); return CylindricalCoordinate(radius,phi,0.0); } GeometryXform AnnularSurfaceSection::local_to_xform(const CylindricalCoordinate& lpt) const // // Purpose: Convert a point on the disk to a transformation describing a // cartesian system whose x-y plane is parallel to the disk face, // whose z axis is the same as the disk, and whose y axis // points radially outward. // States: // { double x=lpt.x(); double y=lpt.y(); double phi = atan2(y,x); if(x == 0.0 && y == 0.0) phi = PI/2.0; double psi = (PI/2.0)-phi; return GeometryXform(x,y,lpt.z(),-psi,0.0,0.0); } // The non-virtual part of the expected interface bool AnnularSurfaceSection::resize(const double drmin, const double drmax, const double dphimax) // // Purpose: Change the size of a disk. Children are not moved. (Bounds check?) // States: // { _rmin += drmin; _rmax += drmax; _phimax += dphimax; // Range check needed? return true; } bool AnnularSurfaceSection::position_child_at( const CylindricalCoordinate& lpt, GeometryElement& kid) // // Purpose: Attach at child at the given position // States: // { GeometryXform gxf = local_to_xform(lpt); gxf = get_position().apply(gxf); kid.set_position(gxf); return true; } std::ostream& dgs::operator<<(std::ostream& os, const AnnularSurfaceSection& me) // // Purpose: Dump this instance to a text stream // States: // { os << "AnnularSurfaceSection (rmin,rmax,phimax)=(" << me._rmin << "," <