MOAB: Mesh Oriented datABase  (version 5.2.1)
MBMesquite::CircleDomainTest Class Reference
+ Inheritance diagram for MBMesquite::CircleDomainTest:
+ Collaboration diagram for MBMesquite::CircleDomainTest:

Public Member Functions

void test_snap_to ()
void test_arc_length ()
void test_position_from_length ()

Private Member Functions

 CPPUNIT_TEST_SUITE (CircleDomainTest)
 CPPUNIT_TEST (test_snap_to)
 CPPUNIT_TEST (test_arc_length)
 CPPUNIT_TEST (test_position_from_length)
 CPPUNIT_TEST_SUITE_END ()

Detailed Description

Definition at line 38 of file CircleDomainTest.cpp.


Member Function Documentation

Definition at line 93 of file CircleDomainTest.cpp.

References MBMesquite::CircleDomain::arc_length(), ASSERT_NO_ERROR, center(), CPPUNIT_ASSERT_DOUBLES_EQUAL, MBMesquite::Vector3D::length(), origin, MBMesquite::Vector3D::to_array(), and z.

{
    MsqPrintError err( std::cerr );

    Vector3D origin( 0, 0, 0 );
    Vector3D z( 0, 0, 1 );
    double rad1 = 4.0 / 3.0;
    CircleDomain dom1( origin, z, rad1 );

    Vector3D xp = Vector3D( 1, 0, 0 );
    Vector3D xn = Vector3D( -1, 0, 0 );
    Vector3D yp = Vector3D( 0, 1, 0 );

    double len = dom1.arc_length( xp.to_array(), yp.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( rad1 * M_PI * 0.5, len, 1e-6 );

    len = dom1.arc_length( xp.to_array(), xn.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( rad1 * M_PI, len, 1e-6 );

    len = dom1.arc_length( yp.to_array(), xp.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( -rad1 * M_PI * 0.5, len, 1e-6 );

    len = dom1.arc_length( ( xp + z ).to_array(), yp.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( rad1 * M_PI * 0.5, len, 1e-6 );

    len = dom1.arc_length( xp.to_array(), ( yp + z ).to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( rad1 * M_PI * 0.5, len, 1e-6 );

    Vector3D center( -1, -2, -1 );
    Vector3D normal( -2, -1, -2 );
    double rad = 1.5;
    CircleDomain dom2( center, normal, rad );

    Vector3D v( 1, 0, 0 );
    v = v * normal;
    v *= rad / v.length();
    v += center;
    len = dom2.arc_length( v.to_array(), v.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, len, 1e-6 );
}

Definition at line 140 of file CircleDomainTest.cpp.

References ASSERT_NO_ERROR, center(), CPPUNIT_ASSERT_VECTORS_EQUAL, MBMesquite::Vector3D::length(), origin, MBMesquite::CircleDomain::position_from_length(), MBMesquite::Vector3D::to_array(), and z.

{
    MsqPrintError err( std::cerr );

    Vector3D origin( 0, 0, 0 );
    Vector3D z( 0, 0, 1 );
    double rad1 = 4.0 / 3.0;
    CircleDomain dom1( origin, z, rad1 );

    Vector3D xp = Vector3D( 1, 0, 0 );
    Vector3D xn = Vector3D( -1, 0, 0 );
    Vector3D yp = Vector3D( 0, 1, 0 );

    const double qc = 0.5 * rad1 * M_PI;

    Vector3D result;
    dom1.position_from_length( xp.to_array(), qc, result.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_VECTORS_EQUAL( yp * rad1, result, 1e-6 );

    dom1.position_from_length( xp.to_array(), 2 * qc, result.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_VECTORS_EQUAL( xn * rad1, result, 1e-6 );

    dom1.position_from_length( yp.to_array(), -qc, result.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_VECTORS_EQUAL( xp * rad1, result, 1e-6 );

    dom1.position_from_length( ( xp + z ).to_array(), qc, result.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_VECTORS_EQUAL( yp * rad1, result, 1e-6 );

    Vector3D center( -1, -2, -1 );
    Vector3D normal( -2, -1, -2 );
    double rad2 = 1.5;
    CircleDomain dom2( center, normal, rad2 );

    Vector3D v( 1, 0, 0 );
    v = v * normal;
    v *= rad2 / v.length();
    v += center;
    dom2.position_from_length( v.to_array(), 0.0, result.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_VECTORS_EQUAL( v, result, 1e-6 );
}

Definition at line 55 of file CircleDomainTest.cpp.

References CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_VECTORS_EQUAL, MBMesquite::Vector3D::length(), MBMesquite::length(), origin, MBMesquite::CircleDomain::snap_to(), and z.

{
    Vector3D origin( 0, 0, 0 );
    Vector3D z( 0, 0, 1 );
    double rad1 = 4.0 / 3.0;
    CircleDomain dom1( origin, z, rad1 );
    Vector3D pt( 1, 0, 0 );
    dom1.snap_to( 0, pt );
    CPPUNIT_ASSERT_VECTORS_EQUAL( Vector3D( rad1, 0, 0 ), pt, 1e-6 );
    Vector3D a = Vector3D( 1, 2, 3 );
    pt         = a;
    dom1.snap_to( 0, pt );
    a = Vector3D( 1, 2, 0 );
    a *= rad1 / a.length();
    CPPUNIT_ASSERT_VECTORS_EQUAL( a, pt, 1e-6 );

    Vector3D some_pt( 5, -1, 6 );
    Vector3D some_dir( -5, -4, 1 );
    double rad2 = 1.0;
    CircleDomain dom2( some_pt, some_dir, rad2 );

    a  = Vector3D( 0, 0, 0 );
    pt = a;
    dom2.snap_to( 0, pt );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( rad2, ( pt - some_pt ).length(), 1e-6 );   // rad from center
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, ( pt - some_pt ) % some_dir, 1e-6 );  // in plane
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, ( ( pt - some_pt ) * ( a - some_pt ) ) % some_dir,
                                  1e-6 );  // correct direction from center

    a  = Vector3D( 0, -1, -2 );
    pt = a;
    dom2.snap_to( 0, pt );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( rad2, ( pt - some_pt ).length(), 1e-6 );   // rad from center
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, ( pt - some_pt ) % some_dir, 1e-6 );  // in plane
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, ( ( pt - some_pt ) * ( a - some_pt ) ) % some_dir,
                                  1e-6 );  // correct direction from center
}

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines