CL_CollisionOutline CL_CollisionOutline::clone() const
{
	CL_CollisionOutline copy;
	copy.impl->contours.clear();
	copy.impl->contours.reserve(impl->contours.size());
	for (size_t i = 0; i < impl->contours.size(); i++)
		copy.impl->contours.push_back(impl->contours[i].clone());
	copy.impl->do_inside_test = get_inside_test();
	copy.impl->width = get_width();
	copy.impl->height = get_height();
	copy.impl->position = get_translation();
	copy.impl->scale_factor = get_scale();
	copy.impl->angle = get_angle();
	copy.impl->minimum_enclosing_disc = get_minimum_enclosing_disc();

	bool points, normals, metadata, pendepths;
	get_collision_info_state(points,normals,metadata,pendepths);
	copy.enable_collision_info(points,normals,metadata,pendepths);

	CL_Origin origin;
	float x, y;

	get_alignment(origin,x,y);
	copy.impl->translation_origin = origin;
	copy.impl->translation_offset.x = x;
	copy.impl->translation_offset.y = y;

	get_rotation_hotspot(origin,x,y);
	copy.impl->rotation_origin = origin;
	copy.impl->rotation_hotspot.x = x;
	copy.impl->rotation_hotspot.y = y;
	return copy;
}
示例#2
0
/**
 * @brief Returns the value of a property of this movement.
 *
 * Accepted keys:
 * - speed
 * - angle
 * - max_distance
 * - ignore_obstacles
 * - smooth
 * - displayed_direction
 *
 * @param key key of the property to get
 * @return the corresponding value as a string
 */
const std::string StraightMovement::get_property(const std::string &key) {

  std::ostringstream oss;

  if (key == "speed") {
    oss << get_speed();
  }
  else if (key == "angle") {
    oss << get_angle();
  }
  else if (key == "max_distance") {
    oss << get_max_distance();
  }
  else if (key == "ignore_obstacles") {
    oss << are_obstacles_ignored();
  }
  else if (key == "smooth") {
    oss << is_smooth();
  }
  else if (key == "displayed_direction") {
    oss << get_displayed_direction4();
  }
  else {
    Debug::die(StringConcat() << "Unknown property of StraightMovement: '" << key << "'");
  }

  return oss.str();
}
示例#3
0
int check_pickup(const avrMatrix3x4& cardTrans, const avrMatrix3x4& baseTrans, ItemList* itlist, double* angle)
{
   double   x, y, z;
   double   lx, ly;

   avrMatrix3x4 relation = baseTrans.getRelationWith(cardTrans);

   x = relation.X();
   y = relation.Y();
   z = relation.Z();

   int ret = -1;
   for(int i = 0; i < itlist->itemnum; i ++ ){
      lx = x - itlist->item[i].pos[0];
      ly = y - itlist->item[i].pos[1];

      //MB increased by a factor of 10
      if( lx*lx + ly*ly < 1000.0 && z < 20.0 ) {
         ret = i;
      }
   }

   double   a, b, c;
   if( ret >= 0 ) {
      get_angle( (double(*)[4])relation.matrix(), &a, &b, &c );
      *angle = -c;
   }

   return ret;
}
//********************LIC_9()**********************************
void LIC_9() 
{
CMV[9]=FALSE;
if(NUMPOINTS < 5)
return;
int i;
for(i=0;(i+PARAMETERS.C_PTS+PARAMETERS.D_PTS+1+1< NUMPOINTS);i++)
{
double x1 = X[i];
double x2 = X[i+PARAMETERS.C_PTS+1];
double x3 = X[i+PARAMETERS.C_PTS+1+PARAMETERS.D_PTS+1];
double y1 = Y[i];
double y2 = Y[i+PARAMETERS.C_PTS+1];
double y3 = Y[i+PARAMETERS.C_PTS+1+PARAMETERS.D_PTS+1];
double l12 = get_distance(x1,x2,y1,y2);
double l13 = get_distance(x1,x3,y1,y3);
double l23 = get_distance(x2,x3,y2,y3);	
double angle = get_angle(l12,l23,l13);//vertex of angle is Pt. 2 (angle opp to line 13)
//To include a case where any two points are the same as vertex. Check if x1==x2 && y1==y2  || x2==x3 && y2==y3
        if(((DOUBLECOMPARE(x1,x2)==EQ)&&(DOUBLECOMPARE(y1,y2)==EQ))||
                ((DOUBLECOMPARE(x2,x3)==EQ)&&(DOUBLECOMPARE(y2,y3)==EQ)))
        continue;// 
	
// checks for angle < (PI − EPSILON)or angle > (PI + EPSILON) works even when angle is zero. i.e P1&P3 are same.
        if((DOUBLECOMPARE(angle,(PI+PARAMETERS.EPSILON))==GT)||
                (DOUBLECOMPARE(angle,(PI-PARAMETERS.EPSILON))==LT))
        {     
	CMV[9]=TRUE; 
        }
    }//closes for
}//end of LIC_9()
void approximate_contour(vector<Point>& points, vector<Point>& points_approximated, int theta_threshold, int skip_count)
{
	if (points.size() == 0)
		return;

	points_approximated.push_back(points[0]);

	Point pt_old = Point(-1, 0);
	float angle_old = 9999;

	const int points_size = points.size();

	for (int i = 0; i < points_size; i += skip_count)
	{
		Point pt = points[i];

		if (pt_old.x != -1)
		{
			const float angle = get_angle(pt_old.x, pt_old.y, pt.x, pt.y);

			if (abs(angle - angle_old) > theta_threshold)
			{
				angle_old = angle;
				points_approximated.push_back(pt_old);
			}
		}
		pt_old = pt;
	}

	Point pt_end = points[points.size() - 1];
	Point pt_end_approximated = points_approximated[points_approximated.size() - 1];
	if (pt_end_approximated.x != pt_end.x || pt_end_approximated.y != pt_end.y)
		points_approximated.push_back(pt_end);
}
示例#6
0
/**
 * \brief Calculates the direction and the speed of the movement
 * depending on the target.
 */
void TargetMovement::recompute_movement() {

  if (target_entity != NULL) {
    // the target may be a moving entity
    target_x = target_entity->get_x() + entity_offset_x;
    target_y = target_entity->get_y() + entity_offset_y;
  }

  if (get_x() != target_x || get_y() != target_y) {
    finished = false;

    double angle = Geometry::get_angle(get_x(), get_y(), target_x, target_y);

    int dx = target_x - get_x();
    int dy = target_y - get_y();

    sign_x = (dx >= 0) ? 1 : -1;
    sign_y = (dy >= 0) ? 1 : -1;

    if (std::fabs(angle - get_angle()) > 1E-6 || get_speed() < 1E-6) {
      // The angle has changed or the movement was stopped.
      set_speed(moving_speed);
      set_angle(angle);
      set_max_distance((int) Geometry::get_distance(
            get_x(), get_y(), target_x, target_y));
    }
  }
}
示例#7
0
文件: ball.c 项目: danielrvt/Roller
/**
 * Actualiza la posicion de la pelota.
 * @param: La pelota.
 * @param: La matriz de transformacion de la marca
 * sobre la que esta la pelota.
 */
void updateBallPosition(Ball *ball, double trans[3][4], Floor floor) {

  double omega[2];
  double wa, wb, wc;
  double nextX;
  double nextY;

  // Obtiene el angulo euleriano.
  get_angle(trans, &wa, &wb, &wc);
  
  omega[0] = wc;
  omega[1] = wb - GAME_FLAT_ANGLE;

  // Proxima posicion de la pelota en x y en y.
  nextX = ball->position[0] + omega[0]*ball->speed;
  nextY = ball->position[1] - omega[1]*ball->speed;

  // Checkea que no se salga por la izquierda ni la derecha.
  if (nextX - ball->radius > floor.left && nextX + ball->radius < floor.right){

    ball->prev_position[0] = ball->position[0];
    ball->position[0] = nextX; 
  }
  
  // Checkea que no se salga por arriba ni por abajo.
  if (nextY - ball->radius < floor.top && nextY + ball->radius > floor.bottom){

    ball->prev_position[1] = ball->position[1];
    ball->position[1] = nextY;
  }
};
示例#8
0
static gmx_bool calc_vsite3fad_param(t_param *param,
				 int nrbond, t_mybonded *bonds,
				 int nrang,  t_mybonded *angles)
{
  /* i = virtual site          |
   * j = 1st bonded heavy atom | i-j
   * k = 2nd bonded heavy atom |    `k-l
   * l = 3d bonded heavy atom  |
   */

  gmx_bool bSwapParity,bError;
  real bij,aijk;
  
  bSwapParity = ( param->C1 == -1 );
  
  bij  = get_bond_length(nrbond, bonds, param->AI, param->AJ);
  aijk = get_angle      (nrang, angles, param->AI, param->AJ, param->AK);
  bError = (bij==NOTSET) || (aijk==NOTSET);
  
  param->C1 = bij;          /* 'bond'-length for fixed distance vsite */
  param->C0 = RAD2DEG*aijk; /* 'bond'-angle for fixed angle vsite */
  
  if (bSwapParity)
    param->C0 = 360 - param->C0;
  
  if (debug)
    fprintf(debug,"params for vsite3fad %u: %g %g\n",
	    param->AI+1,param->C0,param->C1);
  return bError;
}
示例#9
0
double convex_hull(int n, int first) {
  point_t ref = {0, -1};
  double total=0;
  int next_point;
  double best_angle;
  int current = first;

  while(true) {
    //printf("<%d>\n", current);
    best_angle = 720;
    for(int i=0; i<n; ++i) {
      if (i != current) {
        double angle = get_angle(tree[current]-tree[i], ref);
        //printf("~ %lf\n", angle);
        if (angle < best_angle) {
          best_angle = angle;
          next_point = i;
        }
      }
    }
    total += (tree[current] - tree[next_point]).length();
    if (next_point == first)
      break;
    ref = tree[next_point] - tree[current];
    current = next_point;
  }

  return total;
}
示例#10
0
///////////////////////
// normal
void Tooltip::draw()
{
	if(is_visible())
	{
		std::string text = get_text();
	    int x = get_x();
	    int y = get_y();
	    int width  = get_width ();
	    int height = get_height();
		double angle = get_angle();
		double scale_x = get_scale().x;
		double scale_y = get_scale().y;
	    double red = get_color().x;
	    double green = get_color().y;
	    double blue  = get_color().z;
	    double alpha = get_color().w;
		Renderer::draw_tooltip(text, x, y, width, height, angle, scale_x, scale_y,
		    red, green, blue, alpha);
		if(label != nullptr)
		{
			label->draw();
			//Renderer::draw_label(text, x, y, angle, get_label()->get_scale().x, get_label()->get_scale().y,
			//   get_label()->get_font()->get_data(), 
			//   get_text_color().x,get_text_color().y,get_text_color().z,get_text_color().w);
		}
	}
	on_draw(); // callback for all gui
}
void LIC_2() 
{
    CMV[2] = FALSE;
    // Loop through X and Y
    int i;
    for (i=0;i<NUMPOINTS-2;++i) 
    {
        // Get the coordinates for the three points
        double x1 = X[i];
        double x2 = X[i+1];
        double x3 = X[i+2];
        double y1 = Y[i];
        double y2 = Y[i+1];
        double y3 = Y[i+2];
        double l12 = get_distance(x1,x2,y1,y2);
        double l13 = get_distance(x1,x3,y1,y3);
        double l23 = get_distance(x2,x3,y2,y3);
        double angle = get_angle(l12,l23,l13); // vertex of angle is Pt. 2 (angle opp to line 13)
//To include a case where any two points are the same as vertex. Check if x1==x2 && y1==y2 || x2==x3 && y2==y3
        if(((DOUBLECOMPARE(x1,x2)==EQ)&&(DOUBLECOMPARE(y1,y2)==EQ))||
                ((DOUBLECOMPARE(x2,x3)==EQ)&&(DOUBLECOMPARE(y2,y3)==EQ)))
        continue;// eliminates setting CMV true even whenever any two points are coincident and angle = nan

	// checks for angle < (PI − EPSILON)or angle > (PI + EPSILON)
        if((DOUBLECOMPARE(angle,(PI+PARAMETERS.EPSILON))==GT)||
                (DOUBLECOMPARE(angle,(PI-PARAMETERS.EPSILON))==LT))
        {     
	CMV[2]=TRUE; 
        }
    }//closes for
}//end of LIC_2()
示例#12
0
文件: mathutils.cpp 项目: amecky/DT
	float get_target_angle(const v2& v1,const v2& v2) {	
		Vector2f diff = v2 - v1;
		float angle = get_angle(V2_RIGHT,diff);
		if ( angle >= TWO_PI ) {
			angle -= TWO_PI;
		}
		return angle;
	}
示例#13
0
文件: d_geo.c 项目: Abstrusle/LCTourn
// call this when a member (but not the core) moves or is moved
void update_design_member_position_recursively(struct template_struct* templ, int m)
{

   struct nshape_struct* parent_nshape = &nshape[templ->member[templ->member[m].connection[0].template_member_index].shape];
   struct nshape_struct* child_nshape = &nshape[templ->member[m].shape];

	  templ->member[m].group_angle_offset = templ->member[templ->member[m].connection[0].template_member_index].group_angle_offset
	                                              + parent_nshape->link_angle_fixed [templ->member[m].connection[0].reverse_link_index] // - AFX_ANGLE_4
	                                              + (AFX_ANGLE_2 - child_nshape->link_angle_fixed [templ->member[m].connection[0].link_index])
	                                              + templ->member[m].connection_angle_offset;

/*
	   templ->member[m].position.x = templ->member[templ->member[m].connection[0].template_member_index].position.x
                 + (symmetrical_cos(templ->member[templ->member[m].connection[0].template_member_index].group_angle_offset
																		+ parent_nshape->link_angle_fixed [templ->member[m].connection[0].reverse_link_index])
																		* (parent_nshape->link_dist_pixel [templ->member[m].connection[0].reverse_link_index]))
																	- (symmetrical_cos(templ->member[m].group_angle_offset + child_nshape->link_angle_fixed [templ->member[m].connection[0].link_index])
																		* (get_link_dist_pixel(child_nshape->link_dist_pixel [templ->member[m].connection[0].link_index], templ->member[m].connection_angle_offset)));
    templ->member[m].position.y = templ->member[templ->member[m].connection[0].template_member_index].position.y
                 + (symmetrical_sin(templ->member[templ->member[m].connection[0].template_member_index].group_angle_offset
																		+ parent_nshape->link_angle_fixed [templ->member[m].connection[0].reverse_link_index])
																		* (parent_nshape->link_dist_pixel [templ->member[m].connection[0].reverse_link_index]))
																	- (symmetrical_sin(templ->member[m].group_angle_offset + child_nshape->link_angle_fixed [templ->member[m].connection[0].link_index])
																		* (get_link_dist_pixel(child_nshape->link_dist_pixel [templ->member[m].connection[0].link_index], templ->member[m].connection_angle_offset)));
*/


	   templ->member[m].position.x = templ->member[templ->member[m].connection[0].template_member_index].position.x
                 + (symmetrical_cos(templ->member[templ->member[m].connection[0].template_member_index].group_angle_offset
																		+ parent_nshape->link_angle_fixed [templ->member[m].connection[0].reverse_link_index])
																		* (parent_nshape->link_dist_pixel [templ->member[m].connection[0].reverse_link_index]))
																	- (symmetrical_cos(templ->member[m].group_angle_offset + child_nshape->link_angle_fixed [templ->member[m].connection[0].link_index])
																		* (child_nshape->link_dist_pixel [templ->member[m].connection[0].link_index]));
    templ->member[m].position.y = templ->member[templ->member[m].connection[0].template_member_index].position.y
                 + (symmetrical_sin(templ->member[templ->member[m].connection[0].template_member_index].group_angle_offset
																		+ parent_nshape->link_angle_fixed [templ->member[m].connection[0].reverse_link_index])
																		* (parent_nshape->link_dist_pixel [templ->member[m].connection[0].reverse_link_index]))
																	- (symmetrical_sin(templ->member[m].group_angle_offset + child_nshape->link_angle_fixed [templ->member[m].connection[0].link_index])
																		* (child_nshape->link_dist_pixel [templ->member[m].connection[0].link_index]));

 templ->member[m].approximate_angle_offset = get_angle(templ->member[m].position.y, templ->member[m].position.x);
 templ->member[m].approximate_distance = distance(templ->member[m].position.y, templ->member[m].position.x);

 int i;

 for (i = 1; i < GROUP_CONNECTIONS; i ++) // note i begins at 1
	{
		if (templ->member[m].connection[i].template_member_index != -1)
			update_design_member_position_recursively(templ, templ->member[m].connection[i].template_member_index);
	}

// note: be careful about calling other design functions from this one,
//  as they may use dwindow.templ.



}
示例#14
0
int main(int argc, char* argv[]) {
	
	long long x1 = atof(argv[1]);
	long long y1 = atof(argv[2]);
	long long x2 = atof(argv[3]);
	long long y2 = atof(argv[4]);
	long long x3 = atof(argv[5]);
	long long y3 = atof(argv[6]);

	double x1_x2_length = get_side_length(x2, x1, y2, y1);
	double x2_x3_length = get_side_length(x3, x2, y3, y2);
	double x1_x3_length = get_side_length(x3, x1, y3, y1);

	double x1_x2_angle = get_angle(x1_x2_length, x2_x3_length, x1_x3_length);
	double x2_x3_angle = get_angle(x2_x3_length, x1_x3_length, x1_x2_length);
	double x1_x3_angle = get_angle(x1_x3_length, x1_x2_length, x2_x3_length);

	if(!is_a_triangle(x1_x2_length, x2_x3_length, x1_x3_length)) {
		printf("not a triangle\n");
		exit(0);
	}

	if(is_scalene(x1_x2_length, x2_x3_length, x1_x3_length))
		printf("scalene ");
	else
		printf("isosceles ");
	
	if(is_right(x1_x2_length, x2_x3_length, x1_x3_length))
		printf("right\n");
	
	if(is_acute(x1_x2_angle, x2_x3_angle, x1_x3_angle))
		printf("acute\n");
	else
		printf("obtuse\n");

	/*printf("x1_x2_length: %f\n", x1_x2_length);
	printf("x2_x3_length: %f\n", x2_x3_length);
	printf("x1_x3_length: %f\n", x1_x3_length);
	printf("x1_x2_angle: %f\n", x1_x2_angle);
	printf("x2_x3_angle: %f\n", x2_x3_angle);
	printf("x1_x3_angle: %f\n", x1_x3_angle);*/
	
	return 0;
}
示例#15
0
/**************************************************************************
*   Function name : preset_drivers
*   Returns :       нет
*   Parameters :    нет
*   Purpose :       Конфігуримо драйвер крокового двигуна і стаємо в нуль стенда
****************************************************************************/
void preset_drivers(void)
{
	//---------------------------------------------------------------------------------------
	stepper_motor_init();
	//---------------------------------------------------------------------------------------
	get_angle();
	_delay_ms(100);
	set_axle_to(ANGLE_MIN);
	//---------------------------------------------------------------------------------------
};
示例#16
0
static void set_player_map_init_spawn_angle(int player_index, int nearby_data_well)
{
//fpr("\n spmisa %i,%i", player_index, nearby_data_well);
	al_fixed spawn_x = block_to_fixed(map_init.spawn_position[player_index].x) + BLOCK_SIZE_FIXED / 2;
	al_fixed spawn_y = block_to_fixed(map_init.spawn_position[player_index].y) + BLOCK_SIZE_FIXED / 2;
	al_fixed well_x = block_to_fixed(map_init.data_well_position[nearby_data_well].x) + BLOCK_SIZE_FIXED / 2;
	al_fixed well_y = block_to_fixed(map_init.data_well_position[nearby_data_well].y) + BLOCK_SIZE_FIXED / 2;

	map_init.spawn_angle [player_index] = fixed_angle_to_int(get_angle(spawn_y - well_y, spawn_x - well_x));

}
示例#17
0
文件: util.c 项目: danielrvt/Roller
/**
 * Obtiene el angulo de inclinacion de la marca
 * en grados. 
 * La marca forma 0° al estar paralela al suelo, 
 * y 90° al estar paralela a la camara. Esto es
 * yangle.
 * La marca forma 0° al estar paralela a la camara
 * y 180° al estar mirando hacia los lados. Cuando
 * mira hacia la derecha los grados son - y cuando
 * mira hacia la izquierda los grados son +. Esto
 * es xangle.
 */
void get_user_angle(double trans[3][4], double *xangle, double *yangle) {

  double wa, wb, wc;

  // Obtiene el angulo euleriano.
  get_angle(trans, &wa, &wb, &wc);

  // Obtiene el angulo de inclinacion de la marca
  // en grados con respecto al eje natural del usuario.
  *xangle = toDegree(wc);
  *yangle = toDegree(wb) - 90;
}
示例#18
0
void find_next_edge(Segment s, std::vector<Segment>& segments,
        std::set<int>& unusedIndexes, std::vector<Polygon_2>& rings) {
    if (unusedIndexes.empty()
            || prev_size == unusedIndexes.size()) {
        return;
    }

    prev_size = unusedIndexes.size();

    Point start = s.source();
    Point end = s.target();
    rings.back().push_back(end);

    std::vector<int> nextIndexes;
    for (unsigned int i = 0; i < segments.size(); i++) {
        if (unusedIndexes.find(i) != unusedIndexes.end()) {
            Point source = segments.at(i).source();
            if (source == end) {
                nextIndexes.push_back(i);
            }
        }
    }
    if (nextIndexes.size() == 1) {
        int i = nextIndexes.at(0);
        unusedIndexes.erase(i);
        find_next_edge(segments.at(i), segments, unusedIndexes, rings);
    } else if (nextIndexes.size() > 1) {
        std::vector< std::pair<double, int> > nextAngles;
        for (unsigned int i = 0; i < nextIndexes.size(); i++) {
            int j = nextIndexes.at(i);
            Point target = segments.at(j).target();
            double angle = get_angle(start, end, target);
            nextAngles.push_back(std::pair<double, int>(angle, j));
        }
        std::sort(nextAngles.begin(), nextAngles.end());
        int i = nextAngles.begin()->second;
        unusedIndexes.erase(i);
        find_next_edge(segments.at(i), segments, unusedIndexes, rings);
    }

    if (!unusedIndexes.empty()) {
        for (unsigned int i = 0; i < segments.size(); i++) {
            if (unusedIndexes.find(i) != unusedIndexes.end()) {
                Polygon_2 ring;
                ring.push_back(segments.at(i).source());
                rings.push_back(ring);
                unusedIndexes.erase(i);
                find_next_edge(segments.at(i), segments, unusedIndexes, rings);
            }
        }
    }
}
示例#19
0
文件: make_3_j.c 项目: mpw/p2
float
inscribed_angle (int basepoint, int p1, int p2)
{
    float angle1, angle2, temp;

    /* Get the angle between line #1 and the origin and the angle
     * between line #2 and the origin, and then subtract these values. */
    angle1 = get_angle(basepoint,p1);
    angle2 = get_angle(basepoint,p2);
    temp = angle1 - angle2;
    if (temp < 0.0)
        temp = -temp;

    /* We always want the smaller of the two angles inscribed, so if the
     * answer is greater than 180 degrees, calculate the smaller angle and
     * return it. */
    if (temp > PI)
        temp = 2*PI - temp;
    if (temp < 0.0)
        return(-temp);
    return(temp);
}
/**
 * \brief Combine with an other set of attributes.
 * \param that The attributes to combine with.
 *
 * The attributes changed by this method are : is_flipped(), is_mirrored(), the
 * intensities, the opacity and the angle. The size is not changed.
 */
void bear::visual::bitmap_rendering_attributes::combine
( const bitmap_rendering_attributes& that )
{
  flip( that.is_flipped() ^ is_flipped() );
  mirror( that.is_mirrored() ^ is_mirrored() );
  set_intensity
    ( that.get_red_intensity() * get_red_intensity(),
      that.get_green_intensity() * get_green_intensity(),
      that.get_blue_intensity() * get_blue_intensity()
      );
  set_opacity( that.get_opacity() * get_opacity() );
  set_angle( that.get_angle() + get_angle() );
} // bitmap_rendering_attributes::combine()
示例#21
0
int check_incline (const avrMatrix3x4& cardTrans, const avrMatrix3x4& baseTrans, double *angle )
{
   avrMatrix3x4 relation = cardTrans.getRelationWith(baseTrans);

   double  a, b, c;
   get_angle( (double(*)[4])relation.matrix(), &a, &b, &c );

   if( b > 0.4 ) {
      *angle = a + 3.141592;
      return 1;
   }

   return 0;
}
示例#22
0
		size_t revolute_joint::initialize_state_value_bindings_(sv_bindings_t& bindings, sv_accessors_t& accessors, state_value_id const& base) const
		{
			auto initial_count = bindings.size();
			auto bound_id = accessors.size();

			auto svid = base + "angle";
			bindings[svid] = bound_id++;
			accessors.push_back([this]
			{
				return get_angle();
			});

			svid = base + "speed";
			bindings[svid] = bound_id++;
			accessors.push_back([this]
			{
				return get_speed();
			});

			svid = base + "applied";
			bindings[svid] = bound_id++;
			accessors.push_back([this]
			{
				return gen_as_.applied_torque;
			});

			svid = base + "reaction_Fx";
			bindings[svid] = bound_id++;
			accessors.push_back([this]
			{
				return 0.0; //todo: joint_->GetReactionForce(m_sys->get_hertz()).x;
			});

			svid = base + "reaction_Fy";
			bindings[svid] = bound_id++;
			accessors.push_back([this]
			{
				return 0.0; //todo: joint_->GetReactionForce(m_sys->get_hertz()).y;
			});

			svid = base + "reaction_T";
			bindings[svid] = bound_id++;
			accessors.push_back([this]
			{
				return 0.0; //todo: joint_->GetReactionTorque(m_sys->get_hertz());
			});

			return bindings.size() - initial_count;
		}
示例#23
0
void CHARMMPatch::apply(CHARMMResidueTopology *res) const {
  if (res->get_patched()) {
    IMP_THROW("Cannot patch an already-patched residue", ValueException);
  }
  check_empty_patch(this);

  // Copy or update atoms
  for (base::Vector<CHARMMAtomTopology>::const_iterator it = atoms_.begin();
       it != atoms_.end(); ++it) {
    try {
      res->get_atom(it->get_name()) = *it;
    }
    catch (base::ValueException &) {
      res->add_atom(*it);
    }
  }

  // Delete atoms
  for (base::Vector<std::string>::const_iterator it = deleted_atoms_.begin();
       it != deleted_atoms_.end(); ++it) {
    try {
      res->remove_atom(*it);
    }
    catch (base::ValueException &) {
      // ignore atoms that don't exist to start with
    }
  }

  // Add angles/bonds/dihedrals/impropers
  for (unsigned int i = 0; i < get_number_of_bonds(); ++i) {
    res->add_bond(get_bond(i));
  }
  for (unsigned int i = 0; i < get_number_of_angles(); ++i) {
    res->add_angle(get_angle(i));
  }
  for (unsigned int i = 0; i < get_number_of_dihedrals(); ++i) {
    res->add_dihedral(get_dihedral(i));
  }
  for (unsigned int i = 0; i < get_number_of_impropers(); ++i) {
    res->add_improper(get_improper(i));
  }

  // Add internal coordinates
  for (unsigned int i = 0; i < get_number_of_internal_coordinates(); ++i) {
    res->add_internal_coordinate(get_internal_coordinate(i));
  }

  res->set_patched(true);
}
示例#24
0
/* Auto-rotate, if rotate_image is set. 
 */
static VipsImage *
thumbnail_rotate( VipsObject *process, VipsImage *im )
{
	VipsImage **t = (VipsImage **) vips_object_local_array( process, 1 );

	if( rotate_image ) {
		if( vips_rot( im, &t[0], get_angle( im ), NULL ) )
			return( NULL ); 
		im = t[0];

		(void) vips_image_remove( im, ORIENTATION );
	}

	return( im );
}
示例#25
0
// ------------------------------------------------------------------------
// class to move enemy army on adventure map
// ------------------------------------------------------------------------
void t_enemy_army_attack::activate_trigger()
{
	if (m_in_trigger)
		return;

	m_in_trigger = true;
	
	t_direction direction;
	int			angle;

	angle = get_angle( m_target->get_position(), m_army->get_position() );
	direction = get_direction( angle );
	m_army->touch_armies( m_target, m_army->get_position(), direction,
		                  m_window->get_frame(), m_original_position );

	m_in_trigger = false;
}
/**
 * \brief Combine with an other set of attributes.
 * \param that The attributes to combine with.
 * The attributes changed by this method are : get_flipped_status(),
 * get_mirrored_status(), the intensities, the opacity and the angle.
 * The size is not changed.
 */
void bf::bitmap_rendering_attributes::combine
( const bitmap_rendering_attributes& that )
{
  flip( trinary_logic::from_bool
        (trinary_logic::to_bool(that.get_flipped_status()) ^
         trinary_logic::to_bool(get_flipped_status())) );
  mirror( trinary_logic::from_bool
          (trinary_logic::to_bool(that.get_mirrored_status()) ^
           trinary_logic::to_bool(get_mirrored_status())) );
  m_color.set_intensity
    ( that.get_color().get_red_intensity() * m_color.get_red_intensity(),
      that.get_color().get_green_intensity() * m_color.get_green_intensity(),
      that.get_color().get_blue_intensity() * m_color.get_blue_intensity()
      );
  m_color.set_opacity( that.get_color().get_opacity() * m_color.get_opacity() );
  set_angle( that.get_angle() + get_angle() );
} // bitmap_rendering_attributes::combine()
示例#27
0
static double u_fndd(double x, double y, double& dx, double& dy)
{
    dx = D * drdx(x, y) * (u_F * cos(lambda * get_angle(y, x)) - lambda * cos((lambda - 2) * get_angle(y, x))) +
         D * r(x, y) * (u_F * (-1) * lambda * sin(lambda * get_angle(y, x)) * d_theta_dx(x, y)) -
         D * r(x, y) * (lambda * (-1) * (lambda - 2) * sin((lambda - 2) * get_angle(y, x)) * d_theta_dx(x, y));

    dy = D * drdy(x, y) * (u_F * cos(lambda * get_angle(y, x)) - lambda * cos((lambda - 2) * get_angle(y, x))) +
         D * r(x, y) * (u_F * (-1) * lambda * sin(lambda * get_angle(y, x)) * d_theta_dy(x, y)) -
         D * r(x, y) * (lambda * (-1) * (lambda - 2) * sin((lambda - 2) * get_angle(y, x)) * d_theta_dy(x, y));

    return u_fn(x, y);
}
Pixel get_pixel_coords(uint32_t position, uint32_t scale, float length, Pixel center, float orientation) {

    Pixel res_px ;

    /** Get the angle from position in the circle where 3 o'clock
      * is orientation == 0  ; divided in scale units.             **/
    float angle_degrees = get_angle(position, scale, orientation)   ;


    /** Conversion angle in degrees to radians **/
    float radians = angle_degrees / 180.0 * M_PI  ;

    res_px.x = cosf(radians) * length + center.x  ;
    res_px.y = sinf(radians) * length + center.y  ;

    return res_px ;

}
示例#29
0
static double v_fndd(double x, double y, double& dx, double& dy)
{

    dx = D * drdx(x, y) * (v_F * sin(lambda * get_angle(y, x)) + lambda * sin((lambda - 2) * get_angle(y, x))) +
         D * r(x, y) * (v_F * lambda * cos(lambda * get_angle(y, x)) * d_theta_dx(x, y)) +
         D * r(x, y) * (lambda * (lambda - 2) * cos((lambda - 2) * get_angle(y, x)) * d_theta_dx(x, y));

    dy = D * drdy(x, y) * (v_F * sin(lambda * get_angle(y, x)) + lambda * sin((lambda - 2) * get_angle(y, x))) +
         D * r(x, y) * (v_F * lambda * cos(lambda * get_angle(y, x)) * d_theta_dy(x, y)) +
         D * r(x, y) * (lambda * (lambda - 2) * cos((lambda - 2) * get_angle(y, x)) * d_theta_dy(x, y));

    return v_fn(x, y);
}
示例#30
0
		void revolute_joint::pos_apply_activation(value_t act)
		{
			/*
			Activation specifies an absolute angle by a mapping from [0, 1] to [min, max], where min and
			max are the joint limits. Note that currently this activation method requires the joint
			to have limits enabled.

			A motor is used to attempt to track to the angle, under the same conditions as above.
			*/

			auto const& as = get_act_st< Activation::Position >();

			auto target = joint_->GetLowerLimit() + (joint_->GetUpperLimit() - joint_->GetLowerLimit()) * act;
			auto error = get_angle() - target;
			joint_->SetMotorSpeed(-as.gain * error);
			joint_->SetMaxMotorTorque(gen_as_.max_theoretical_torque);	// todo: muscle energy, as above

			gen_as_.applied_torque = joint_->GetMotorTorque(30.0);	// TODO: !!!!!!!!!!!!
		}