예제 #1
0
파일: u_drag.c 프로젝트: hhoeflin/xfig
static void
place_spline_x(int x, int y)
{
    canvas_leftbut_proc = null_proc;
    canvas_middlebut_proc = null_proc;
    canvas_rightbut_proc = null_proc;
    canvas_locmove_proc = null_proc;
    canvas_ref_proc = null_proc;
    adjust_pos(x, y, fix_x, fix_y, &x, &y);
    translate_spline(new_s, x - fix_x, y - fix_y);
    if (return_proc == copy_selected) {
	add_spline(new_s);
    } else {
	list_add_spline(&objects.splines, new_s);
	clean_up();
	set_lastposition(fix_x, fix_y);
	set_newposition(x, y);
	set_action_object(F_MOVE, O_SPLINE);
	set_latestspline(new_s);
	set_modifiedflag();
    }
    redisplay_spline(new_s);
    /* turn back on all relevant markers */
    update_markers(new_objmask);
    (*return_proc) ();
    draw_mousefun_canvas();
}
예제 #2
0
파일: HGear.cpp 프로젝트: play113/swer
void involute(double tooth_angle, bool do_reverse)
{
	int steps = 10;
	bool first = true;

	for(int i = do_reverse ? (steps) : 0; do_reverse ? (i>= 0) : (i<=steps); )
	{
		double phi = inside_phi_and_angle.phi + (tip_relief_phi_and_angle.phi - inside_phi_and_angle.phi)*i/steps;

		// calculate point on the first tooth
		double px, py;
		point_at_phi(phi, px, py);
		if(do_reverse)py = -py; // mirror for reverse

		// rotate by tooth angle
		double x = px*cos(tooth_angle) - py*sin(tooth_angle);
		double y = py*cos(tooth_angle) + px*sin(tooth_angle);

		// output the point
		point(x, y);
		if(first)add_spline();
		first = false;

		if(do_reverse)i--;
		else i++;
	}
}
예제 #3
0
파일: HGear.cpp 프로젝트: play113/swer
void tooth(int i, bool want_start_point, bool make_closed_tooth_form)
{
	double tooth_angle = 2*M_PI*i/gear_for_point->m_num_teeth;
	double next_tooth_angle = 2*M_PI*(i+1)/gear_for_point->m_num_teeth;
	// incremental_angle - to space the middle point at a quarter of a cycle
	double incremental_angle = 0.5*M_PI/gear_for_point->m_num_teeth - middle_phi_and_angle.angle;
	double angle1 = tooth_angle - (inside_phi_and_angle.angle + incremental_angle);
	//double angle2 = tooth_angle + (inside_phi_and_angle.angle + incremental_angle);
	double angle3 = tooth_angle + (outside_phi_and_angle.angle + incremental_angle);
	double angle4 = next_tooth_angle - (outside_phi_and_angle.angle + incremental_angle);
	//double angle5 = next_tooth_angle - (inside_phi_and_angle.angle + incremental_angle);

	if(!make_closed_tooth_form && fabs(gear_for_point->GetClearanceMM()) > 0.0000000001)
	{
		add_spline();
		if(sketch_for_gear)
		{			
			line_arc_line(tooth_angle);
		}
		else
		{
			if(i == 0 && want_start_point)base_point1(tooth_angle);
			clearance_point1(tooth_angle, gear_for_point->GetClearanceMM());
			clearance_point2(tooth_angle, gear_for_point->GetClearanceMM());
		}
	}
	else
	{
		if(i==0 && want_start_point)point_at_rad_and_angle(inside_radius, angle1);
	}

	involute(tooth_angle + incremental_angle, false);

	add_spline();

	if(fabs(gear_for_point->m_tip_relief) > 0.00000000001)
	{
		point_at_rad_and_angle(outside_radius, angle3 + (gear_for_point->m_tip_relief/2)/outside_radius);
	add_spline();
		point_at_rad_and_angle(outside_radius, angle4 - (gear_for_point->m_tip_relief/2)/outside_radius);
		add_spline();
	}

	involute(next_tooth_angle - incremental_angle, true);

	add_spline();
}
예제 #4
0
static void
init_flipspline(F_spline *old_s, int px, int py)
{
    F_spline	   *new_s;

    new_s = copy_spline(old_s);
    flip_spline(new_s, px, py, flip_axis);
    if (copy) {
	add_spline(new_s);
    } else {
	toggle_splinemarker(old_s);
	draw_spline(old_s, ERASE);
	change_spline(old_s, new_s);
    }
    /* redisplay objects under this object before it was rotated */
    redisplay_spline(old_s);
    /* and this object and any other objects on top */
    redisplay_spline(new_s);
}