Esempio n. 1
0
int Jenarix::colorsphere( jx_ob ob )
{

    GLdouble xyz[3], r, rgb[3];
    unsigned int ixyz = 0;
    unsigned int irgb = 1;
    unsigned int irad = 2;
    assert (jx_list_check(ob));
    int nval = jx_list_size(ob);
    //printf ("%d sphere\n", nval);

    for ( int index = 0; index < nval; ++index ) {
      jx_ob xyz_rgb_rad = jx_list_shift(ob);
      glPushMatrix();
      //printf ("%d\n", value[index].size());
      get_point(jx_list_get(xyz_rgb_rad, ixyz), xyz);
      glTranslated(xyz[0], xyz[1], xyz[2]);
      get_point(jx_list_get(xyz_rgb_rad, irgb), rgb);
      color(rgb[0], rgb[1], rgb[2], 0.0);
      GLUquadricObj* quadric = gluNewQuadric();
      gluQuadricDrawStyle(quadric, GLU_FILL);
      gluQuadricOrientation(quadric, GLU_OUTSIDE);
      gluQuadricNormals(quadric, GLU_SMOOTH);
      //printf ("%f %f %f\n", xyz[0], xyz[1], xyz[2]);
      r = get_real(jx_list_get(xyz_rgb_rad, irad));
      gluSphere(quadric, r, 20, 20);
      //printf ("%f\n", r);
      gluDeleteQuadric(quadric);
      glPopMatrix();
    }

   return nval;
}
Guess DistanceSet::make_guess(int idx1, int idx2, const Point &p1, const Point &p2) const
{
	double c1 = get_point(idx1).get_euclidean_distance(p1);
	double c2 = get_point(idx2).get_euclidean_distance(p1);
	double cost = c1 + c2;
	return Guess { cost, TIME_PER_COORD * (c1 + c2) + get_time_between(idx1, idx2)};
}
double DistanceSet::get_average_time_per_coord() const
{
	double sum = 0;
	int size = get_num_points();
	int count = 0;
	for (int i = 0; i < size; i++)
	{
		for (int j = 0; j < size; j++)
		{
			if (i == j)
			{
				continue;
			}

			double di = get_point(i).get_euclidean_distance(get_point(j));
			double time = durations[i][j];

			if (di == 0)
			{
				continue;
			}

			sum += time / di;
			count++;
		}
	}
	return sum / count;
}
Esempio n. 4
0
void draw_string(_param p)
{
    double a, r, x, y;
    _point *O;
    _set *s;

    check_font();
    a = POPn;
    r = DEFAULT_DIST*local_size;
    if (p.addr) {
	s = POP(_set);
	O = get_point(&s);
	x = O->x;
	y = O->y;
	O = get_point(&s);
	x = (x + O->x)/2 + r*Cos(a);
	y = (y + O->y)/2 + r*Sin(a);
    } else {
	O = POP(_point);
	x = O->x + r*Cos(a);
	y = O->y + r*Sin(a);
    }
    fprintf(output_file, "\\rput(%.4f,%.4f){", x, y);
    put_font();
    fprintf(output_file, "%s}\n", POPs);
}
Esempio n. 5
0
// Global variables: tree, x, y, body, list, number, distance
// modified variables: list and number
void DorlingCartogram::get_point(int pointer, int axis, int body)
{
	if (pointer > 0) {
		if (tree[pointer].id > 0) {
			if (axis == 1) { 
				if (x[body]-distance < tree[pointer].xpos) {
					get_point(tree[pointer].right, 3-axis, body);
				}
				if (x[body]+distance >= tree[pointer].xpos) {
					get_point(tree[pointer].left, 3-axis, body);
				}
			}
			if (axis == 2) {
				if (y[body]-distance < tree[pointer].ypos) {
					get_point(tree[pointer].right, 3-axis, body);
				}
				if (y[body] + distance >= tree[pointer].ypos) {
					get_point(tree[pointer].left, 3-axis, body);
				}
			}
			if ((x[body]-distance < tree[pointer].xpos) && 
				(x[body]+distance >= tree[pointer].xpos)) {
				if ((y[body]-distance < tree[pointer].ypos) &&
					(y[body]+distance >= tree[pointer].ypos)) { 
					number += 1;
					list[number] = tree[pointer].id;
				}
			}
		}
	}
}
Esempio n. 6
0
void label_segment(void)
{
    double size, a, x, y;
    _set *s;
    _point *A, *B;

    s = POP(_set);
    A = get_point(&s);
    B = get_point(&s);
    size = SIZE(.1);
    a = argument(A, B);
    x = (A->x + B->x)/2;
    y = (A->y + B->y)/2;
    fprintf(output_file, "\\pscustom");
    put_local();
    fprintf(output_file, "{\\");
    switch (local_segment) {
	case SIMPLE:
	    fprintf(output_file, "Simple");
	    break;
	case DOUBLE:
	    fprintf(output_file, "Double");
	    break;
	case TRIPLE:
	    fprintf(output_file, "Triple");
	    break;
	case CROSS:
	    fprintf(output_file, "Cross");
	    a += 45;
	    break;
    }
    fprintf(output_file, "{%.4f}{%.4f}{%.4f}{%.4f}}\n", x, y, a, size);
}
Esempio n. 7
0
rectangle get_rectangle()
{
    point p1 = get_point();
    point p2 = get_point();
    point p3 = get_point(); 
    point p4 = get_point();
    return rectangle(p1, p2, p3, p4);
}
// src is rows*cols and dest is a 4-point array passed in already allocated!
void get_adjacents_1d(float *src, float *dest, uint8_t rows, uint8_t cols, int8_t x, int8_t y) {
    //Serial.print("("); Serial.print(x); Serial.print(", "); Serial.print(y); Serial.println(")");
    // pick two items to the left
    dest[0] = get_point(src, rows, cols, x-1, y);
    dest[1] = get_point(src, rows, cols, x, y);
    // pick two items to the right
    dest[2] = get_point(src, rows, cols, x+1, y);
    dest[3] = get_point(src, rows, cols, x+2, y);
}
Esempio n. 9
0
int get_point_normal( jx_ob ob, GLdouble xyz[3], GLdouble nml[3] ) {

    assert (jx_list_check(ob));
    assert (jx_list_size(ob) == 2);
    unsigned int ivertex = 0;
    unsigned int inormal = 1;
    get_point( jx_list_get(ob,ivertex), xyz );
    get_point( jx_list_get(ob,inormal), nml );

  return 2;
}
Esempio n. 10
0
static void exec_python(char *expr)
{

	if (ok2print)
		hide_cur(w_list);
	siag_row = get_point(w_list).row;
	siag_col = get_point(w_list).col;
	siag_buffer = w_list->buf;
	siag_sht = w_list->sht;
	PyRun_SimpleString(expr);
	if (ok2print)
		show_cur(w_list);
}
Esempio n. 11
0
bool Map::Init(){

    if(map==NULL || map->data==NULL){
        return false;
    }


    list=glGenLists(1);

    glNewList(list,GL_COMPILE_AND_EXECUTE);


    glBegin(GL_TRIANGLE_FAN);
    glColor3f(0,0,0.3);

    glVertex3f(0,-1,0);
    glVertex3f(map->sizeX,-1,0);
    glVertex3f(map->sizeX,-1,map->sizeY);
    glVertex3f(0,-1,map->sizeY);
    glEnd();


    unsigned char y=0;


    for(unsigned int x=0;x<map->sizeX-precision;x+=precision)
        for(unsigned int z=0;z<map->sizeY-precision;z+=precision){

            glBegin(GL_TRIANGLE_FAN);
            y=get_point(map,x,z);
            setVertexColor(y);
            glVertex3f(x,y,z);

            y=get_point(map,x+precision,z);
            setVertexColor(y);
            glVertex3f(x+precision,y,z);

            y=get_point(map,x+precision,z+precision);
            setVertexColor(y);
            glVertex3f(x+precision,y,z+precision);

            y=get_point(map,x,z+precision);
            setVertexColor(y);
            glVertex3f(x,y,z+precision);

            glEnd();

        }
    glEndList();
    return true;
}
Esempio n. 12
0
void create_midpoint(void)
{
    _set *set;
    _point *A, *B;
    _point *val;

    set = POP(_set);
    A = get_point(&set);
    B = get_point(&set);
    get_mem(val, _point);
    val->x = (A->x + B->x)/2;
    val->y = (A->y + B->y)/2;
    PSH(val);
}
Esempio n. 13
0
void			draw_carpet_sierpinski(t_event *e, t_point **p, int c, int n)
{
	draw_rect(e,
		get_point((p[0]->x * 2.0 + p[1]->x) / 3.0,
			(p[0]->y * 2.0 + p[1]->y) / 3),
		get_point((p[0]->x + 2.0 * p[1]->x) / 3.0,
			(p[0]->y + 2.0 * p[1]->y) / 3),
		c);
	if (n < e->nbr)
	{
		draw_allchild(e, p, color_pct(c, 0.8), n + 1);
	}
	free(p[0]);
	free(p[1]);
}
Esempio n. 14
0
static void		draw_allchild(t_event *e, t_point **p, int c, int n)
{
	t_point *v[2];

	draw_allchild_top(e, p, c, n);
	v[0] = get_point(p[0]->x, (p[0]->y * 2.0 + p[1]->y) / 3.0);
	v[1] = get_point((p[0]->x * 2.0 + p[1]->x) / 3.0,
		(p[0]->y + 2.0 * p[1]->y) / 3.0);
	draw_carpet_sierpinski(e, v, c, n);
	v[0] = get_point((p[0]->x + 2.0 * p[1]->x) / 3.0,
		(p[0]->y * 2.0 + p[1]->y) / 3.0);
	v[1] = get_point(p[1]->x, (p[0]->y + 2.0 * p[1]->y) / 3.0);
	draw_carpet_sierpinski(e, v, c, n);
	draw_allchild_bottom(e, p, c, n);
}
void CL_GUILayoutProvider_Corners::set_geometry(const CL_Rect &geometry)
{
	rect = geometry;

	std::vector<LayoutData>::iterator it;
	for (it = components.begin(); it != components.end(); ++it)
	{
		LayoutData &ld = (*it);

		CL_Point tl = get_point(ld.anchor_tl, ld.dist_tl_x, ld.dist_tl_y);
		CL_Point br = get_point(ld.anchor_br, ld.dist_br_x, ld.dist_br_y);

		ld.component->set_geometry(CL_Rect(tl.x, tl.y, br.x, br.y));
	}
}
Esempio n. 16
0
Bbox_3 
RFC_Pane_base::get_bounding_box() const {
  Bbox_3 b;
  for ( int i=1, size=size_of_nodes(); i<=size; ++i) 
    b += Bbox_3(get_point( i));
  return b;
}
Esempio n. 17
0
int main(void)
{
    point pt1(3, 5);
    pt1.print();

#if 1
    point pt2 = pt1;
    pt2.print();
#endif

    point pt3 = get_point();
    pt3.print();

#if 1
    point pt4(98, 6);
    pt4 = pt4;
    pt4.print();
#endif

#if 1
    point pt5;
    pt5 = pt4;//call the assign operator, remind the self assignment
    pt5.print();
#endif

    return 0;
}
Esempio n. 18
0
void create_point_on_segment(void)
{
    double x;
    _set *set;
    _point *A, *B;
    _point *val;

    x = POPn;
    set = POP(_set);
    A = get_point(&set);
    B = get_point(&set);
    get_mem(val, _point);
    val->x = A->x + x*(B->x - A->x);
    val->y = A->y + x*(B->y - A->y);
    PSH(val);
}
Esempio n. 19
0
int Jenarix::triangle( jx_ob ob, bool clockwise)
{

    GLdouble xyz[3][3];
    assert (jx_list_check(ob));
    int nval = jx_list_size(ob);
    //printf ("%d triangle\n", nval);

    glBegin(GL_TRIANGLES);
    for ( int index = 0; index < nval; ++index ) {
      jx_ob triangle = jx_list_shift(ob);
      //printf ("%d\n", value[index].size());
      for (unsigned int itri=0; itri<3; ++itri) {
        get_point(jx_list_get(triangle, itri), xyz[itri]);
      }
      for (unsigned int itri=0; itri<3; ++itri) {
        if (clockwise) {
          glVertex3d(xyz[2-itri][0], xyz[2-itri][1], xyz[2-itri][2]);
        } else {
          glVertex3d(xyz[itri][0], xyz[itri][1], xyz[itri][2]);
        }
      }
    }
    glEnd();

   return nval;

}
Esempio n. 20
0
inline std::vector<weighted_point> get_points(size_t n, size_t d) {
  std::vector<weighted_point> ret;
  for (size_t i = 0; i < n; ++i) {
    ret.push_back(get_point(d));
  }
  return ret;
}
Esempio n. 21
0
Datum
spherepoint_in(PG_FUNCTION_ARGS)
{
	SPoint	   *sp = (SPoint *) palloc(sizeof(SPoint));
	char	   *c = PG_GETARG_CSTRING(0);
	double		lng,
				lat;

	void		sphere_yyparse(void);

	init_buffer(c);
	sphere_yyparse();
	if (get_point(&lng, &lat))
	{
		sp->lng = lng;
		sp->lat = lat;
		spoint_check(sp);
	}
	else
	{
		reset_buffer();
		pfree(sp);
		sp = NULL;
		elog(ERROR, "spherepoint_in: parse error");
	}
	reset_buffer();
	PG_RETURN_POINTER(sp);
}
Esempio n. 22
0
ofVboMesh VectorMap::set_areaclass(ofPrimitiveMode mode, ofColor color, int aid){
    int lid = areas[aid].slid;
    ofVboMesh tmp;
    ofVec3f pos;
    tmp.setMode(mode);
    pos.set(get_point(lines[lid].bpid));
    tmp.addVertex(pos);
    tmp.addColor(color);
    while(lid != areas[aid].elid){
        pos.set(get_point(lines[lid].fpid));
        tmp.addVertex(pos);
        tmp.addColor(color);
        lid = lines[lid].flid;
        }
    return tmp;
}
Esempio n. 23
0
void consume()
{
        bool ret;
	#pragma omp critical
        ret = buffer_empty();
        
        if(ret)
                return;

        double x, y;
	#pragma omp critical
        {
                if(get_point(&x, &y, r_index))
                        r_index = (r_index + 1) % FIFO_SIZE;
        }

        x = (x - .5) * (x - .5);
        y = (y - .5) * (y - .5);
        double r = sqrt(x + y);
        int i = (r <= .5) ? 1 : 0;        

	#pragma omp critical
        {        
                in_range += i;
                consumer_count++;
        }
}
Esempio n. 24
0
int		ft_keypress(int keycode, t_env *e)
{
	if (keycode == 76)
	{
		clear_map(e);
		get_point(e);
		choose_fractal(e);
		mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0);
	}
	if (keycode == 69 || keycode == 78)
		increase_deacrease(keycode, e);
	if (keycode == 123 || keycode == 124)
		ft_keypress2(keycode, e);
	if (keycode == 126 || keycode == 125)
		ft_keypress2(keycode, e);
	if (keycode == 53)
	{
		clear_map(e);
		exit(0);
	}
	if (keycode == 12)
		e->loop = 1;
	if (keycode == 0)
		e->loop = 0;
	return (0);
}
Esempio n. 25
0
int winbox::fill_polygon(lua_State* L)
{
	std::vector<Gdiplus::PointF> points;
	int count = lua_gettop(L);

	if (m_graphics == nullptr || count != 1)
		return 0;

	int len = (int)luaL_len(L, 1);
	if (len < 3)
	{
		return 0;
	}

	for (int i = 1; i <= len; i++)
	{
		lua_pushinteger(L, i);
		lua_gettable(L, 1);
		points.push_back(get_point(L, -1));
		lua_pop(L, 1);
	}

	m_graphics->FillPolygon(m_brush, &points[0], (int)points.size());
	return 0;
}
Esempio n. 26
0
point rotate(point u,point v,point p,double ang)//点p沿uv右旋ang角度
{
	point root=get_point(u,v,p),e,r; point ans;
	e=(v-u)/dist(u,v);	r=p-root;	e=e*r;
	ans=r*cos(ang)+e*sin(ang)+root;
	return ans;
}
Esempio n. 27
0
static void exec_tcl(char *expr)
{
	char p[80];
	if (ok2print)
		hide_cur(w_list);
	siag_row = get_point(w_list).row;
	siag_col = get_point(w_list).col;
	siag_buffer = buffer_of_window(w_list);
	siag_sht = w_list->sht;
	sprintf(p, "%d", siag_row);
	Tcl_SetVar(interp, "R", p, 0);
	sprintf(p, "%d", siag_col);
	Tcl_SetVar(interp, "C", p, 0);
	Tcl_Eval(interp, expr);
	if (ok2print)
		show_cur(w_list);
}
Esempio n. 28
0
inline std::vector<weighted_point> get_points(size_t n, size_t d,
                                              const std::vector<double>& c) {
  std::vector<weighted_point> ret;
  for (size_t i = 0; i < n; ++i) {
    ret.push_back(get_point(d, c));
  }
  return ret;
}
void run()
{
  Vector points;
  Vector points2;
  Random_points g( 150.0);

  // We enforce IEEE double precision as we compare a distance 
  // in a register with a distance in memory
  CGAL::Set_ieee_double_precision pfr;

  CGAL::cpp11::copy_n( g, 1000, std::back_inserter(points));

  typename K_search::Tree t(
    boost::make_transform_iterator(points.begin(),Create_point_with_info<typename K_search::Point_d>()),
    boost::make_transform_iterator(points.end(),Create_point_with_info<typename K_search::Point_d>())
  );
  g++;
  Point query = *g;

  K_search oins(t, query, 0.0, true);

  typename K_search::iterator it = oins.begin();
  typename K_search::Point_with_transformed_distance pd = *it;
  points2.push_back(get_point(pd.first));
  if(CGAL::squared_distance(query,get_point(pd.first)) != pd.second){
    std::cout << "different distances: " << CGAL::squared_distance(query,get_point(pd.first)) << " != " << pd.second << std::endl;
  }

  assert(CGAL_IA_FORCE_TO_DOUBLE(CGAL::squared_distance(query,get_point(pd.first))) == pd.second);
  it++;
  for(; it != oins.end();it++){
    typename K_search::Point_with_transformed_distance qd = *it;
    assert(pd.second <= qd.second);
    pd = qd;
    points2.push_back(get_point(pd.first));
    if(CGAL_IA_FORCE_TO_DOUBLE(CGAL::squared_distance(query,get_point(pd.first))) != pd.second){
      std::cout  << "different distances: " << CGAL::squared_distance(query,get_point(pd.first)) << " != " << pd.second << std::endl;
    }
    assert(CGAL_IA_FORCE_TO_DOUBLE(CGAL::squared_distance(query,get_point(pd.first))) == pd.second);
  }


  std::sort(points.begin(),points.end());
  std::sort(points2.begin(),points2.end());
  assert(points.size() == points2.size());
  for(unsigned int i = 0; i < points.size(); i++){
    if(points[i] != points2[i]){
      std::cout << i << "  " << points[i] << "   " << points2[i] << std::endl;
    }
  }
  assert(points == points2);
  

  std::cout << "done" << std::endl;
}
Esempio n. 30
0
bool
OLCDijkstra::admit_candidate(const ScanTaskPoint &candidate) const
{
  if (!is_final(candidate))
    return true;
  else
    return (get_point(candidate).NavAltitude + fixed(m_finish_alt_diff) >=
            solution[0].NavAltitude);
}