packages/MC/geometry/Mesh_Geometry.cc
//---------------------------------------------------------------------------//
/*!
 * \brief Reflect the direction on a reflecting surface
 */
\brief Reflect the direction on a reflecting surface
\ brief Reflect the direction on a reflecting surface
bool Mesh_Geometry::reflect(Geo_State_t& state)
{
    using def::X; using def::Y; using def::Z;
    REQUIRE(soft_equiv(vector_magnitude(state.d_dir), 1.0, 1.0e-6));
    if( state.reflecting_face == Geo_State_t::NONE )
        return false;
    Space_Vector n = normal(state);
    double dot = state.d_dir[X]*n[X] +
                 state.d_dir[Y]*n[Y] +
                 state.d_dir[Z]*n[Z];
    CHECK( dot != 0.0 );
    state.d_dir[X] -= 2.0 * n[X] * dot;
    state.d_dir[Y] -= 2.0 * n[Y] * dot;
    state.d_dir[Z] -= 2.0 * n[Z] * dot;
    ENSURE(soft_equiv(vector_magnitude(state.d_dir), 1.0, 1.0e-6));
    return true;
}
bool Mesh_Geometry :: reflect ( Geo_State_t & state ) { using def :: X ; using def :: Y ; using def :: Z ; REQUIRE ( soft_equiv ( vector_magnitude ( state . d_dir ) , 1.0 , 1.0e-6 ) ) ; if ( state . reflecting_face == Geo_State_t :: NONE ) return false ; Space_Vector n = normal ( state ) ; double dot = state . d_dir [ X ] * n [ X ] + state . d_dir [ Y ] * n [ Y ] + state . d_dir [ Z ] * n [ Z ] ; CHECK ( dot != 0.0 ) ; state . d_dir [ X ] -= 2.0 * n [ X ] * dot ; state . d_dir [ Y ] -= 2.0 * n [ Y ] * dot ; state . d_dir [ Z ] -= 2.0 * n [ Z ] * dot ; ENSURE ( soft_equiv ( vector_magnitude ( state . d_dir ) , 1.0 , 1.0e-6 ) ) ; return true ; }
\brief Reflect the direction on a reflecting surface
\ brief Reflect the direction on a reflecting surface
// If we're not in a reflecting state, return // get the outward normal // calculate the dot-product of the incoming angle and outward normal