本文整理汇总了C++中Coord::motor_l方法的典型用法代码示例。如果您正苦于以下问题:C++ Coord::motor_l方法的具体用法?C++ Coord::motor_l怎么用?C++ Coord::motor_l使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coord
的用法示例。
在下文中一共展示了Coord::motor_l方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_control
void init_control(Coord& _coord) {
coord = &_coord;
motor_r = &_coord.motor_r();
motor_l = &_coord.motor_l();
Point* pos = &_coord.pos();
_w = motor_r->x + motor_l->x;
_h = motor_l->y + motor_l->x;
double dx = pos->x - motor_l->x;
double dy = motor_l->y - pos->y;
_ll = sqrt(dx*dx + dy*dy);
dx = motor_r->x - pos->x;
_lr = sqrt(dx*dx + dy*dy);
glut_loop = new thread([]() {
int argc = 1;
char* argv = (char*)"";
glutInit(&argc, &argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
// Create the window
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow("V-Plotter Simulator");
glClearColor(0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST);
timer(0);
glutDisplayFunc([]() {
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
// cout << "pos: (" << pos->x << ";" << pos->y << ")" << endl;
// cout << "motor_l: (" << motor_l->x << ";" << motor_l->y << ")" << endl;
// cout << "motor_r: (" << motor_r->x << ";" << motor_r->y << ")" << endl;
// draw motors
glBegin(GL_QUADS);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glVertex3f( motor_l->x - 5, motor_l->y - 5, 0);
glVertex3f( motor_l->x + 5, motor_l->y - 5, 0);
glVertex3f( motor_l->x + 5, motor_l->y + 5, 0);
glVertex3f( motor_l->x - 5, motor_l->y + 5, 0);
glVertex3f( motor_r->x - 5, motor_r->y - 5, 0);
glVertex3f( motor_r->x + 5, motor_r->y - 5, 0);
glVertex3f( motor_r->x + 5, motor_r->y + 5, 0);
glVertex3f( motor_r->x - 5, motor_r->y + 5, 0);
glEnd();
// draw trace
glColor4f(0, 0, 1, 1);
for (auto trace : traces) {
glBegin(GL_LINE_STRIP);
for (Point* p : *trace)
glVertex3f(p->x, p->y, 0);
glEnd();
}
if (curr_trace) {
glBegin(GL_LINE_STRIP);
for (Point* p : *curr_trace)
glVertex3f(p->x, p->y, 0);
glEnd();
}
// draw printer
Point* pos = get_pos(*coord);
glBegin(GL_LINES);
if (curr_trace) glColor4f(0, 0, 1, 1);
else glColor3f(0, 1, 0);
glVertex3f(pos->x - 10, pos->y - 10, 0);
glVertex3f(pos->x + 10, pos->y + 10, 0);
glVertex3f(pos->x + 10, pos->y - 10, 0);
glVertex3f(pos->x - 10, pos->y + 10, 0);
// draw strings
glColor3f(1, 0, 0);
glVertex3f(motor_l->x, motor_l->y, 0);
glVertex3f(pos->x, pos->y, 0);
glVertex3f(motor_r->x, motor_r->y, 0);
glVertex3f(pos->x, pos->y, 0);
glEnd();
glFlush();
});
//.........这里部分代码省略.........