コード例 #1
0
ファイル: chull_d-test.cpp プロジェクト: ArcEarth/cgal
int main()
{
  CGAL_KD_SETDTHREAD(11);  
  CGAL::set_pretty_mode ( std::cerr );
  CGAL_TEST_START;
  {
    typedef CGAL::Homogeneous_d<RT> Kernel;
    typedef CGAL::Convex_hull_d<Kernel> Convex_hull_d;
    typedef Convex_hull_d::Point_d Point;
    typedef Convex_hull_d::Hyperplane_d Plane;
    typedef Convex_hull_d::Simplex_handle Simplex_handle;
    typedef Convex_hull_d::Facet_handle Facet_handle;
    typedef Convex_hull_d::Vertex_handle Vertex_handle;

    Convex_hull_d T1(2);  
    const Convex_hull_d* pT1 = &T1;
    Point p1(0,0,1);
    Point p2(1,0,1);
    Point p3(0,1,1);
    Point p4(1,1,1);
    CGAL_TEST(T1.dimension()==2);
    CGAL_TEST(T1.current_dimension()==-1);
    Vertex_handle v1 = T1.insert(p1);
    CGAL_TEST(T1.associated_point(v1)==p1);
    T1.insert(p2);
    CGAL_TEST(T1.current_dimension()==1);
    CGAL_TEST(T1.is_dimension_jump(p3));
    T1.insert(p3);
    Simplex_handle s1 = T1.simplex(v1);
    int i1 = T1.index(v1);
    CGAL_TEST(T1.vertex_of_simplex(s1,i1)==v1);
    CGAL_TEST(T1.associated_point(T1.vertex_of_simplex(s1,1))==
              T1.point_of_simplex(s1,1));
    T1.insert(p3);
    CGAL_TEST((T1.opposite_simplex(T1.opposite_simplex(s1,1),
              T1.index_of_vertex_in_opposite_simplex(s1,1)) == s1));
    std::list<Simplex_handle> L = T1.all_simplices();
    CGAL_TEST(L.size() == 4);
    std::list<Facet_handle> F = T1.all_facets();
    CGAL_TEST(F.size() == 3);
    Facet_handle f1 = *(L.begin());
    CGAL_TEST(T1.associated_point(T1.vertex_of_facet(f1,1))==
              T1.point_of_facet(f1,1));
    CGAL_TEST((T1.opposite_facet(T1.opposite_facet(f1,1),
               T1.index_of_vertex_in_opposite_facet(f1,1)) == f1));
    Point pf0 = T1.point_of_facet(f1,0);
    Point pf1 = T1.point_of_facet(f1,1);
    Plane h = T1.hyperplane_supporting(f1);
    CGAL_TEST(h.has_on(pf0)&&h.has_on(pf1));
    std::list<Facet_handle> G = T1.facets_visible_from(p4);
    CGAL_TEST(G.size()==1);
    CGAL_TEST(T1.bounded_side(p4)==CGAL::ON_UNBOUNDED_SIDE && 
              T1.bounded_side(Point(1,1,10))==CGAL::ON_BOUNDED_SIDE);

    Convex_hull_d::Point_const_iterator   pit;
    Convex_hull_d::Vertex_iterator  vit;
    Convex_hull_d::Simplex_iterator sit;
    for (pit = T1.points_begin(); pit != T1.points_end(); pit++) *pit;
    for (vit = T1.vertices_begin(); vit != T1.vertices_end(); vit++) *vit;
    for (sit = T1.simplices_begin(); sit != T1.simplices_end(); sit++) *sit;
    T1.is_valid();
    T1.clear(2);
    CGAL_TEST(T1.number_of_vertices()==0);
    CGAL_TEST(T1.number_of_facets()==0);
    CGAL_TEST(T1.number_of_simplices()==0);
    std::vector<Point> V = make_vector(p1,p2,p3,p4);
    T1.initialize(V.begin(),V.end());
    Convex_hull_d::Facet_iterator fit;
    int fnum(0);
    for (fit = T1.facets_begin(); fit != T1.facets_end(); ++fnum, ++fit) *fit;
    CGAL_TEST(fnum==4);

#ifndef _MSC_VER // truncation due to name length exceeded
    Convex_hull_d::Hull_vertex_iterator hvit;
    int vnum(0);
    for (hvit = T1.hull_vertices_begin(); 
         hvit != T1.hull_vertices_end(); ++vnum, ++hvit) *hvit; 
    CGAL_TEST(vnum==4);

    Convex_hull_d::Facet_const_iterator fcit; 
    for (fcit = pT1->facets_begin(); fcit != pT1->facets_end(); ++fcit) *fcit;
    Convex_hull_d::Hull_vertex_const_iterator hvcit; 
    for (hvcit = pT1->hull_vertices_begin(); 
         hvcit != pT1->hull_vertices_end(); ++hvcit) *hvcit;
    Convex_hull_d::Hull_point_const_iterator hpcit; 
    for (hpcit = pT1->hull_points_begin(); 
         hpcit != pT1->hull_points_end(); ++hpcit) *hpcit;
#endif
  }


  {
    typedef CGAL::Cartesian<double> Kernel_3;
    typedef CGAL::Convex_hull_d_traits_3<Kernel_3> Kernel;
    typedef CGAL::Convex_hull_d<Kernel> Convex_hull_d;
    typedef Convex_hull_d::Point_d Point;
    typedef Convex_hull_d::Hyperplane_d Plane;
    typedef Convex_hull_d::Simplex_handle Simplex_handle;
    typedef Convex_hull_d::Facet_handle Facet_handle;
    typedef Convex_hull_d::Vertex_handle Vertex_handle;
    Convex_hull_d T2(3);  
    Point p1(0,0,0,1);
    Point p2(1,0,0,1);
    Point p3(0,1,0,1);
    Point p4(0,0,1,1);
    Point p5(1,1,1,1);
    CGAL_TEST(T2.dimension()==3);
    CGAL_TEST(T2.current_dimension()==-1);
    T2.insert(p1);
    T2.insert(p2);
    CGAL_TEST(T2.is_dimension_jump(p3));
    T2.insert(p3);
    CGAL_TEST(T2.current_dimension()==2);
    CGAL_TEST(T2.is_dimension_jump(p4));
    Vertex_handle v1 = T2.insert(p4);
    CGAL_TEST(T2.associated_point(v1)==p4);

    Simplex_handle s1 = T2.simplex(v1);
    int i1 = T2.index(v1);


    CGAL_TEST(T2.vertex_of_simplex(s1,i1)==v1);
    CGAL_TEST(T2.associated_point(T2.vertex_of_simplex(s1,1))==
          T2.point_of_simplex(s1,1));
    CGAL_TEST((T2.opposite_simplex(T2.opposite_simplex(s1,1),
               T2.index_of_vertex_in_opposite_simplex(s1,1)) == s1));

    std::list<Simplex_handle> L = T2.all_simplices();
    CGAL_TEST(L.size() == 5);
    std::list<Facet_handle> F = T2.all_facets();
    CGAL_TEST(F.size() == 4);
    Facet_handle f1 = *(L.begin());
    CGAL_TEST(T2.associated_point(T2.vertex_of_facet(f1,1))==
              T2.point_of_facet(f1,1));
    CGAL_TEST((T2.opposite_facet(T2.opposite_facet(f1,1),
               T2.index_of_vertex_in_opposite_facet(f1,1)) == f1));

    Point pf0 = T2.point_of_facet(f1,0);
    Point pf1 = T2.point_of_facet(f1,1);
    Point pf2 = T2.point_of_facet(f1,2);
    Plane h = T2.hyperplane_supporting(f1);
    CGAL_TEST(h.has_on(pf0)&&h.has_on(pf1)&&h.has_on(pf2));

    std::list<Facet_handle> G = T2.facets_visible_from(p5);
    CGAL_TEST(G.size()==1);
    CGAL_TEST(T2.bounded_side(p5)==CGAL::ON_UNBOUNDED_SIDE && 
              T2.bounded_side(Point(1,1,1,10))==CGAL::ON_BOUNDED_SIDE);
    T2.is_valid();
    T2.clear(3);


  }


  {
    typedef CGAL::Homogeneous<RT> Kernel_3;
    typedef CGAL::Convex_hull_d_traits_3<Kernel_3> Kernel;
    typedef CGAL::Convex_hull_d<Kernel> Convex_hull_d;
    typedef Convex_hull_d::Point_d Point;
    typedef Convex_hull_d::Hyperplane_d Plane;
    typedef Convex_hull_d::Simplex_handle Simplex_handle;
    typedef Convex_hull_d::Facet_handle Facet_handle;
    typedef Convex_hull_d::Vertex_handle Vertex_handle;
    Convex_hull_d T2(3);  
    Point p1(0,0,0,1);
    Point p2(1,0,0,1);
    Point p3(0,1,0,1);
    Point p4(0,0,1,1);
    Point p5(1,1,1,1);
    CGAL_TEST(T2.dimension()==3);
    CGAL_TEST(T2.current_dimension()==-1);
    T2.insert(p1);
    T2.insert(p2);
    CGAL_TEST(T2.is_dimension_jump(p3));
    T2.insert(p3);
    CGAL_TEST(T2.current_dimension()==2);
    CGAL_TEST(T2.is_dimension_jump(p4));
    Vertex_handle v1 = T2.insert(p4);
    CGAL_TEST(T2.associated_point(v1)==p4);

    Simplex_handle s1 = T2.simplex(v1);
    int i1 = T2.index(v1);


    CGAL_TEST(T2.vertex_of_simplex(s1,i1)==v1);
    CGAL_TEST(T2.associated_point(T2.vertex_of_simplex(s1,1))==
          T2.point_of_simplex(s1,1));
    CGAL_TEST((T2.opposite_simplex(T2.opposite_simplex(s1,1),
               T2.index_of_vertex_in_opposite_simplex(s1,1)) == s1));

    std::list<Simplex_handle> L = T2.all_simplices();
    CGAL_TEST(L.size() == 5);
    std::list<Facet_handle> F = T2.all_facets();
    CGAL_TEST(F.size() == 4);
    Facet_handle f1 = *(L.begin());
    CGAL_TEST(T2.associated_point(T2.vertex_of_facet(f1,1))==
              T2.point_of_facet(f1,1));
    CGAL_TEST((T2.opposite_facet(T2.opposite_facet(f1,1),
               T2.index_of_vertex_in_opposite_facet(f1,1)) == f1));

    Point pf0 = T2.point_of_facet(f1,0);
    Point pf1 = T2.point_of_facet(f1,1);
    Point pf2 = T2.point_of_facet(f1,2);
    Plane h = T2.hyperplane_supporting(f1);
    CGAL_TEST(h.has_on(pf0)&&h.has_on(pf1)&&h.has_on(pf2));

    std::list<Facet_handle> G = T2.facets_visible_from(p5);
    CGAL_TEST(G.size()==1);
    CGAL_TEST(T2.bounded_side(p5)==CGAL::ON_UNBOUNDED_SIDE && 
              T2.bounded_side(Point(1,1,1,10))==CGAL::ON_BOUNDED_SIDE);
    T2.is_valid();
    T2.clear(3);


  }
  {
    typedef CGAL::Cartesian_d<double> Kernel;
    typedef CGAL::Convex_hull_d<Kernel> Convex_hull_d;
    typedef Convex_hull_d::Point_d Point;
    typedef Convex_hull_d::Hyperplane_d Plane;
    typedef Convex_hull_d::Simplex_handle Simplex_handle;
    typedef Convex_hull_d::Facet_handle Facet_handle;
    typedef Convex_hull_d::Vertex_handle Vertex_handle;
    Convex_hull_d T2(3);  
    Point p1(0,0,0,1);
    Point p2(1,0,0,1);
    Point p3(0,1,0,1);
    Point p4(0,0,1,1);
    Point p5(1,1,1,1);
    CGAL_TEST(T2.dimension()==3);
    CGAL_TEST(T2.current_dimension()==-1);
    T2.insert(p1);
    T2.insert(p2);
    CGAL_TEST(T2.is_dimension_jump(p3));
    T2.insert(p3);
    CGAL_TEST(T2.current_dimension()==2);
    CGAL_TEST(T2.is_dimension_jump(p4));
    Vertex_handle v1 = T2.insert(p4);
    CGAL_TEST(T2.associated_point(v1)==p4);

    Simplex_handle s1 = T2.simplex(v1);
    int i1 = T2.index(v1);


    CGAL_TEST(T2.vertex_of_simplex(s1,i1)==v1);
    CGAL_TEST(T2.associated_point(T2.vertex_of_simplex(s1,1))==
          T2.point_of_simplex(s1,1));
    CGAL_TEST((T2.opposite_simplex(T2.opposite_simplex(s1,1),
               T2.index_of_vertex_in_opposite_simplex(s1,1)) == s1));

    std::list<Simplex_handle> L = T2.all_simplices();
    CGAL_TEST(L.size() == 5);
    std::list<Facet_handle> F = T2.all_facets();
    CGAL_TEST(F.size() == 4);
    Facet_handle f1 = *(L.begin());
    CGAL_TEST(T2.associated_point(T2.vertex_of_facet(f1,1))==
              T2.point_of_facet(f1,1));
    CGAL_TEST((T2.opposite_facet(T2.opposite_facet(f1,1),
               T2.index_of_vertex_in_opposite_facet(f1,1)) == f1));

    Point pf0 = T2.point_of_facet(f1,0);
    Point pf1 = T2.point_of_facet(f1,1);
    Point pf2 = T2.point_of_facet(f1,2);
    Plane h = T2.hyperplane_supporting(f1);
    CGAL_TEST(h.has_on(pf0)&&h.has_on(pf1)&&h.has_on(pf2));

    std::list<Facet_handle> G = T2.facets_visible_from(p5);
    CGAL_TEST(G.size()==1);
    CGAL_TEST(T2.bounded_side(p5)==CGAL::ON_UNBOUNDED_SIDE && 
              T2.bounded_side(Point(1,1,1,10))==CGAL::ON_BOUNDED_SIDE);
    T2.is_valid();
    T2.clear(3);


  }
  {
    typedef CGAL::Homogeneous_d<RT> Kernel;
    typedef CGAL::Convex_hull_d<Kernel> Convex_hull_d;
    typedef Convex_hull_d::Point_d Point;
    typedef Convex_hull_d::Hyperplane_d Plane;
    typedef Convex_hull_d::Simplex_handle Simplex_handle;
    typedef Convex_hull_d::Facet_handle Facet_handle;
    typedef Convex_hull_d::Vertex_handle Vertex_handle;
    Convex_hull_d T2(3);  
    Point p1(0,0,0,1);
    Point p2(1,0,0,1);
    Point p3(0,1,0,1);
    Point p4(0,0,1,1);
    Point p5(1,1,1,1);
    CGAL_TEST(T2.dimension()==3);
    CGAL_TEST(T2.current_dimension()==-1);
    T2.insert(p1);
    T2.insert(p2);
    CGAL_TEST(T2.is_dimension_jump(p3));
    T2.insert(p3);
    CGAL_TEST(T2.current_dimension()==2);
    CGAL_TEST(T2.is_dimension_jump(p4));
    Vertex_handle v1 = T2.insert(p4);
    CGAL_TEST(T2.associated_point(v1)==p4);

    Simplex_handle s1 = T2.simplex(v1);
    int i1 = T2.index(v1);


    CGAL_TEST(T2.vertex_of_simplex(s1,i1)==v1);
    CGAL_TEST(T2.associated_point(T2.vertex_of_simplex(s1,1))==
          T2.point_of_simplex(s1,1));
    CGAL_TEST((T2.opposite_simplex(T2.opposite_simplex(s1,1),
               T2.index_of_vertex_in_opposite_simplex(s1,1)) == s1));

    std::list<Simplex_handle> L = T2.all_simplices();
    CGAL_TEST(L.size() == 5);
    std::list<Facet_handle> F = T2.all_facets();
    CGAL_TEST(F.size() == 4);
    Facet_handle f1 = *(L.begin());
    CGAL_TEST(T2.associated_point(T2.vertex_of_facet(f1,1))==
              T2.point_of_facet(f1,1));
    CGAL_TEST((T2.opposite_facet(T2.opposite_facet(f1,1),
               T2.index_of_vertex_in_opposite_facet(f1,1)) == f1));

    Point pf0 = T2.point_of_facet(f1,0);
    Point pf1 = T2.point_of_facet(f1,1);
    Point pf2 = T2.point_of_facet(f1,2);
    Plane h = T2.hyperplane_supporting(f1);
    CGAL_TEST(h.has_on(pf0)&&h.has_on(pf1)&&h.has_on(pf2));

    std::list<Facet_handle> G = T2.facets_visible_from(p5);
    CGAL_TEST(G.size()==1);
    CGAL_TEST(T2.bounded_side(p5)==CGAL::ON_UNBOUNDED_SIDE && 
              T2.bounded_side(Point(1,1,1,10))==CGAL::ON_BOUNDED_SIDE);
    T2.is_valid();
    T2.clear(3);


  }
  CGAL_TEST_END;
}
コード例 #2
0
ファイル: view.c プロジェクト: FeeJai/Tux-Racer-4-iOS
void update_view( player_data_t *plyr, scalar_t dt )
{
    point_t view_pt;
    vector_t view_dir, up_dir, vel_dir, view_vec;
    scalar_t ycoord;
    scalar_t course_angle;
    vector_t axis;
    matrixgl_t rot_mat;
    vector_t y_vec;
    vector_t mz_vec;
    vector_t vel_proj;
    quaternion_t rot_quat;
    scalar_t speed;
    vector_t vel_cpy;
    scalar_t time_constant_mult;

    vel_cpy = plyr->vel;
    speed = normalize_vector( &vel_cpy );

    time_constant_mult = 1.0 /
	min( 1.0, 
	     max( 0.0, 
		  ( speed - NO_INTERPOLATION_SPEED ) /
		  ( BASELINE_INTERPOLATION_SPEED - NO_INTERPOLATION_SPEED )));

    up_dir = make_vector( 0, 1, 0 );

    vel_dir = plyr->vel;
    normalize_vector( &vel_dir );

    course_angle = get_course_angle();

    switch( plyr->view.mode ) {
    case TUXEYE:
    {
        view_pt = plyr->pos;
        scalar_t f = 2;

        vector_t v = plyr->plane_nml;
        scalar_t n = 1.;
        view_pt.x += v.x / n  * 0.3;
        view_pt.y += v.y / n * 0.3;
        view_pt.y += 0.1;
        view_pt.z += v.z / n * 0.3;


        if(plyr->control.flip_factor || plyr->control.barrel_roll_factor) {
            matrixgl_t mat1, mat;
            scalar_t n = sqrt(plyr->viewdir_for_tuxeye.x * plyr->viewdir_for_tuxeye.x + plyr->viewdir_for_tuxeye.y * plyr->viewdir_for_tuxeye.y + plyr->viewdir_for_tuxeye.z * plyr->viewdir_for_tuxeye.z);
            plyr->viewdir_for_tuxeye.x /= n;
            plyr->viewdir_for_tuxeye.y /= n;
            plyr->viewdir_for_tuxeye.z /= n;
            n = sqrt(plyr->updir_for_tuxeye.x * plyr->updir_for_tuxeye.x + plyr->updir_for_tuxeye.y * plyr->updir_for_tuxeye.y + plyr->updir_for_tuxeye.z * plyr->updir_for_tuxeye.z);
            plyr->updir_for_tuxeye.x /= n;
            plyr->updir_for_tuxeye.y /= n;
            plyr->updir_for_tuxeye.z /= n;
            vector_t right = cross_product(plyr->updir_for_tuxeye, plyr->viewdir_for_tuxeye);
            make_rotation_about_vector_matrix( mat1, right, jump_from_time(plyr->control.flip_factor) * 360 );
            make_rotation_about_vector_matrix( mat, plyr->viewdir_for_tuxeye, jump_from_time(plyr->control.barrel_roll_factor)  * 360 );
            multiply_matrices(mat, mat1, mat);
            view_dir = transform_vector(mat, plyr->viewdir_for_tuxeye);
            up_dir = transform_vector(mat, plyr->updir_for_tuxeye);
        }
        else {
            view_dir = plyr->direction;
            view_dir.y += 0.1;

            view_dir.x = (plyr->view.dir.x * f +  view_dir.x) / (f + 1);
            view_dir.y = (plyr->view.dir.y * f + view_dir.y) / (f + 1);
            view_dir.z = (plyr->view.dir.z * f + view_dir.z) / (f + 1);
            plyr->viewdir_for_tuxeye = view_dir;

            up_dir = plyr->plane_nml;
            up_dir.x = (plyr->view.up.x * f +  up_dir.x) / (f + 1);
            up_dir.y = (plyr->view.up.y * f + up_dir.y) / (f + 1);
            up_dir.z = (plyr->view.up.z * f + up_dir.z) / (f + 1);
            plyr->updir_for_tuxeye = up_dir;
        }
        break;
    }
    case BEHIND:
    {
	/* Camera-on-a-string mode */

	/* Construct vector from player to camera */
	view_vec = make_vector( 0, 
				sin( ANGLES_TO_RADIANS( 
				    course_angle -
				    CAMERA_ANGLE_ABOVE_SLOPE + 
				    PLAYER_ANGLE_IN_CAMERA ) ),
				cos( ANGLES_TO_RADIANS( 
				    course_angle -
				    CAMERA_ANGLE_ABOVE_SLOPE + 
				    PLAYER_ANGLE_IN_CAMERA ) ) );

	view_vec = scale_vector( CAMERA_DISTANCE, view_vec );

	y_vec = make_vector( 0.0, 1.0, 0.0 );
	mz_vec = make_vector( 0.0, 0.0, -1.0 );
	vel_proj = project_into_plane( y_vec, vel_dir );

	normalize_vector( &vel_proj );

	/* Rotate view_vec so that it places the camera behind player */
	rot_quat = make_rotation_quaternion( mz_vec, vel_proj );

	view_vec = rotate_vector( rot_quat, view_vec );


	/* Construct view point */
	view_pt = move_point( plyr->pos, view_vec );

	/* Make sure view point is above terrain */
        ycoord = find_y_coord( view_pt.x, view_pt.z );

        if ( view_pt.y < ycoord + MIN_CAMERA_HEIGHT ) {
            view_pt.y = ycoord + MIN_CAMERA_HEIGHT;
        } 

	/* Interpolate view point */
	if ( plyr->view.initialized ) {
	    /* Interpolate twice to get a second-order filter */
	    int i;
	    for (i=0; i<2; i++) {
		view_pt = 
		    interpolate_view_pos( plyr->pos, plyr->pos, 
					  MAX_CAMERA_PITCH, plyr->view.pos, 
					  view_pt, CAMERA_DISTANCE, dt,
					  BEHIND_ORBIT_TIME_CONSTANT * 
					  time_constant_mult );
	    }
	}

	/* Make sure interpolated view point is above terrain */
        ycoord = find_y_coord( view_pt.x, view_pt.z );

        if ( view_pt.y < ycoord + ABSOLUTE_MIN_CAMERA_HEIGHT ) {
            view_pt.y = ycoord + ABSOLUTE_MIN_CAMERA_HEIGHT;
        } 

	/* Construct view direction */
	view_vec = subtract_points( view_pt, plyr->pos );
	
	axis = cross_product( y_vec, view_vec );
	normalize_vector( &axis );
	
	make_rotation_about_vector_matrix( rot_mat, axis,
					   PLAYER_ANGLE_IN_CAMERA );
	view_dir = scale_vector( -1.0, 
				 transform_vector( rot_mat, view_vec ) );

	/* Interpolate orientation of camera */
	if ( plyr->view.initialized ) {
	    /* Interpolate twice to get a second-order filter */
	    int i;
	    for (i=0; i<2; i++) {
		interpolate_view_frame( plyr->view.up, plyr->view.dir,
					&up_dir, &view_dir, dt,
					BEHIND_ORIENT_TIME_CONSTANT );
		up_dir = make_vector( 0.0, 1.0, 0.0 );
	    }
	}

        break;
    }

    case FOLLOW: 
    {
	/* Camera follows player (above and behind) */

	up_dir = make_vector( 0, 1, 0 );

	/* Construct vector from player to camera */
	view_vec = make_vector( 0, 
				sin( ANGLES_TO_RADIANS( 
				    course_angle -
				    CAMERA_ANGLE_ABOVE_SLOPE +
				    PLAYER_ANGLE_IN_CAMERA ) ),
				cos( ANGLES_TO_RADIANS( 
				    course_angle -
				    CAMERA_ANGLE_ABOVE_SLOPE + 
				    PLAYER_ANGLE_IN_CAMERA ) ) );
	view_vec = scale_vector( CAMERA_DISTANCE, view_vec );

	y_vec = make_vector( 0.0, 1.0, 0.0 );
	mz_vec = make_vector( 0.0, 0.0, -1.0 );
	vel_proj = project_into_plane( y_vec, vel_dir );

	normalize_vector( &vel_proj );

	/* Rotate view_vec so that it places the camera behind player */
	rot_quat = make_rotation_quaternion( mz_vec, vel_proj );

	view_vec = rotate_vector( rot_quat, view_vec );


	/* Construct view point */
	view_pt = move_point( plyr->pos, view_vec );


	/* Make sure view point is above terrain */
        ycoord = find_y_coord( view_pt.x, view_pt.z );

        if ( view_pt.y < ycoord + MIN_CAMERA_HEIGHT ) {
            view_pt.y = ycoord + MIN_CAMERA_HEIGHT;
	}

	/* Interpolate view point */
	if ( plyr->view.initialized ) {
	    /* Interpolate twice to get a second-order filter */
	    int i;
	    for ( i=0; i<2; i++ ) {
		view_pt = 
		    interpolate_view_pos( plyr->view.plyr_pos, plyr->pos, 
					  MAX_CAMERA_PITCH, plyr->view.pos, 
					  view_pt, CAMERA_DISTANCE, dt,
					  FOLLOW_ORBIT_TIME_CONSTANT *
					  time_constant_mult );
	    }
	}

	/* Make sure interpolate view point is above terrain */
        ycoord = find_y_coord( view_pt.x, view_pt.z );

        if ( view_pt.y < ycoord + ABSOLUTE_MIN_CAMERA_HEIGHT ) {
            view_pt.y = ycoord + ABSOLUTE_MIN_CAMERA_HEIGHT;
        } 

	/* Construct view direction */
	view_vec = subtract_points( view_pt, plyr->pos );
	
	axis = cross_product( y_vec, view_vec );
	normalize_vector( &axis );
	
	make_rotation_about_vector_matrix( rot_mat, axis,
					   PLAYER_ANGLE_IN_CAMERA );
	view_dir = scale_vector( -1.0, 
				 transform_vector( rot_mat, view_vec ) );

	/* Interpolate orientation of camera */
	if ( plyr->view.initialized ) {
	    /* Interpolate twice to get a second-order filter */
	    int i;
	    for ( i=0; i<2; i++ ) {
		interpolate_view_frame( plyr->view.up, plyr->view.dir,
					&up_dir, &view_dir, dt,
					FOLLOW_ORIENT_TIME_CONSTANT );
		up_dir = make_vector( 0.0, 1.0, 0.0 );
	    }
	}

        break;
    }

    case ABOVE:
    {
	/* Camera always uphill of player */

	up_dir = make_vector( 0, 1, 0 );


	/* Construct vector from player to camera */
	view_vec = make_vector( 0, 
				sin( ANGLES_TO_RADIANS( 
				    course_angle - 
				    CAMERA_ANGLE_ABOVE_SLOPE+
				    PLAYER_ANGLE_IN_CAMERA ) ),
				cos( ANGLES_TO_RADIANS( 
				    course_angle - 
				    CAMERA_ANGLE_ABOVE_SLOPE+ 
				    PLAYER_ANGLE_IN_CAMERA ) ) );
	view_vec = scale_vector( CAMERA_DISTANCE, view_vec );

	
	/* Construct view point */
	view_pt = move_point( plyr->pos, view_vec );


	/* Make sure view point is above terrain */
        ycoord = find_y_coord( view_pt.x, view_pt.z );

        if ( view_pt.y < ycoord + MIN_CAMERA_HEIGHT ) {
            view_pt.y = ycoord + MIN_CAMERA_HEIGHT;
	}

	/* Construct view direction */
	view_vec = subtract_points( view_pt, plyr->pos );

	make_rotation_matrix( rot_mat, PLAYER_ANGLE_IN_CAMERA, 'x' );
	view_dir = scale_vector( -1.0, 
				 transform_vector( rot_mat, view_vec ) );

        break;
    }

    default:
	code_not_reached();
    } 

    /* Create view matrix */
    plyr->view.pos = view_pt;
    plyr->view.dir = view_dir;
    plyr->view.up = up_dir;
    plyr->view.plyr_pos = plyr->pos;
    plyr->view.initialized = True;

    setup_view_matrix( plyr );
} 
コード例 #3
0
ファイル: spawn.c プロジェクト: o-lim/lua-ex
/* ... argtab -- ... argtab vector */
void spawn_param_args(struct spawn_params *p)
{
  const char **argv = make_vector(p->L);
  if (!argv[0]) argv[0] = p->command;
  p->argv = argv;
}
コード例 #4
0
ファイル: TransformTools.cpp プロジェクト: CarlosGS/heekscad
//static
void TransformTools::Translate(bool copy)
{
	// pick items
	if(wxGetApp().m_marked_list->size() == 0){
		wxGetApp().PickObjects(_("Pick objects to move"));
	}
	if(wxGetApp().m_marked_list->size() == 0)return;

	// get number of copies
	HeeksConfig config;
	int ncopies;
	config.Read(_T("TranslateNumCopies"), &ncopies, 1);
	if(copy)
	{
		// check for uncopyable objects
		RemoveUncopyable();
		if(wxGetApp().m_marked_list->size() == 0)return;

		// input "number of copies"
		if(!wxGetApp().InputInt(_("Enter number of copies"), _("number of copies"), ncopies))return;
		if(ncopies < 1)return;
		config.Write(_T("TranslateNumCopies"), ncopies);
	}

	// clear the selection
	std::list<HeeksObj *> selected_items = wxGetApp().m_marked_list->list();
	wxGetApp().m_marked_list->Clear(true);

	// pick "from" position
	if(!wxGetApp().PickPosition(_("Click position to move from"), from))return;

	// pick "to" position
	wxGetApp().CreateTransformGLList(selected_items, false);
	wxGetApp().m_drag_matrix = gp_Trsf();
	if(!copy)
	{
		for(std::list<HeeksObj*>::const_iterator It = selected_items.begin(); It != selected_items.end(); It++){
			HeeksObj* object = *It;
			if(object->m_visible)wxGetApp().m_hidden_for_drag.push_back(object);
			object->m_visible = false;
		}
	}
	double to[3];

	bool move_to_accepted = wxGetApp().PickPosition(_("Click position to move to"), to, on_move_translate);

	if(!copy)
	{
		for(std::list<HeeksObj*>::iterator It = wxGetApp().m_hidden_for_drag.begin(); It != wxGetApp().m_hidden_for_drag.end(); It++)
		{
			HeeksObj* object = *It;
			object->m_visible = true;
		}
		wxGetApp().m_hidden_for_drag.clear();
	}
	wxGetApp().DestroyTransformGLList();

	if(!move_to_accepted)return;

	wxGetApp().CreateUndoPoint();

	// transform the objects
	if(copy)
	{
		for(int i = 0; i<ncopies; i++)
		{
			gp_Trsf mat;
			mat.SetTranslationPart(make_vector(make_point(from), make_point(to)) * (i + 1));
			double m[16];
			extract(mat, m);
			for(std::list<HeeksObj*>::iterator It = selected_items.begin(); It != selected_items.end(); It++)
			{
				HeeksObj* object = *It;
				HeeksObj* new_object = object->MakeACopy();
#ifdef MULTIPLE_OWNERS
				object->HEEKSOBJ_OWNER->Add(new_object, NULL);
#else
				object->m_owner->Add(new_object, NULL);
#endif
				new_object->ModifyByMatrix(m);
			}
		}
		wxGetApp().m_marked_list->Clear(true);
	}
	else
	{
		gp_Trsf mat;
		mat.SetTranslationPart(make_vector(make_point(from), make_point(to)));
		double m[16];
		extract(mat, m);
		wxGetApp().Transform(selected_items, m);
	}

	wxGetApp().Changed();
}
コード例 #5
0
ファイル: eval.c プロジェクト: Melab/gvmt
R_environment make_top_level_environment(void) {
    R_environment env = top_level_environment();
    globals = make_vector(1000);
    bind(env, "display", make_function_c("display", 1, display_byte_codes, 3, NULL));
    bind(env, "+", make_function_c("+", 2, add_byte_codes, 2, NULL));
    bind(env, "-", make_function_c("-", 2, sub_byte_codes, 2, NULL));
    bind(env, "*", make_function_c("*", 2, mul_byte_codes, 2, NULL));
    bind(env, "/", make_function_c("/", 2, div_byte_codes, 2, NULL));
    bind(env, "modulo", make_function_c("modulo", 2, mod_byte_codes, 2, NULL));
    bind(env, "eq?", make_function_c("eq?", 2, eq_byte_codes, 2, NULL));
    // As ints are tagged and chars are not implemented, eq? == eqv?
    bind(env, "eqv?", make_function_c("eqv?", 2, eq_byte_codes, 2, NULL));
    bind(env, "equal?", make_function_c("equal?", 2, equal_byte_codes, 2, NULL));
    bind(env, "symbol?", make_function_c("symbol?", 1, is_symbol_byte_codes, 2, NULL));
    bind(env, "=", make_function_c("=", 2, i_eq_byte_codes, 2, NULL));
    bind(env, "!=", make_function_c("!=", 2, i_ne_byte_codes, 2, NULL));
    bind(env, "<", make_function_c("<", 2, i_lt_byte_codes, 2, NULL));
    bind(env, "<=", make_function_c("<=", 2, i_le_byte_codes, 2, NULL));
    bind(env, ">", make_function_c(">", 2, i_gt_byte_codes, 2, NULL));
    bind(env, ">=", make_function_c(">=", 2, i_ge_byte_codes, 2, NULL));
    bind(env, "arithmetic-shift", make_function_c("arithmetic-shift", 2, i_shift_byte_codes, 2, NULL));
    bind(env, "cons", make_function_c("cons", 2, cons_byte_codes, 2, NULL));
    bind(env, "car", make_function_c("car", 1, car_byte_codes, 2, NULL));
    bind(env, "cdr", make_function_c("cdr", 1, cdr_byte_codes, 2, NULL));
    bind(env, "&", make_function_c("&", 2, band_byte_codes, 2, NULL));
    bind(env, "|", make_function_c("|", 2, bor_byte_codes, 2, NULL));
    bind(env, "vector-ref", make_function_c("vector-ref", 2, vec_get_byte_codes, 2, NULL));
    bind(env, "vector-set!", make_function_c("vector-set!", 3, vec_set_byte_codes, 3, NULL));
    bind(env, "list->vector", make_function_c("list->vector", 1, list_to_vec_byte_codes, 2, NULL));
    bind(env, "vector->list", make_function_c("vector->list", 1, vec_to_list_byte_codes, 2, NULL));
    bind(env, "string->number", make_function_c("string->number", 1, string_to_number_byte_codes, 2, NULL));
    bind(env, "__vector-copy!", make_function_c("__vector-copy!", 5, vector_copy_byte_codes, 3, NULL));
    bind(env, "set!", make_syntax("set!", compile_set_bang));
    bind(env, "vector-length", make_function_c("vector-length", 1, vec_len_byte_codes, 2, NULL));
    bind(env, "not", make_function_c("not", 1, not_byte_codes, 2, NULL));
    bind(env, "null?", make_function_c("null?", 1, null_byte_codes, 2, NULL));
    bind(env, "if", make_syntax("if", compile_if));
    bind(env, "and", make_syntax("and", compile_and));
    bind(env, "or", make_syntax("or", compile_or));
    bind(env, "let", make_syntax("let", compile_let));
    bind(env, "let*", make_syntax("let*", compile_let_star));
    bind(env, "letrec", make_syntax("letrec", compile_let_rec));
    bind(env, "do", make_syntax("do", compile_do));
    LAMBDA = make_syntax("lambda", compile_lambda);
    bind(env, "lambda", LAMBDA);
    bind(env, "define", make_syntax("define", compile_define));
    bind(env, "define-syntax", make_syntax("define-syntax", compile_define_syntax));
    bind(env, "list", make_syntax("list", compile_list));
    QUOTE = make_syntax("'", compile_quote);
    QUASI_QUOTE = make_syntax("`", compile_quasi_quote);
    UNQUOTE = make_syntax(",", compile_unquote);
    VECTOR = make_syntax("vector", compile_vector);
    bind(env, "vector", VECTOR);
    BEGIN = make_syntax("begin", compile_begin);
    bind(env, "begin", BEGIN);
    bind(env, "#t", TRUE);
    bind(env, "#f", FALSE);
    bind(env, "#void", VOID);
    bind(env, "#null", EMPTY_LIST);
    bind(env, "#undefined", UNDEFINED);
    bind(env, "__make-vector", make_function_c("__make-vector", 2, make_vector_byte_codes, 2, NULL));
    bind(env, "exit", make_function_c("exit", 0, exit_byte_codes, 2, NULL));
    return env;
}
コード例 #6
0
CommandLineHandler::CommandLineHandler()
  : CommandLineHandlerBase("animatecamera")
{
    add_default_options();

    m_filenames.set_exact_value_count(2);
    parser().set_default_option_handler(&m_filenames);

    parser().add_option_handler(
        &m_animation_path
            .add_name("--animation-path")
            .add_name("-a")
            .set_description("load an animation path file")
            .set_syntax("filename.txt")
            .set_exact_value_count(1));

    parser().add_option_handler(
        &m_3dsmax_mode
            .add_name("--3dsmax")
            .set_description("assume the animation path file uses Autodesk 3ds Max's coordinate system"));

    parser().add_option_handler(
        &m_output_format
            .add_name("--output-format")
            .add_name("-o")
            .set_description("set the format of the output frames")
            .set_syntax("format")
            .set_exact_value_count(1)
            .set_default_value("exr"));

    parser().add_option_handler(
        &m_frame_count
            .add_name("--frame-count")
            .add_name("-f")
            .set_description("set the number of frames in the animation")
            .set_syntax("count")
            .set_exact_value_count(1)
            .set_default_value(20));

    parser().add_option_handler(
        &m_part_count
            .add_name("--part-count")
            .add_name("-p")
            .set_description("split the render script in that many parts")
            .set_syntax("count")
            .set_exact_value_count(1)
            .set_default_value(1));

    parser().add_option_handler(
        &m_camera_target
            .add_name("--target")
            .add_name("-t")
            .set_description("set the target of the camera relatively to the center of the scene")
            .set_syntax("x y z")
            .set_exact_value_count(3)
            .set_default_values(make_vector(0.0, 0.0, 0.0)));

    parser().add_option_handler(
        &m_camera_distance
            .add_name("--distance")
            .add_name("-d")
            .set_description("set the normalized distance from the camera to the scene")
            .set_syntax("scalar")
            .set_exact_value_count(1)
            .set_default_value(10.0));

    parser().add_option_handler(
        &m_camera_elevation
            .add_name("--elevation")
            .add_name("-e")
            .set_description("set the normalized elevation of the camera")
            .set_syntax("scalar")
            .set_exact_value_count(1)
            .set_default_value(2.0));
}
コード例 #7
0
TEST(bit_index_storage, mix) {
    bit_index_storage s1, s2, s3;
    s1.set_row("r1", make_vector("0101"));
    s1.set_row("r2", make_vector("1010"));
    string d1;
    s1.get_diff(d1);

    s2.set_row("r1", make_vector("1110"));
    s2.set_row("r3", make_vector("1100"));
    string d2;
    s2.get_diff(d2);

    s1.mix(d1, d2);

    // d2 is
    // r1: 0101 (s1)
    // r2: 1010 (s1)
    // r3: 1100 (s2)

    s3.set_row("r1", make_vector("1111"));
    s3.set_row("r2", make_vector("1111"));
    s3.set_row("r3", make_vector("1111"));
    s3.set_row("r4", make_vector("1111"));
    s3.set_mixed_and_clear_diff(d2);

    // r1, r2 and r3 are overwritten by d2
    // r4 is no longer retained

    bit_vector v;
    s3.get_row("r1", v);
    EXPECT_TRUE(v == make_vector("0101"));
    s3.get_row("r2", v);
    EXPECT_TRUE(v == make_vector("1010"));
    s3.get_row("r3", v);
    EXPECT_TRUE(v == make_vector("1100"));
    s3.get_row("r4", v);
    EXPECT_TRUE(v == bit_vector());
}
コード例 #8
0
void GripperSelTransform::MakeMatrix ( const double* from, const double* to, const double* object_m, gp_Trsf& mat )
{
	mat = gp_Trsf();
	switch ( m_data.m_type )
	{
	case GripperTypeTranslate:
		mat.SetTranslation ( gp_Vec ( make_point ( from ), make_point ( to ) ) );
		break;
	case GripperTypeScale:
		{
			gp_Trsf object_mat = make_matrix(object_m);
			gp_Pnt scale_centre_point = gp_Pnt(0, 0, 0).Transformed(object_mat);
			double dist = make_point ( from ).Distance ( scale_centre_point );
			if ( dist<0.00000001 )
			{
				return;
			}
			double scale = make_point ( to ).Distance ( scale_centre_point ) /dist;
			mat.SetScale( scale_centre_point, scale );
		}
		break;
	case GripperTypeObjectScaleX:
		{
			gp_Trsf object_mat = make_matrix(object_m);
			gp_Vec object_x = gp_Vec(1, 0, 0).Transformed(object_mat).Normalized();
			gp_Pnt scale_centre_point = gp_Pnt(0, 0, 0).Transformed(object_mat);
			double old_x = make_vector(from) * object_x - gp_Vec(scale_centre_point.XYZ()) * object_x;
			double new_x = make_vector(to) * object_x - gp_Vec(scale_centre_point.XYZ()) * object_x;
			if(fabs(old_x) < 0.000000001)return;
			double scale = new_x/old_x;
			double m[16] = {scale, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
			mat = object_mat * make_matrix(m) * object_mat.Inverted();
		}
		break;
	case GripperTypeObjectScaleY:
		{
			gp_Trsf object_mat = make_matrix(object_m);
			gp_Vec object_y = gp_Vec(0, 1, 0).Transformed(object_mat).Normalized();
			gp_Pnt scale_centre_point = gp_Pnt(0, 0, 0).Transformed(object_mat);
			double old_y = make_vector(from) * object_y - gp_Vec(scale_centre_point.XYZ()) * object_y;
			double new_y = make_vector(to) * object_y - gp_Vec(scale_centre_point.XYZ()) * object_y;
			if(fabs(old_y) < 0.000000001)return;
			double scale = new_y/old_y;
			double m[16] = {1, 0, 0, 0, 0, scale, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
			mat = object_mat * make_matrix(m) * object_mat.Inverted();
		}
		break;
	case GripperTypeObjectScaleZ:
		{
			gp_Trsf object_mat = make_matrix(object_m);
			gp_Vec object_z = gp_Vec(0, 0, 1).Transformed(object_mat).Normalized();
			gp_Pnt scale_centre_point = gp_Pnt(0, 0, 0).Transformed(object_mat);
			double old_z = make_vector(from) * object_z - gp_Vec(scale_centre_point.XYZ()) * object_z;
			double new_z = make_vector(to) * object_z - gp_Vec(scale_centre_point.XYZ()) * object_z;
			if(fabs(old_z) < 0.000000001)return;
			double scale = new_z/old_z;
			double m[16] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, scale, 0, 0, 0, 0, 1};
			mat = object_mat * make_matrix(m) * object_mat.Inverted();
		}
		break;
	case GripperTypeObjectScaleXY:
		{
			gp_Trsf object_mat = make_matrix(object_m);
			gp_Vec object_x = gp_Vec(1, 0, 0).Transformed(object_mat).Normalized();
			gp_Pnt scale_centre_point = gp_Pnt(0, 0, 0).Transformed(object_mat);
			double old_x = make_vector(from) * object_x - gp_Vec(scale_centre_point.XYZ()) * object_x;
			double new_x = make_vector(to) * object_x - gp_Vec(scale_centre_point.XYZ()) * object_x;
			if(fabs(old_x) < 0.000000001)return;
			double scale = new_x/old_x;
			double m[16] = {scale, 0, 0, 0, 0, scale, 0, 0, 0, 0, scale, 0, 0, 0, 0, scale};
			mat = object_mat * make_matrix(m) * object_mat.Inverted();
		}
		break;
	case GripperTypeRotate:
	case GripperTypeRotateObject:
	case GripperTypeRotateObjectXY:
	case GripperTypeRotateObjectXZ:
	case GripperTypeRotateObjectYZ:
		{
			gp_Trsf object_mat = make_matrix(object_m);
			gp_Pnt rotate_centre_point = gp_Pnt(0, 0, 0).Transformed(object_mat);
			gp_Vec start_to_end_vector(make_point(from), make_point(to));
			if ( start_to_end_vector.Magnitude() <0.000001 ) return;
			gp_Vec start_vector ( rotate_centre_point, make_point ( from ) );
			gp_Vec end_vector ( rotate_centre_point, make_point ( to ) );
			if ( start_vector.Magnitude() <0.000001 ) return;
			if ( end_vector.Magnitude() <0.000001 ) return;
			mat.SetTranslation ( -gp_Vec ( rotate_centre_point.XYZ() ) );

			gp_Vec vx, vy;
			wxGetApp().m_current_viewport->m_view_point.GetTwoAxes(vx, vy, false, 0);			
			gp_Vec rot_dir = vx ^ vy;
			rot_dir.Normalize();

			if(m_data.m_type == GripperTypeRotateObjectXY){
				// use object z axis
				gp_Vec object_x = gp_Vec(1, 0, 0).Transformed(object_mat).Normalized();
				gp_Vec object_y = gp_Vec(0, 1, 0).Transformed(object_mat).Normalized();
				gp_Vec object_z = gp_Vec(0, 0, 1).Transformed(object_mat).Normalized();
				rot_dir = object_z;
				vx = object_x;
				vy = object_y;
			}

			else if(m_data.m_type == GripperTypeRotateObjectXZ){
				// use object y axis
				gp_Vec object_x = gp_Vec(1, 0, 0).Transformed(object_mat).Normalized();
				gp_Vec object_y = gp_Vec(0, 1, 0).Transformed(object_mat).Normalized();
				gp_Vec object_z = gp_Vec(0, 0, 1).Transformed(object_mat).Normalized();
				rot_dir = object_y;
				vx = object_z;
				vy = object_x;
			}

			else if(m_data.m_type == GripperTypeRotateObjectYZ){
				// use object x axis
				gp_Vec object_x = gp_Vec(1, 0, 0).Transformed(object_mat).Normalized();
				gp_Vec object_y = gp_Vec(0, 1, 0).Transformed(object_mat).Normalized();
				gp_Vec object_z = gp_Vec(0, 0, 1).Transformed(object_mat).Normalized();
				rot_dir = object_x;
				vx = object_y;
				vy = object_z;
			}

			else if(m_data.m_type == GripperTypeRotateObject){
				// choose the closest object axis to use
				gp_Vec object_x = gp_Vec(1, 0, 0).Transformed(object_mat).Normalized();
				gp_Vec object_y = gp_Vec(0, 1, 0).Transformed(object_mat).Normalized();
				gp_Vec object_z = gp_Vec(0, 0, 1).Transformed(object_mat).Normalized();

				double dpx = fabs(rot_dir * object_x);
				double dpy = fabs(rot_dir * object_y);
				double dpz = fabs(rot_dir * object_z);
				if(dpx > dpy && dpx > dpz){
					// use object x axis
					rot_dir = object_x;
					vx = object_y;
					vy = object_z;
				}
				else if(dpy > dpz){
					// use object y axis
					rot_dir = object_y;
					vx = object_z;
					vy = object_x;
				}
				else{
					// use object z axis
					rot_dir = object_z;
					vx = object_x;
					vy = object_y;
				}
			}

			gp_Ax1 rot_axis(rotate_centre_point, rot_dir);
			double sx = start_vector * vx;
			double sy = start_vector * vy;
			double ex = end_vector * vx;
			double ey = end_vector * vy;
			double angle = gp_Vec(sx, sy, 0).AngleWithRef(gp_Vec(ex, ey, 0), gp_Vec(0,0,1));
			mat.SetRotation(rot_axis, angle);
		}
		break;
	default:
		break;
	}
}
コード例 #9
0
ファイル: FireParticle.cpp プロジェクト: Bubbers/SpaceBubba
float3 FireParticle::accelerate(float3 velocity) {
    return make_vector(.9f * velocity.x, 1.06f * velocity.y, .9f * velocity.z);
}
コード例 #10
0
int OperationFailed(const string& Object, LNGID Title, const string& Description, bool AllowSkip)
{
	std::vector<string> Msg;
	IFileIsInUse *pfiu = nullptr;
	LNGID Reason = MObjectLockedReasonOpened;
	bool SwitchBtn = false, CloseBtn = false;
	DWORD Error = Global->CaughtError();
	if(Error == ERROR_ACCESS_DENIED ||
		Error == ERROR_SHARING_VIOLATION ||
		Error == ERROR_LOCK_VIOLATION ||
		Error == ERROR_DRIVE_LOCKED)
	{
		string FullName;
		ConvertNameToFull(Object, FullName);
		pfiu = CreateIFileIsInUse(FullName);
		if (pfiu)
		{
			FILE_USAGE_TYPE UsageType = FUT_GENERIC;
			pfiu->GetUsage(&UsageType);
			switch(UsageType)
			{
			case FUT_PLAYING:
				Reason = MObjectLockedReasonPlayed;
				break;
			case FUT_EDITING:
				Reason = MObjectLockedReasonEdited;
				break;
			case FUT_GENERIC:
				Reason = MObjectLockedReasonOpened;
				break;
			}
			DWORD Capabilities = 0;
			pfiu->GetCapabilities(&Capabilities);
			if(Capabilities&OF_CAP_CANSWITCHTO)
			{
				SwitchBtn = true;
			}
			if(Capabilities&OF_CAP_CANCLOSE)
			{
				CloseBtn = true;
			}
			LPWSTR AppName = nullptr;
			if(SUCCEEDED(pfiu->GetAppName(&AppName)))
			{
				Msg.emplace_back(AppName);
			}
		}
		else
		{
			DWORD dwSession;
			WCHAR szSessionKey[CCH_RM_SESSION_KEY+1] = {};
			if (Imports().RmStartSession(&dwSession, 0, szSessionKey) == ERROR_SUCCESS)
			{
				PCWSTR pszFile = FullName.data();
				if (Imports().RmRegisterResources(dwSession, 1, &pszFile, 0, nullptr, 0, nullptr) == ERROR_SUCCESS)
				{
					DWORD dwReason;
					DWORD RmGetListResult;
					UINT nProcInfoNeeded;
					UINT nProcInfo = 1;
					std::vector<RM_PROCESS_INFO> rgpi(nProcInfo);
					while((RmGetListResult=Imports().RmGetList(dwSession, &nProcInfoNeeded, &nProcInfo, rgpi.data(), &dwReason)) == ERROR_MORE_DATA)
					{
						nProcInfo = nProcInfoNeeded;
						rgpi.resize(nProcInfo);
					}
					if(RmGetListResult ==ERROR_SUCCESS)
					{
						for (size_t i = 0; i < nProcInfo; i++)
						{
							string tmp = rgpi[i].strAppName;
							if (*rgpi[i].strServiceShortName)
							{
								tmp.append(L" [").append(rgpi[i].strServiceShortName).append(L"]");
							}
							tmp += L" (PID: " + std::to_wstring(rgpi[i].Process.dwProcessId);
							HANDLE hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, rgpi[i].Process.dwProcessId);
							if (hProcess)
							{
								FILETIME ftCreate, ftExit, ftKernel, ftUser;
								if (GetProcessTimes(hProcess, &ftCreate, &ftExit, &ftKernel, &ftUser) && rgpi[i].Process.ProcessStartTime == ftCreate)
								{
									string Name;
									if (os::GetModuleFileNameEx(hProcess, nullptr, Name))
									{
										tmp += L", " + Name;
									}
								}
								CloseHandle(hProcess);
							}
							tmp += L")";
							Msg.emplace_back(tmp);
						}
					}
				}
				Imports().RmEndSession(dwSession);
			}
		}
	}

	auto Msgs = make_vector(Description, QuoteLeadingSpace(string(Object)));
	if(!Msg.empty())
	{
		Msgs.emplace_back(LangString(MObjectLockedReason) << MSG(Reason));
		Msgs.insert(Msgs.end(), ALL_CONST_RANGE(Msg));
	}

	std::vector<string> Buttons;
	Buttons.reserve(4);
	if(SwitchBtn)
	{
		Buttons.emplace_back(MSG(MObjectLockedSwitchTo));
	}
	Buttons.emplace_back(MSG(CloseBtn? MObjectLockedClose : MDeleteRetry));
	if(AllowSkip)
	{
		Buttons.emplace_back(MSG(MDeleteSkip));
		Buttons.emplace_back(MSG(MDeleteFileSkipAll));
	}
	Buttons.emplace_back(MSG(MDeleteCancel));

	int Result = -1;
	for(;;)
	{
		Result = Message(MSG_WARNING|MSG_ERRORTYPE, MSG(Title), Msgs, Buttons);

		if(SwitchBtn)
		{
			if(Result == 0)
			{
				HWND Wnd = nullptr;
				if (pfiu && SUCCEEDED(pfiu->GetSwitchToHWND(&Wnd)))
				{
					SetForegroundWindow(Wnd);
					if (IsIconic(Wnd))
						ShowWindow(Wnd, SW_RESTORE);
				}
				continue;
			}
			else if(Result > 0)
			{
				--Result;
			}
		}

		if(CloseBtn && Result == 0)
		{
			// close & retry
			if (pfiu)
			{
				pfiu->CloseFile();
			}
		}
		break;
	}

	if (pfiu)
	{
		pfiu->Release();
	}

	return Result;
}
コード例 #11
0
void ReCompileErrorMessage(const RegExp& re, const string& str)
{
	Message(MSG_WARNING | MSG_LEFTALIGN, MSG(MError),
		make_vector(GetReErrorString(re.LastError()), str, string(re.ErrorPosition(), L' ') + L'^'),
		make_vector<string>(MSG(MOk)));
}
コード例 #12
0
const float3 float3x3::operator * (const float3& v) const
{
  return make_vector(c1[0]*v.x + c2[0]*v.y + c3[0]*v.z,  
		c1[1]*v.x + c2[1]*v.y + c3[1]*v.z, 
		c1[2]*v.x + c2[2]*v.y + c3[2]*v.z);
}
コード例 #13
0
namespace Graphics {

Vector2ui screen_size = make_vector(800U, 600U);
bool fullscreen = false;

namespace { //private-type variables.
SDL_Surface *surface = NULL;
bool sub_inited = false;
bool inited = false;
} //end anon namespace

bool init(int flags) {
	
	if (SDL_InitSubSystem(SDL_INIT_VIDEO) == 0) {
		sub_inited = true;
		
		SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8);
		SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8);
		SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8);
		if (flags & NEED_ACCUM) {
			SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 16);
			SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 16);
			SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 16);
		}
		//SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8);
		//SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, 32);
		SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24);
		if (flags & NEED_STENCIL) {
			SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8);
		}
		SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1);
		if (flags & WANT_VSYNC) {
			#ifdef SDL_GL_SWAP_CONTROL
			SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1);
			#else
			cerr << "Using a version of SDL that doesn't support VSYNC." << endl;
			#endif
		}
		if (flags & WANT_MULTISAMPLE4) {
			SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
			SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4 );
		}
		if (flags & WANT_MULTISAMPLE8) {
			SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
			SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 8 );
		}
		if (flags & WANT_MULTISAMPLE16) {
			SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
			SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 16 );
		}

		if (fullscreen) {
			surface = SDL_SetVideoMode(screen_size.x, screen_size.y, 24, SDL_OPENGL | SDL_FULLSCREEN);
		} else {
			surface = SDL_SetVideoMode(screen_size.x, screen_size.y, 24, SDL_OPENGL);
		}

		if (surface) {
			inited = true;
		} else {
			cerr << "Could not create video surface: " << SDL_GetError() << endl;
		}
	} else {
		cerr << "Could not init video: " << SDL_GetError() << endl;
	}

	if (sub_inited && !inited) {
		deinit();
	}

	return inited;

}

void deinit() {
	if (sub_inited) {
		SDL_QuitSubSystem(SDL_INIT_VIDEO);
		sub_inited = false;
		inited = false;
		surface = NULL;
	}
}

void gl_errors(string const &where) {
	GLuint err;
	while ((err = glGetError()) != GL_NO_ERROR) {
	cerr << "(in " << where << ") OpenGL error #" << err
	     << ": " << gluErrorString(err) << endl;
	}
}

}
コード例 #14
0
ファイル: print.c プロジェクト: byeah/cs294_hw
void vm_init(Program* p) {
    global_vars = ht_create(13);
    operand = make_vector();
}
コード例 #15
0
ファイル: yssloader.cpp プロジェクト: cyberwarriorx/yssloader
void find_bios_funcs()
{
	ea_t i;
	make_ascii_string(0x06000200, 16, ASCSTR_C);
	doByte(0x06000210, 36);
	make_vector(0x06000234, NULL);
	make_vector(0x06000238, NULL);
	make_vector(0x0600023C, NULL);
	make_ascii_string(0x06000240, 4, ASCSTR_C);
	make_ascii_string(0x06000244, 4, ASCSTR_C);
	doDwrd(0x06000248, 4);
	doDwrd(0x0600024C, 4);
	make_vector(0x06000250, NULL);
	doDwrd(0x06000264, 4);
	make_vector(0x06000268, NULL);
	make_vector(0x0600026C, "bios_run_cd_player");
	make_vector(0x06000270, NULL);
	make_vector(0x06000274, "bios_is_mpeg_card_present");
	doDwrd(0x06000278, 4);
	doDwrd(0x0600027C, 4);
	make_vector(0x06000280, NULL);
	make_vector(0x06000284, NULL);
	make_vector(0x06000288, NULL);
	make_vector(0x0600028C, NULL);
	doDwrd(0x06000290, 4);
	doDwrd(0x06000294, 4);
	make_vector(0x06000298, "bios_get_mpeg_rom");
	make_vector(0x0600029C, NULL);
	doDwrd(0x060002A0, 4);
	doDwrd(0x060002A4, 4);
	doDwrd(0x060002A8, 4);
	doDwrd(0x060002AC, 4);
	make_vector(0x060002B0, NULL);
	doDwrd(0x060002B4, 4);
	doDwrd(0x060002B8, 4);
	doDwrd(0x060002BC, 4);
	doDwrd(0x060002C0, 4);
	for (i = 0x060002C4; i < 0x06000324; i+=4)
		make_vector(i, NULL);
	set_name(0x06000300, "bios_set_scu_interrupt");
	set_name(0x06000304, "bios_get_scu_interrupt");
	set_name(0x06000310, "bios_set_sh2_interrupt");
	set_name(0x06000314, "bios_get_sh2_interrupt");
	set_name(0x06000320, "bios_set_clock_speed");
	doDwrd(0x06000324, 4);
	set_name(0x06000324, "bios_get_clock_speed");
	for (i = 0x06000328; i < 0x06000348; i+=4)
		make_vector(i, NULL);
	set_name(0x06000340, "bios_set_scu_interrupt_mask");
	set_name(0x06000344, "bios_change_scu_interrupt_mask");
	doDwrd(0x06000348, 4);
	set_name(0x06000348, "bios_get_scu_interrupt_mask");
	make_vector(0x0600034C, NULL);
	doDwrd(0x06000350, 4);
	doDwrd(0x06000354, 4);
	doDwrd(0x06000358, 4);
	doDwrd(0x0600035C, 4);
	for (i = 0x06000360; i < 0x06000380; i+=4)
		make_vector(i, NULL);
	doByte(0x06000380, 16);
	doWord(0x06000390, 16);
	doDwrd(0x060003A0, 32);
	make_ascii_string(0x060003C0, 0x40, ASCSTR_C);
	add_func(0x06000600, BADADDR);
	add_func(0x06000646, BADADDR);
	make_ascii_string(0x0600065C, 0x4, ASCSTR_C);
	add_func(0x06000678, BADADDR);
	add_func(0x0600067C, BADADDR);
	add_func(0x06000690, BADADDR);
	doDwrd(0x06000A80, 0x80);
}
コード例 #16
0
ファイル: FireParticle.cpp プロジェクト: Bubbers/SpaceBubba
float3 FireParticle::calcParticleScale() {
    return make_vector(.1f, .1f, .1f);
}
コード例 #17
0
ファイル: yssloader.cpp プロジェクト: cyberwarriorx/yssloader
void load_68k_data(linput_t *li)
{
	int version;
	int csize;
	ea_t pc;

	if (!load_header(li))
		return;

	if (StateCheckRetrieveHeader(li, "CART", &version, &csize) != 0)
	{
		error("Invalid CART chunk");
		return;
	}
	qlseek(li, csize, SEEK_CUR);

	if (StateCheckRetrieveHeader(li, "CS2 ", &version, &csize) != 0)
	{
		error("Invalid CS2 chunk");
		return;
	}
	qlseek(li, csize, SEEK_CUR);

	if (StateCheckRetrieveHeader(li, "MSH2", &version, &csize) != 0)
	{
		error("Invalid MSH2 chunk");
		return;
	}
	qlseek(li, csize, SEEK_CUR);

	if (StateCheckRetrieveHeader(li, "SSH2", &version, &csize) != 0)
	{
		error("Invalid SSH2 chunk");
		return;
	}
	qlseek(li, csize, SEEK_CUR);

	if (StateCheckRetrieveHeader(li, "SCSP", &version, &csize) != 0)
	{
		error("Invalid SCSP chunk");
		return;
	}
	SoundLoadState(li, &pc, csize);

	if (StateCheckRetrieveHeader(li, "SCU ", &version, &csize) != 0)
	{
		error("Invalid SCU chunk");
		return;
	}
	qlseek(li, csize, SEEK_CUR);

	if (StateCheckRetrieveHeader(li, "SMPC", &version, &csize) != 0)
	{
		error("Invalid SMPC chunk");
		return;
	}
	qlseek(li, csize, SEEK_CUR);

	if (StateCheckRetrieveHeader(li, "VDP1", &version, &csize) != 0)
	{
		error("Invalid VDP1 chunk");
		return;
	}
	qlseek(li, csize, SEEK_CUR);

	if (StateCheckRetrieveHeader(li, "VDP2", &version, &csize) != 0)
	{
		error("Invalid VDP2 chunk");
		return;
	}
	qlseek(li, csize, SEEK_CUR);

	if (StateCheckRetrieveHeader(li, "OTHR", &version, &csize) != 0)
	{
		error("Invalid OTHR chunk");
		return;
	}

	for (int i = 0x000004; i < 0x0000EC; i+=4)
		make_vector(i, NULL);

	// move cursor to current 68K PC
	jumpto(pc);
}
コード例 #18
0
ファイル: FireParticle.cpp プロジェクト: Bubbers/SpaceBubba
float3 FireParticle::initialPosition() {
    float rand = getRand(0.0f, 360.0f);
    float rand2  = getRand(0.0f, 0.3f);
	return make_vector((float)cos(rand) * rand2, (float)sin(rand) * rand2, 0.0f);
}
コード例 #19
0
ファイル: vector.c プロジェクト: amuthaOlin/SoftwareSystems
// Adds two vectors elementwise and returns a new vector.
Vector *add_vector_func(Vector *A, Vector *B) {
    Vector *C = make_vector(A->len);
    add_vector(A, B, C);
    return C;
}
コード例 #20
0
ファイル: FireParticle.cpp プロジェクト: Bubbers/SpaceBubba
float3 FireParticle::initialVelocity() {
    return make_vector(getRand(-.5f, .5f), getRand(0.0f, 1.0f), getRand(-.5f, .5f));
}
コード例 #21
0
ファイル: vm0.cpp プロジェクト: LordJagged/ypsilon
void
VM::stop()
{
    #define ARGC_TH     8
    collector_usage_t last_usage = m_heap->m_usage;
    if (last_usage.m_recorded) m_heap->m_usage.clear();
    double t1 = msec();
#if HPDEBUG
    if (m_heap->m_root_snapshot == ROOT_SNAPSHOT_CONSISTENCY_CHECK) save_stack();
#endif
    if ((m_heap->m_root_snapshot == ROOT_SNAPSHOT_EVERYTHING) ||
        (m_heap->m_root_snapshot == ROOT_SNAPSHOT_RETRY) ||
        (m_heap->m_root_snapshot == ROOT_SNAPSHOT_GLOBALS)) {
        m_heap->enqueue_root(m_bootport);
        m_heap->enqueue_root(m_current_input);
        m_heap->enqueue_root(m_current_output);
        m_heap->enqueue_root(m_current_error);
        m_heap->enqueue_root(m_current_exception_handler);
        m_heap->enqueue_root(m_current_environment);
        m_heap->enqueue_root(m_current_dynamic_environment);
        m_heap->enqueue_root(m_current_dynamic_wind_record);
        m_heap->enqueue_root(m_current_source_comments);
    }
    if ((m_heap->m_root_snapshot == ROOT_SNAPSHOT_EVERYTHING) ||
        (m_heap->m_root_snapshot == ROOT_SNAPSHOT_RETRY) ||
        (m_heap->m_root_snapshot == ROOT_SNAPSHOT_LOCALS)) {
        save_stack();
        m_heap->enqueue_root(m_pc);
        m_heap->enqueue_root(m_value);
        m_heap->enqueue_root(m_trace);
        m_heap->enqueue_root(m_trace_tail);
        if (m_fp != m_sp) {
            int argc = m_sp - m_fp;
            if (argc > ARGC_TH) {
                scm_vector_t vector = make_vector(m_heap, argc, scm_nil);
                for (int i = 0; i < argc; i++) vector->elts[i] = m_fp[i];
                m_heap->enqueue_root(vector);
            } else {
                for (int i = 0; i < argc; i++) m_heap->enqueue_root(m_fp[i]);
            }
        }
        if (m_cont) {
            assert(m_heap->is_collectible(m_cont));
            m_heap->enqueue_root(OBJECT_SLAB_TRAITS_OF(m_cont)->cache->lookup(m_cont));
        }
        if (m_env) {
            assert(m_heap->is_collectible(m_env));
            m_heap->enqueue_root(OBJECT_SLAB_TRAITS_OF(m_env)->cache->lookup(m_env));
        }
    }
#if USE_PARALLEL_VM
    if (m_interp->live_thread_count() > 1) {
        if (m_heap->m_root_snapshot == ROOT_SNAPSHOT_EVERYTHING) m_interp->snapshot(this, false);
        if (m_heap->m_root_snapshot == ROOT_SNAPSHOT_RETRY) m_interp->snapshot(this, true);
    }
#endif
    m_heap->m_collector_lock.lock();
    while (m_heap->m_stop_the_world) {
        m_heap->m_mutator_stopped = true;
        m_heap->m_collector_wake.signal();
        m_heap->m_mutator_wake.wait(m_heap->m_collector_lock);
        m_heap->m_mutator_stopped = false;
    }
    m_heap->m_collector_wake.signal();
    m_heap->m_collector_lock.unlock();
    double t2 = msec();
    switch (m_heap->m_root_snapshot) {
        case ROOT_SNAPSHOT_GLOBALS:
            m_heap->m_usage.m_pause1 = t2 - t1;
            break;
        case ROOT_SNAPSHOT_LOCALS:
            m_heap->m_usage.m_pause2 = t2 - t1;
            break;
        case ROOT_SNAPSHOT_RETRY:
        case ROOT_SNAPSHOT_EVERYTHING: {
            double d = t2 - t1;
            if (d > m_heap->m_usage.m_pause3) m_heap->m_usage.m_pause3 = d;
        } break;
    }

    char usage[128];
    if (flags.m_collect_notify != scm_false) {
        if (last_usage.m_recorded) {
            if (DETAILED_STATISTIC) {
                if (last_usage.m_synchronized) {
                    snprintf(usage,
                             sizeof(usage),
                             ";; [collect synchronize: %.2fms]",
                             last_usage.m_duration);
                } else {
                    snprintf(usage,
                            sizeof(usage),
                             ";; [collect concurrent: %.2fms sync: %.2fms/%.2fms pause: %.2fms/%.2fms/%.2fms barrier: %dR/%dW/%dA]",
                             last_usage.m_duration,
                             last_usage.m_sync1,
                             last_usage.m_sync2,
                             last_usage.m_pause1,
                             last_usage.m_pause2,
                             last_usage.m_pause3,
                             last_usage.m_barriered_read,
                             last_usage.m_barriered_write,
                             last_usage.m_barriered_alloc);
                }
            } else {
                if (last_usage.m_synchronized) {
                    snprintf(usage,
                             sizeof(usage),
                             ";; [collect synchronize: %.2fms]",
                             last_usage.m_duration);
                } else {
                    snprintf(usage,
                             sizeof(usage),
                             ";; [collect concurrent: %.2fms pause: %.2fms/%.2fms/%.2fms]",
                             last_usage.m_duration,
                             last_usage.m_pause1,
                             last_usage.m_pause2,
                             last_usage.m_pause3);
                }
            }
            scoped_lock lock(m_current_output->lock);
            printer_t prt(this, m_current_output);
            prt.format("~&%s", usage);
            if (last_usage.m_shade_queue_hazard) prt.format("[shade queue overflow: %d]", last_usage.m_shade_queue_hazard);
            if (last_usage.m_expand_mark_stack) prt.format("[mark stack overflow: %d]", last_usage.m_expand_mark_stack);
            prt.format("~%~!");
        }
    } else {
        if (last_usage.m_recorded) {
            if (CONCURRENT_COLLECT) {
                if (last_usage.m_synchronized) {
                    snprintf(usage,
                             sizeof(usage),
                             "warning: low heap memory (collect: %.2fms)",
                             last_usage.m_duration);
                    scoped_lock lock(m_current_error->lock);
                    printer_t prt(this, m_current_error);
                    prt.format("~&%s~%~!", usage);
                }
            }
        }
    }
}
コード例 #22
0
ファイル: display.c プロジェクト: apinkney97/JSReflow
static void
digitize_spline (spline_type s)
{
    coordinate_type start = real_cartesian_to_offset_x (START_POINT (s)),
                    control1 = real_cartesian_to_offset_x (CONTROL1 (s)),
                    control2 = real_cartesian_to_offset_x (CONTROL2 (s)),
                    end = real_cartesian_to_offset_x (END_POINT (s));

    /* These a_i are the coefficients of the polynomial
       p(t) = a_3 t^3 + a_2 t^2 + a_1 t + a_0,
       computed by expanding the Bernshte\u in polynomial
       z(t) = (1 - t)^3z_1 + 3(1 - t)^2tz_2 + 3(1 - t)t^2z_3 + t^3z_4,
       where z_1 is the starting point of the spline, z_2 and z_3 the
       control points, and z_4 the ending point.  We have two such
       polynomials p(t), one for the x-coordinate, one for the
       y-coordinate.  So everything here is done with points and vectors,
       instead of just numbers.

       a_0 = x_0
       a_1 = 3(x_1 - x_0)
       a_2 = 3(x_0 + x_2 - 2x_1)
       a_3 = x_3 - x_0 + 3(x_1 - x_2)  */

    coordinate_type /* a0 = start, */
    a1 = IPmult_scalar (IPsubtractP (control1, start), 3),
    a2 = IPmult_scalar (IPsubtractP (IPadd (start, control2),
                                     IPmult_scalar (control1, 2)),
                        3),
         a3 = IPadd (IPsubtractP (end, start),
                     IPmult_scalar (IPsubtractP (control1, control2), 3));

    /* The step size.  We want to use the length of the bounding rectangle
       to compute this, instead of the distance between the starting point
       and the ending point, since the latter will be zero if the spline
       is cyclic.  */
    real factor = int_distance (control1, start)
                  + int_distance (control2, control1)
                  + int_distance (end, control2)
                  + int_distance (start, end),
                  /* Avoid division by zero, in pathological cases.  (We will just
                     produce one point.  */
                  delta = 1.0 / MAX (factor, 1),
                  delta_squared = delta * delta,
                  delta_cubed = delta_squared * delta;

    /* The current position.  */
    coordinate_type p = start,
                    previous_p = { start.x - 1, 0 };
    /* The real current position.  */
    real_coordinate_type real_p = int_to_real_coord (p);

    /* The first three forward differences evaluated at t = 0.  */
    vector_type d = make_vector (Padd (IPmult_real (a3, delta_cubed),
                                       Padd (IPmult_real (a2, delta_squared),
                                               IPmult_real (a1, delta)))),
                    d2 = make_vector (Padd (IPmult_real (a3, 6 * delta_cubed),
                                            IPmult_real (a2, 2 * delta_squared))),
                         d3 = make_vector (IPmult_real (a3, 6 * delta_cubed));

    /* Where we will collect the points to output.  */
    unsigned point_count = 0;
    XPoint point_list[(unsigned) (1.0 / delta) + 1];

    real t;

    for (t = 0.0; t <= 1.0; t += delta)
    {
        if (!IPequal (p, previous_p))
        {
            point_list[point_count].x = p.x;
            point_list[point_count].y = p.y;
            point_count++;
            previous_p = p;
        }

        /* We must keep track of the current position in unrounded
           coordinates, so the calculations do not lose precision.  */
        real_p = Padd_vector (real_p, d);
        p.x = ROUND (real_p.x);
        p.y = ROUND (real_p.y);
        d = Vadd (d, d2);
        d2 = Vadd (d2, d3);
        /* d3 is constant with respect to t.  */
    }

#if 0
    /* GDB under system V doesn't grok XPoint, so here's a way to print
       out the points we find.  */
    {
        unsigned i;
        for (i = 0; i < point_count; i++)
            printf ("(%d,%d)", point_list[i].x, point_list[i].y);
        puts ("");
    }
#endif

    XDrawPoints (display, pixmap, gc, point_list, point_count,
                 CoordModeOrigin);
}
コード例 #23
0
ファイル: Tree.cpp プロジェクト: ChuanonlyGame/traingame
void Tree::set_position(float x, float y, float z)
{
   position = make_vector(x, y, z);
}
コード例 #24
0
static ColorList grayscale_color_table(){
  return make_vector(make_closed_range(0, 255), grayscale_rgb);
}
コード例 #25
0
ファイル: Character.cpp プロジェクト: getarobo/Simulation
void State::apply_to(Pose &pose) const {
	Quatf rot = rotation(orientation, make_vector(0.0f, 1.0f, 0.0f));
	pose.root_position = rotate(pose.root_position, rot) + position;
	pose.root_orientation = multiply(rot, pose.root_orientation);
}
コード例 #26
0
ファイル: operator.c プロジェクト: FunnyLanguage/funny
//符号列表初始化
static Cell* oblist_initial_value(Scheme *sc) {
	return make_vector(sc, 461); /* probably should be bigger */
}
コード例 #27
0
ファイル: Particle.cpp プロジェクト: awesson/cloth-sim
void Particle::reset()
{
	Position = ConstructPos;
	Velocity = make_vector(0.0, 0.0, 0.0);
    forces = make_vector(0.0, 0.0, 0.0);
}
コード例 #28
0
ファイル: window.hpp プロジェクト: kfrlib/kfr
 expression_kaiser(size_t size, T beta = 0.5, window_symmetry symmetry = window_symmetry::symmetric)
     : linspace(size, symmetry), beta(beta), m(reciprocal(modzerobessel(make_vector(beta))[0])),
       m_size(size)
 {
 }
コード例 #29
0
tree
streamer_alloc_tree (struct lto_input_block *ib, struct data_in *data_in,
		     enum LTO_tags tag)
{
  enum tree_code code;
  tree result;
#ifdef LTO_STREAMER_DEBUG
  HOST_WIDEST_INT orig_address_in_writer;
#endif

  result = NULL_TREE;

#ifdef LTO_STREAMER_DEBUG
  /* Read the word representing the memory address for the tree
     as it was written by the writer.  This is useful when
     debugging differences between the writer and reader.  */
  orig_address_in_writer = streamer_read_hwi (ib);
  gcc_assert ((intptr_t) orig_address_in_writer == orig_address_in_writer);
#endif

  code = lto_tag_to_tree_code (tag);

  /* We should never see an SSA_NAME tree.  Only the version numbers of
     SSA names are ever written out.  See input_ssa_names.  */
  gcc_assert (code != SSA_NAME);

  /* Instantiate a new tree using the header data.  */
  if (CODE_CONTAINS_STRUCT (code, TS_STRING))
    result = streamer_read_string_cst (data_in, ib);
  else if (CODE_CONTAINS_STRUCT (code, TS_IDENTIFIER))
    result = input_identifier (data_in, ib);
  else if (CODE_CONTAINS_STRUCT (code, TS_VEC))
    {
      HOST_WIDE_INT len = streamer_read_hwi (ib);
      result = make_tree_vec (len);
    }
  else if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
    {
      HOST_WIDE_INT len = streamer_read_hwi (ib);
      result = make_vector (len);
    }
  else if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
    {
      unsigned HOST_WIDE_INT len = streamer_read_uhwi (ib);
      result = make_tree_binfo (len);
    }
  else if (code == CALL_EXPR)
    {
      unsigned HOST_WIDE_INT nargs = streamer_read_uhwi (ib);
      return build_vl_exp (CALL_EXPR, nargs + 3);
    }
  else
    {
      /* For all other nodes, materialize the tree with a raw
	 make_node call.  */
      result = make_node (code);
    }

#ifdef LTO_STREAMER_DEBUG
  /* Store the original address of the tree as seen by the writer
     in RESULT's aux field.  This is useful when debugging streaming
     problems.  This way, a debugging session can be started on
     both writer and reader with a breakpoint using this address
     value in both.  */
  lto_orig_address_map (result, (intptr_t) orig_address_in_writer);
#endif

  return result;
}
コード例 #30
0
ファイル: DisplayModule.hpp プロジェクト: ixchow/Preshack
	DisplayModule(std::string const &_prefix) : prefix(_prefix) {
		in_ports.push_back(&data);
		data.position = make_vector(-0.5f * size().x, 0.0f);
		data.name = "data";
	}