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

Public Member Functions

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

Private Member Functions

 CPPUNIT_TEST_SUITE (LineDomainTest)
 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 LineDomainTest.cpp.


Member Function Documentation

Definition at line 75 of file LineDomainTest.cpp.

References MBMesquite::LineDomain::arc_length(), ASSERT_NO_ERROR, CPPUNIT_ASSERT_DOUBLES_EQUAL, MBMesquite::Vector3D::length(), and MBMesquite::Vector3D::to_array().

{
    MsqPrintError err( std::cerr );

    const Vector3D base1( 1, 1, 1 );
    const Vector3D dir1( -1, -2, -3 );
    LineDomain dom1( base1, dir1 );

    double l1 = 1.0, l2 = M_PI;
    Vector3D p1 = base1 + l1 / dir1.length() * dir1;
    Vector3D p2 = base1 + l2 / dir1.length() * dir1;
    double len  = dom1.arc_length( p1.to_array(), p2.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( l2 - l1, len, 1e-6 );
    len = dom1.arc_length( p2.to_array(), p1.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( l1 - l2, len, 1e-6 );
}

Definition at line 94 of file LineDomainTest.cpp.

References ASSERT_NO_ERROR, CPPUNIT_ASSERT_VECTORS_EQUAL, MBMesquite::Vector3D::length(), MBMesquite::LineDomain::position_from_length(), MBMesquite::Vector3D::to_array(), and moab::unit().

{
    MsqPrintError err( std::cerr );

    const Vector3D base1( 1, 1, 1 );
    const Vector3D dir1( -1, -2, -3 );
    LineDomain dom1( base1, dir1 );
    const Vector3D unit = dir1 / dir1.length();
    double l1           = 1.5;
    Vector3D result;
    dom1.position_from_length( base1.to_array(), l1, result.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_VECTORS_EQUAL( base1 + l1 * unit, result, 1e-6 );

    double l2 = 3.333;
    Vector3D result2;
    dom1.position_from_length( result.to_array(), l2, result2.to_array(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_VECTORS_EQUAL( result + l2 * unit, result2, 1e-6 );
}

Definition at line 55 of file LineDomainTest.cpp.

References CPPUNIT_ASSERT_DOUBLES_EQUAL, MBMesquite::length(), and MBMesquite::LineDomain::snap_to().

{
    const Vector3D base1( 1, 1, 1 );
    const Vector3D dir1( -1, -2, -3 );
    LineDomain dom1( base1, dir1 );

    Vector3D point( 0, 0, 0 ), result( point );
    dom1.snap_to( 0, result );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, ( ( result - base1 ) * dir1 ).length(),
                                  1e-6 );                                      // on the line
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, ( ( point - result ) % dir1 ), 1e-6 );  // moved perp to line

    point  = Vector3D( 10, 11, 12 );
    result = point;
    dom1.snap_to( 0, result );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, ( ( result - base1 ) * dir1 ).length(),
                                  1e-6 );                                      // on the line
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, ( ( point - result ) % dir1 ), 1e-6 );  // moved perp to line
}

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