//============================================================================= // // File: Trapezoid.cpp // Created: 5-DEC-1997 by Stephen Kahn // Purpose: provide Trapezoid methods // //============================================================================ #include #include #include using namespace dgs; // //Assesor functions // CartesianCoordinate Trapezoid::get_center() const { return _TrapCenter; } double Trapezoid::get_half_height() const { return _half_height; } double Trapezoid::get_inner_half_length() const { return _inner_half_length; } double Trapezoid::get_outer_half_length() const { return _outer_half_length; } double Trapezoid::get_inner_half_width() const { return _inner_half_width; } double Trapezoid::get_outer_half_width() const { return _outer_half_width; } // // local_to_global // SpacePoint Trapezoid::local_to_global(const CartesianCoordinate& lpt) const { return GeometryElement::local_to_global( lpt); } // // global_to_local // CartesianCoordinate Trapezoid::global_to_local(const SpacePoint& gpt) const { CartesianCoordinate lxyz = get_position().invert(gpt); return lxyz; } // // xform_to_local // Purpose : Convert a (local) transformation describing a point in // a trapezoid to its local cartesian coordinates // CartesianCoordinate Trapezoid::xform_to_local(const GeometryXform& xf) const { CartesianCoordinate lxyz( xf[0], xf[1], xf[2]); return lxyz; } // // local_to_xform // GeometryXform Trapezoid::local_to_xform(const CartesianCoordinate& lpt) const { return GeometryXform(lpt.x(),lpt.y(),lpt.z(),0.,0.,0.); } // // set_center_xyz // void Trapezoid::set_center_xyz() { CartesianCoordinate zero( 0., 0., 0.); SpacePoint gc = local_to_global( zero); CartesianCoordinate gcen( gc.x(), gc.y(), gc.z()); _TrapCenter = gcen; } void Trapezoid::set_center_xyz( double xx, double yy, double zz) { CartesianCoordinate center( xx, yy, zz); _TrapCenter = center; } // // set_Xform // void Trapezoid::set_Xform( double xx, double yy, double zz, double psi) { GeometryXform Tform( xx, yy, zz, 0., 0., -psi); GeometryElement::set_position( Tform); CartesianCoordinate zero( 0., 0., 0.); SpacePoint gc = local_to_global( zero); CartesianCoordinate gcen( gc.x(), gc.y(), gc.z()); _TrapCenter = gcen; } // // fill_Trapezoid // void Trapezoid::fill_Trapezoid( double dxi, double dxo, double dzi, double dzo, double dh) { _inner_half_width = dxi; _outer_half_width = dxo; _inner_half_length = dzi; _outer_half_length = dzo; _half_height = dh; } // // position_child_at // bool Trapezoid::position_child_at( const CartesianCoordinate& lpt, GeometryElement& kid) { GeometryXform gxf = local_to_xform(lpt); gxf = get_position().apply(gxf); kid.set_position(gxf); return true; } bool Trapezoid::position_child_at( const GeometryXform& lpt, GeometryElement& kid) { GeometryXform gxf = get_position().apply( lpt); kid.set_position(gxf); return true; }