void SegmentsTests<dimension>::run()
{
  VecD origin1 = random_vec<VecD>();
  VecD direction1 = random_vec<VecD>();
  geom::Point<dimension> point1( new typename geom::Point<dimension>::EuclideanDriver( random_vec<HomogenousVecD>() ) );
  geom::Point<dimension> point2( new typename geom::Point<dimension>::EuclideanDriver( random_vec<HomogenousVecD>() ) );
  
  // Test based on line
  geom::Line<dimension> line1( new typename geom::Line<dimension>::EuclideanDriver( origin1, direction1));
  
  double firstIndex = random_float();
  double lastIndex = random_float();
  SegmentD seg1( new typename SegmentD::LineDriver( &line1, firstIndex, lastIndex ) );
  test_segment_validity( seg1 );
  GEOM_CHECK_VEC_EQUAL( seg1.firstPoint(), line1.pointAt(firstIndex) );
  GEOM_CHECK_VEC_EQUAL( seg1.lastPoint(), line1.pointAt(lastIndex) );
  GEOM_CHECK_NULL( geom::angle(seg1, line1 ) );
  test_segment( seg1 );
  JFR_CHECK( !seg1.isTransformable() );
  // Test constructor based on two points
  SegmentD seg2( new typename SegmentD::TwoPointsPointerDriver( &point1, &point2 ) );
  test_segment_validity( seg2 );
  GEOM_CHECK_VEC_EQUAL( seg2.firstPoint(), point1.homogenousCoordinates() );
  GEOM_CHECK_VEC_EQUAL( seg2.lastPoint(), point2.homogenousCoordinates() );
  test_segment( seg2 );
  JFR_CHECK( !seg2.isTransformable() );
  // Test constructor based on two points
  SegmentD seg3( new typename SegmentD::TwoPointsDriver( point1.homogenousCoordinates(), point2.homogenousCoordinates() ) );
  test_segment_validity( seg3 );
  GEOM_CHECK_VEC_EQUAL( seg3.firstPoint(), point1.homogenousCoordinates() );
  GEOM_CHECK_VEC_EQUAL( seg3.lastPoint(), point2.homogenousCoordinates() );
  test_segment( seg3 );
  JFR_CHECK( seg3.isTransformable() );
  // Test transformability
  HomogenousMatrixD m = random_inversible_mat<dimension>();
  HomogenousMatrixD mInv;
  jmath::ublasExtra::inv( m, mInv );
  SegmentD seg3bis = seg3;
  seg3bis.applyTransformation( m );
  GEOM_CHECK_VEC_EQUAL( seg3bis.firstPoint(), ublas::prod(m, seg3.firstPoint() ) );
  GEOM_CHECK_VEC_EQUAL( seg3bis.lastPoint(), ublas::prod(m, seg3.lastPoint() ) );
  seg3bis.applyTransformation( mInv );
  GEOM_CHECK_VEC_EQUAL( seg3bis.firstPoint(), seg3.firstPoint() );
  GEOM_CHECK_VEC_EQUAL( seg3bis.lastPoint(), seg3.lastPoint() );
  
  // Test distance
  test_distance(seg1, seg2);
  test_distance(seg2, seg3);
  test_distance(seg1, seg3);
  test_distance(seg1, seg2.support());
  test_distance(seg1, seg3.support());
  test_distance(seg2, seg1.support());
  test_distance(seg2, seg3.support());
  test_distance(seg3, seg2.support());
  test_distance(seg3, seg1.support());
}
示例#2
0
void test_cases(void)
{
   test_cast_ray();
   test_distance();
   test_printColor();
//   test_cast_all_rays();
}
示例#3
0
文件: test.c 项目: runderwood/ssdb
int main(int argc, char** argv) {
    
    srand(time(NULL));
    //test_points(10, 360, 180);
    test_linestrs(10, 100);
    test_distance();
    test_polygon(10, 10);

    return EXIT_SUCCESS;
}
示例#4
0
void test_slist(struct cag_test_series *tests)
{
	test_it(tests);
	test_new(tests);
	test_prepend(tests);
	test_insert(tests);
	test_insertp(tests);
	test_distance(tests);
	test_front(tests);
	test_erase(tests);
	test_copy(tests);
	test_reverse(tests);
	test_copy_over(tests);
	test_sort(tests);
	test_find(tests);
}
示例#5
0
bool BlenderObjectCulling::test(Scene *scene, BL::Object& b_ob, Transform& tfm)
{
	if(!use_camera_cull_ && !use_distance_cull_) {
		return false;
	}

	/* Compute world space bounding box corners. */
	float3 bb[8];
	BL::Array<float, 24> boundbox = b_ob.bound_box();
	for(int i = 0; i < 8; ++i) {
		float3 p = make_float3(boundbox[3 * i + 0],
		                       boundbox[3 * i + 1],
		                       boundbox[3 * i + 2]);
		bb[i] = transform_point(&tfm, p);
	}

	bool camera_culled = use_camera_cull_ && test_camera(scene, bb);
	bool distance_culled = use_distance_cull_ && test_distance(scene, bb);

	return ((camera_culled && distance_culled) ||
	        (camera_culled && !use_distance_cull_) ||
	        (distance_culled && !use_camera_cull_));
}