Lines Matching refs:g1
449 belt (struct GEAR g1, struct GEAR g2)
462 width = min (g1.width, g2.width);
463 D = sqrt (pow (g1.position[0] - g2.position[0], 2) + pow (g1.position[1] - g2.position[1], 2) + pow (g1.position[2] - g2.position[2], 2));
464 alpha = acos ((g2.position[0] - g1.position[0]) / D);
465 phi = acos ((g1.radius - g2.radius) / D);
469 incr = 1.2 * 360.0 / g1.teeth * M_PI / 180.00;
470 for (angle = alpha + phi; angle <= 2 * M_PI - phi + alpha; angle += 360.0 / g1.teeth * M_PI / 180.00)
473 glVertex3f (g1.radius * cos (angle), g1.radius * sin (angle), width * 0.5);
474 glVertex3f (g1.radius * cos (angle), g1.radius * sin (angle), -width * 0.5);
475 glVertex3f (g1.radius * cos (angle + incr), g1.radius * sin (angle + incr), -width * 0.5);
476 glVertex3f (g1.radius * cos (angle + incr), g1.radius * sin (angle + incr), width * 0.5);
483 for (angle = -phi + alpha; angle <= phi + alpha; angle += 360.0 / g1.teeth * M_PI / 180.0)
486 glVertex3f (g2.radius * cos (angle) + g2.position[0] - g1.position[0], g2.radius * sin (angle) + g2.position[1] - g1.position[1], width * 0.5);
487 glVertex3f (g2.radius * cos (angle) + g2.position[0] - g1.position[0], g2.radius * sin (angle) + g2.position[1] - g1.position[1], width * -0.5);
488 glVertex3f (g2.radius * cos (angle + incr) + g2.position[0] - g1.position[0], g2.radius * sin (angle + incr) + g2.position[1] - g1.position[1], width * -0.5);
489 glVertex3f (g2.radius * cos (angle + incr) + g2.position[0] - g1.position[0], g2.radius * sin (angle + incr) + g2.position[1] - g1.position[1], width * 0.5);
496 glVertex3f (g1.radius * cos (alpha + phi), g1.radius * sin (alpha + phi), width * 0.5);
497 glVertex3f (g1.radius * cos (alpha + phi), g1.radius * sin (alpha + phi), width * -0.5);
498 glVertex3f (g2.radius * cos (alpha + phi) + g2.position[0] - g1.position[0], g2.radius * sin (alpha + phi) + g2.position[1] - g1.position[1], width * -0.5);
499 glVertex3f (g2.radius * cos (alpha + phi) + g2.position[0] - g1.position[0], g2.radius * sin (alpha + phi) + g2.position[1] - g1.position[1], width * 0.5);
500 glVertex3f (g1.radius * cos (alpha - phi), g1.radius * sin (alpha - phi), width * 0.5);
501 glVertex3f (g1.radius * cos (alpha - phi), g1.radius * sin (alpha - phi), width * -0.5);
502 glVertex3f (g2.radius * cos (alpha - phi) + g2.position[0] - g1.position[0], g2.radius * sin (alpha - phi) + g2.position[1] - g1.position[1], width * -0.5);
503 glVertex3f (g2.radius * cos (alpha - phi) + g2.position[0] - g1.position[0], g2.radius * sin (alpha - phi) + g2.position[1] - g1.position[1], width * 0.5);
540 GLint axle_index, i, j, g1, g2, k;
678 g1 = gear_find (b[i].gear1_name);
680 D = sqrt (pow (g[g1].position[0] - g[g2].position[0], 2) + pow (g[g1].position[1] - g[g2].position[1], 2) + pow (g[g1].position[2] - g[g2].position[2], 2));
681 if (!((g[g1].axis == g[g2].axis) && (!strcmp (g[g1].type, g[g2].type)) && (!strcmp (g[g1].type, "NORMAL"))))
687 if ((g[g1].axis == g[g2].axis) && (!strcmp (g[g1].type, g[g2].type)) && (!strcmp (g[g1].type, "NORMAL")))
690 if((g[g1].motored)&&(g[g2].motored))
691 if(g[g2].angular_velocity!=(g[g1].angular_velocity*g[g1].radius/g[g2].radius))
693 printf("Error in belt linkage of gears %s and %s".,g[g1].name,g[g2].name);
697 if (g[g1].axis == 0)
699 dist = g[g1].position[0] - g[g2].position[0];
703 dist = g[g1].position[1] - g[g2].position[1];
706 dist = g[g1].position[2] - g[g2].position[2];
710 if (dist > (g[g1].width / 2 + g[g2].width / 2))
716 if (dist < (g[g1].width / 2 + g[g2].width / 2))
718 if (D < g[g1].radius + g[g2].radius)
720 printf ("Gears %s and %s too close to be linked with belts", g[g1].name, g[g2].name);
724 if ((g[g1].motored) && (!(g[g2].motored)))
728 g[g2].direction = (a[axle_index].direction = g[g1].direction);
729 g[g2].angular_velocity = (a[axle_index].angular_velocity = g[g1].angular_velocity * g[g1].radius / g[g2].radius);
732 if ((!(g[g1].motored)) && (g[g2].motored))
734 axle_index = axle_find (g[g1].axle_name);
735 g[g1].motored = (a[axle_index].motored = 1);
736 g[g1].direction = (a[axle_index].direction = g[g2].direction);
737 g[g1].angular_velocity = (a[axle_index].angular_velocity = g[g2].angular_velocity * g[g2].radius / g[g1].radius);