void Pulley::placeElement() { MyNode *node = getNode(); BoundingBox box = node->getWorldBox(); float x, y; switch(_currentElement) { case 0: //base y = (box.max.y - box.min.y) / 2.0f; node->setTranslation(Vector3(0.0f, y, 0.0f)); break; case 1: { //wheel Vector3 base(getNode(0)->getTranslationWorld()), wheel(base + Vector3(0.0f, 6.0f, 0.0f)); node->rotate(Vector3(0, 1, 0), M_PI/2); node->setTranslation(wheel); box = node->getModel()->getMesh()->getBoundingBox(); _radius = (box.max.x - box.min.x) / 2.0f + _linkWidth/2; // L/2 / R = sin(180/N / 2) => L = 2*R*sin(180 / 2N) _linkLength = 2 * _radius * sin(M_PI / (2*_wheelLinks)); _dropLinks = (int)((wheel.y - _linkLength/2 - base.y) / (2.0f * _linkLength)); _numLinks = _dropLinks + _wheelLinks+1 + _dropLinks; break; } case 2: case 3: { //left/right bucket //vertically halfway between base and wheel, rounded to the nearest chain link endpoint //horizontally at left/right edge of wheel Vector3 base(getNode(0)->getTranslationWorld()), wheel(getNode(1)->getTranslationWorld()); y = _dropLinks * _linkLength + (box.max.y - box.min.y) / 2.0f; Vector3 pos(base.x + (2*_currentElement - 5) * _radius, wheel.y - y, wheel.z); node->setTranslation(pos); break; } } }
void DynamixelServo::angle(float newAngle) { int rev=0; float diffAngle=newAngle-presentAngle; presentAngle=newAngle; while (diffAngle>180.0) { rev--; diffAngle-=360.0; } while(diffAngle<-180.0){ rev++; diffAngle+=360.0; } int pos=DXL2USB.readWord(id,DXL_PRESENT_POSITION_WORD); while (rev>0){ wheel(1023); int newpos=DXL2USB.readWord(id,DXL_PRESENT_POSITION_WORD); if (pos-newpos>DynamixelInterface::JITTER) rev--; pos=newpos; } while (rev<0){ wheel(1024+1023); int newpos=DXL2USB.readWord(id,DXL_PRESENT_POSITION_WORD); if (newpos-pos>DynamixelInterface::JITTER) rev++; pos=newpos; } diffAngle=presentAngle; while (diffAngle>180)diffAngle-=360.0; while (diffAngle<-180) diffAngle+=360.0; int angle=((180-diffAngle)*2047)/180; joint(angle); }
/* * Simple Two-pass algorithm to test a range of memory - * every bit flips and all locations are unique to detect * address line problems. */ U32 memory_test(void *start, U32 len, U64 seed, U32 verbose) { U64 *p = (U64*)start; U64 *e = (U64*)((U32)start + len); register U64 d = seed; U32 i, bank, cont = 1; U32 result = SUCCESS; if (verbose) printf(verbMemTstHerald, d, p, (U32)e-8); for (i=0; i < 2 && cont; i++) { /* Two-pass algorithm */ if (verbose) { if (i && !result) printf(aoknl); printf(verbWriting); wheel(1); } d = i ? ~seed : seed; for (p = start; p < e; p++) { if (i) *p = d--; else *p = d++; wheel(0); } if (verbose) { printf(verbReadCompare); wheel(1); } d = i ? ~seed : seed; for (p = start; p < e && cont; p++) { if (*p != d) { bank = ((U32)p >> 28) - 0xA; printf("\n%s Bank %d\n", dmc, (((U32)p >> 27) & 1) + bank); printf(errAddrWR_long, (U32)p, d, *p); result = FAILURE; cont = AskYN(keepGoing); } wheel(0); if (i) d--; else d++; } }
void draw_frame(ScreenBuffer *s, int frame) { static int pos = 0; s->rect(0, 0, WIDTH, HEIGHT, wheel(pos)); pos = (pos + 1) % (256 * 3); }
void rainbow2(Strip* self, uint8_t j, uint8_t length) { uint16_t i; for (i =0; i< self->length; i++) { Strip_setPixel(self, i, wheel(((i*length)+j) %255)); } }
bool MapView::eventFilter(QObject *pObject, QEvent *pEvent) { QWheelEvent *pWheelEvent; QMouseEvent *pMouseEvent; bool used = false; switch(pEvent->type()) { case QEvent::Wheel: pWheelEvent = static_cast<QWheelEvent*>(pEvent); wheel(pWheelEvent); used = true; break; case QEvent::MouseMove: pMouseEvent = static_cast<QMouseEvent*>(pEvent); mouseMove(pMouseEvent); used = true; break; case QEvent::MouseButtonPress: pMouseEvent = static_cast<QMouseEvent*>(pEvent); m_prevMousePos = pMouseEvent->pos(); used = true; break; default: break; } return used; }
task main() { while(true){ checkMode(); drive(); tread(); wheel(); } }
// display static rainbow void showrainbow(void) { int k; for ( k=0; k < NUMLEDS; k++ ) { setPixelS(k, wheel( ((k * 256 / NUMLEDS )) % 255) ); } display(); delayMillis(100); }
int main(){ //portInit(); serial_initialize(57600); dxl_initialize( 0, 1 ); // init with baud = 1 Mbps ADCInit(); sei(); //Enables global interrupts unsigned int distanceLeft, distanceRight, front, movingLeft, movingRight; signed int speedLeft, speedRight; while(1) { //printf("%d %d\n\n",getSensorValue(3),getSensorValue(4)); //_delay_ms(1000); // Get sensor reading (in cm) front = DMSDistance(getSensorValue(1)); distanceLeft = IRValue(getSensorValue(3)); distanceRight = IRValue(getSensorValue(4)); // Calculating the required speed speedRight = (int)((front-40*distanceLeft)); speedLeft = (int)((front-40*distanceRight)); movingLeft = dxl_read_byte( 1, 38 ); movingRight = dxl_read_byte(2,38); if(movingLeft < 15 && movingRight < 15){ wheel(1,0); wheel(2,-20); _delay_ms(1000); }else{ wheel(1,-speedRight); wheel(2,speedLeft); } printf("%d %d - %d\n\n",speedLeft,speedRight,getSensorValue(1)); //_delay_ms(1000); // Making the wheels spin } return 0; }
void ofTurtle::draw(int _x, int _y) { int ppi=pixPerInch; ofPoint wheel(.25*ppi,(2+3/8)*ppi); ofPoint rWheel(1.125*ppi,1.875*ppi); ofRectangle body(-3.25*ppi/2,-wheel.y/2,ppi*3.25,ppi*4.5); //int body=w-whlWid*2; //int leng=h; ofEnableSmoothing(); for (unsigned int i=0; i<lines.size()-1&&lines.size()>1; i++) { ofSetLineWidth(2); ofLine(lines[i].x, lines[i].y, lines[i+1].x, lines[i+1].y); } ofDisableSmoothing(); ofPushMatrix(); ofTranslate(pos.x, pos.y, 0); ofRotate(360-bearing.absoluteAngle()); ofEnableSmoothing(); ofSetColor(black.opacity(128)); ofRect(body.x,body.y,body.width,body.height); ofSetColor(white); ofNoFill(); ofRect(body.x,body.y,body.width,body.height); ofFill(); ofSetColor(black); ofRect(body.x-ppi*3/8, body.y, wheel.x, wheel.y); ofRect(body.x+body.width+ppi*3/32, body.y, wheel.x, wheel.y); /*ofSetColor(white*.8); ofRect(body.x+(body.width-ppi*1.375)/2, body.y+body.height, 1.375*ppi, .25*ppi); ofRect(body.x+(body.width-ppi*1.375)/2+1.125*ppi, body.y+body.height, .25*ppi,1.375*ppi); ofSetColor(white*.5); ofRect(body.x+(body.width-ppi*1.375)/2+.125*ppi, body.y+body.height+.5*ppi, .875*ppi, 1.5*ppi); ofSetColor(orange); ofRect(body.x+(body.width-ppi*1.375)/2+.125*ppi, body.y+body.height+.50625*ppi, .375*ppi, .4375*ppi); ofRect(body.x+(body.width-ppi*1.375)/2+.125*ppi, body.y+body.height+(2.-.4375)*ppi, .375*ppi, .4375*ppi); ofRect(body.x+(body.width-ppi*1.375)/2+(1-.375)*ppi, body.y+body.height+(.5+(1.5-.4375)/2)*ppi, .375*ppi, .4375*ppi);*/ ofPopMatrix(); ofDisableSmoothing(); if(!frontIsClear(frontCheckDist)) ofSetColor(255, 0, 0); else ofSetColor(0, 255, 0); ofPoint ps = pointAlongBearing(frontCheckDist+wheel.y/2); ofCircle(ps.x, ps.y, 5); if(!leftIsClear(leftCheckDist)) ofSetColor(255, 0, 0); else ofSetColor(0, 255, 0); ps = pos+bearing.ortho().unit()*w/2-bearing.unit()*w/2+bearing.unit().rotate(270)*leftCheckDist; ofCircle(ps.x, ps.y, 5); for (unsigned int i=0; i<bdy.size(); i++) { ofSetColor(yellow); ofVector t=bdy[i]; ofLine(pos, pos+t.rotate(360-bearing.absoluteAngle())); } }
uint16_t * rainbow_cycle(uint16_t *strip) { static int t; for(int i = 0; i < NUM_LEDS; ++i) { strip[i] = wheel(((i * 96 / NUM_LEDS) + t) % 96); } ++t; return strip; }
bool QGLGraphicsNavigationItemPrivate::handleWheel(QGraphicsSceneWheelEvent *e) { if ((viewportItem->options() & QGLGraphicsViewportItem::CameraNavigation) != 0) { wheel(e->delta()); return true; } else { return false; } }
void main() { int gd,gm,i; detectgraph(&gd,&gm); initgraph(&gd,&gm,"c:\\tc\\bgi"); wheel(); //for loading home_draw(); // for home page design profile_draw(); closegraph(); }
void rainbow(Strip* self, uint8_t wait) { uint16_t i,j; for (j=0; j<256; j++) { // TOFIX: 256 for (i =0; i< self->length; i++) { Strip_setPixel(self, i, wheel(((i*10)+j) %255)); } Strip_show(self); delay32Ms(0,wait); } }
// animate fading rainbow cycle void rainbowcycle(void) { int k, j; for ( j=0; j<256; j++ ) { for ( k=0; k < NUMLEDS; k++ ) { setPixelS(k, wheel( ( k+j) % 255 ) ); } display(); delayMillis(100); } }
// r a i n b o w C y c l e ( ) //================================================================================= //From Adafruit // Slightly different, this makes the rainbow equally distributed throughout // void GoldieClock::rainbowCycle(uint8_t wait, uint8_t repeatNumber) { for(uint16_t j = 0; j < 256U * repeatNumber; j++) { // repeatNumber of cycles of all colors on wheel for(uint16_t i=0; i< numPixels(); i++) { setPixelColor(i, wheel(((i * 256 / numPixels()) + j) & 255)); } show(); delay(wait); } }
uint16_t * chase(uint16_t *strip) { static unsigned int t; for(int i = 0; i < NUM_LEDS; ++i) { strip[i] = (i + t) & 3 ? LED_OFF : wheel(((i * 96 / NUM_LEDS) - t) % 96); } vTaskDelay(50 / portTICK_RATE_MS); ++t; return strip; }
/*! Processes the mouse move event \a e. */ void QGLView::mouseMoveEvent(QMouseEvent *e) { if (d->panning) { QPoint delta = e->pos() - d->startPan; if (e->modifiers() == d->panModifiers) { d->camera->setEye(d->startEye); d->camera->setCenter(d->startCenter); d->camera->setUpVector(d->startUpVector); } else { d->startPan = d->lastPan; delta = e->pos() - d->startPan; d->startEye = d->camera->eye(); d->startCenter = d->camera->center(); d->startUpVector = d->camera->upVector(); d->panModifiers = e->modifiers(); } d->lastPan = e->pos(); if ((e->modifiers() & Qt::ControlModifier) != 0) wheel(delta.y() * -60); else if ((e->modifiers() & Qt::ShiftModifier) != 0) pan(delta.x(), delta.y()); else rotate(delta.x(), delta.y()); } else if ((d->options & QGLView::ObjectPicking) != 0) { QObject *object = objectForPoint(e->pos()); if (d->pressedObject) { // Send the move event to the pressed object. Use a position // of (0, 0) if the mouse is still within the pressed object, // or (-1, -1) if the mouse is no longer within the pressed object. QMouseEvent event (QEvent::MouseMove, (d->pressedObject == object) ? QPoint(0, 0) : QPoint(-1, -1), e->globalPos(), e->button(), e->buttons(), e->modifiers()); QCoreApplication::sendEvent(d->pressedObject, &event); } else if (object) { if (object != d->enteredObject) { if (d->enteredObject) sendLeaveEvent(d->enteredObject); d->enteredObject = object; sendEnterEvent(d->enteredObject); } QMouseEvent event (QEvent::MouseMove, QPoint(0, 0), e->globalPos(), e->button(), e->buttons(), e->modifiers()); QCoreApplication::sendEvent(object, &event); } else if (d->enteredObject) { sendLeaveEvent(d->enteredObject); d->enteredObject = 0; } } QGLWidget::mouseMoveEvent(e); }
QPopupMenu * ViewFogGL3::createToolsMenu(QWidget * parent) { QPixmap wheel(ViewerIcon3::icon_wheel); QPopupMenu * menu = new QPopupMenu(parent,"Fog Menu"); int id = menu->insertItem(wheel,tr("Control"),__control, SLOT(show())); ViewPopupButton3 * bt = new ViewPopupButton3(menu,id,"Control Fog"); QObject::connect(__control,SIGNAL(visibilityChanged(bool)),bt,SLOT(check(bool))); menu->insertSeparator(); id = menu->insertItem(tr("Enable"),this, SLOT(setEnable())); bt = new ViewPopupButton3(menu,id,"Enable Fog"); QObject::connect(this,SIGNAL(enabled(bool)),bt,SLOT(check(bool))); return menu; }
void QQuickMouseArea::wheelEvent(QWheelEvent *event) { Q_D(QQuickMouseArea); if (!d->enabled) { QQuickItem::wheelEvent(event); return; } QQuickWheelEvent we(event->posF().x(), event->posF().y(), event->angleDelta(), event->pixelDelta(), event->buttons(), event->modifiers()); we.setAccepted(d->isWheelConnected()); emit wheel(&we); if (!we.isAccepted()) QQuickItem::wheelEvent(event); }
void QQuickMouseArea::wheelEvent(QWheelEvent *event) { Q_D(QQuickMouseArea); if (!d->enabled || (!isScrollGestureEnabled() && event->source() != Qt::MouseEventNotSynthesized)) { QQuickItem::wheelEvent(event); return; } QQuickWheelEvent we(event->posF().x(), event->posF().y(), event->angleDelta(), event->pixelDelta(), event->buttons(), event->modifiers()); we.setAccepted(d->isWheelConnected()); emit wheel(&we); if (!we.isAccepted()) QQuickItem::wheelEvent(event); }
void paratraverse(int r) { cleardevice(); std::vector<Point2D> list; parabola(getmaxx()/2, getmaxy(), 16, list, true); std::sort(list.begin(), list.end(), compPoint2D); setcolor(WHITE); float theta = 0; for (auto i = list.begin(); i != list.end(); i+=10, theta+=10) { Point2D t(*i); if (t.y > getmaxy() - r) t.y = t.y - r; else if(i - list.begin() > list.size()/2) t = Point2D(t.x - r, t.y); else t = Point2D(t.x + r, t.y); wheel(t, r, theta); parabola(getmaxx()/2, getmaxy(), 16, list); setcolor(BLACK); delay(100); wheel(t, r, theta); setcolor(WHITE); } getch(); }
void ofTurtle::setup(string filename) { map.loadImage(filename); int ppi=pixPerInch=map.width/48; ofPoint wheel(.25*ppi,(2+3/8)*ppi); ofPoint rWheel(1.125*ppi,1.875*ppi); setup(2*(map.width/12.),map.height-3*(map.height/12.), pixPerInch*5,7.25*pixPerInch); ofRectangle body(-3.25*ppi/2,-wheel.y/2,ppi*3.25,ppi*4.5); bdy.push_back(ofVector(body.x,body.y)); bdy.push_back(ofVector(body.x+body.width,body.y)); bdy.push_back(ofVector(body.x,body.y+body.height)); bdy.push_back(ofVector(body.x+body.width,body.y+body.height)); //bdy.push_back(ofVector(body.x+(body.width-rWheel.x)/2,body.y+body.height+rWheel.y)); //bdy.push_back(ofVector(body.x+(body.width+rWheel.x)/2,body.y+body.height+rWheel.y)); //ofRect(body.x+(body.width-ppi*1.375)/2+.125*ppi, body.y+body.height+.5*ppi, .875*ppi, 1.5*ppi); }
void ossimGui::ImageScrollWidget::wheelEvent ( QWheelEvent * e ) { //QScrollArea::wheelEvent(e); if(!m_inputBounds.hasNans()) { ossimIpt origin = m_inputBounds.ul(); ossimIpt localPoint(m_scrollOrigin.x +e->x(), m_scrollOrigin.y+e->y()); ossimIpt viewPoint(localPoint.x+origin.x, localPoint.y+origin.y); ossimDrect rect = viewportBoundsInViewSpace(); emit wheel(e, rect, viewPoint);//viewportPoint, localPoint, viewPoint); } }
void WheeledBaseSim::drawGL() { //constructor: create a physical representation of the robot only for drawing double height=wheel_radius*3; double clearance=wheel_radius; vector<Vector2D> list; PrismaticPart bod; list.push_back(Vector2D(large/2,width/2)); list.push_back(Vector2D(large/2,-width/2)); list.push_back(Vector2D(-large/2,-width/2)); list.push_back(Vector2D(-large/2,width/2)); bod.setPolygonalBase(list); bod.setHeight(height-clearance); bod.setRelativePosition(Vector3D(0,0,clearance)); bod.setColor(1,0,0); //las ruedas no se pueden añadir hasta no tener un mecanismo de exclusión de detección CylindricalPart wheel(wheel_width,wheel_radius); wheel.setColor(0.1,0.1,0.1); glPushMatrix(); getAbsoluteT3D().transformGL(); //body bod.drawGL(); //each wheel wheel.setRelativeOrientation(X_AXIS,-PI/2); wheel.setRelativePosition(Vector3D(large/2,width/2,wheel_radius+0.002)); wheel.drawGL(); wheel.setRelativeOrientation(X_AXIS,-PI/2); wheel.setRelativePosition(Vector3D(-large/2,width/2,wheel_radius+0.002)); wheel.drawGL(); wheel.setRelativeOrientation(X_AXIS,PI/2); wheel.setRelativePosition(Vector3D(large/2,-width/2,wheel_radius+0.002)); wheel.drawGL(); wheel.setRelativeOrientation(X_AXIS,PI/2); wheel.setRelativePosition(Vector3D(-large/2,-width/2,wheel_radius+0.002)); wheel.drawGL(); glPopMatrix(); return; }
bool QGLGraphicsNavigationItemPrivate::handleMouseMove(QGraphicsSceneMouseEvent *e) { if (panning) { QPointF delta = e->pos() - startPan; startPan = e->pos(); if ((e->modifiers() & Qt::ControlModifier) != 0) wheel(delta.y() * -60); else if ((e->modifiers() & Qt::ShiftModifier) != 0) pan(delta.x(), delta.y()); else rotate(delta.x(), delta.y()); } else if ((viewportItem->options() & QGLGraphicsViewportItem::ObjectPicking) != 0) { QObject *object = viewportItem->objectForPosition(e->pos()); if (pressedObject) { // Send the move event to the pressed object. Use a position // of (0, 0) if the mouse is still within the pressed object, // or (-1, -1) if the mouse is no longer within the pressed object. QMouseEvent event (QEvent::MouseMove, (pressedObject == object) ? QPoint(0, 0) : QPoint(-1, -1), e->screenPos(), e->button(), e->buttons(), e->modifiers()); QCoreApplication::sendEvent(pressedObject, &event); } else if (object) { if (object != enteredObject) { if (enteredObject) sendLeaveEvent(enteredObject); enteredObject = object; sendEnterEvent(enteredObject); } QMouseEvent event (QEvent::MouseMove, QPoint(0, 0), e->screenPos(), e->button(), e->buttons(), e->modifiers()); QCoreApplication::sendEvent(object, &event); } else if (enteredObject) { sendLeaveEvent(enteredObject); enteredObject = 0; } } else { return false; } return true; }
//----------------------------------------------------------------------------------------- void TestTransformation::onMouseMoved() { if (m_bTouch) return; if (CCamera* pCamera = m_pView->getCurrentCamera()) { if (m_bPressed) { CMouseStates mouseStates = m_pView->getMouseStates(); QPoint delta = mouseStates.getPosition() - m_StartPan; if (mouseStates.isRightButtonPressed()) { pCamera->setEyePosition(m_vStartEye); pCamera->setCenter(m_vStartCenter); pCamera->setUp(m_vStartUpVector); } else { m_StartPan = m_LastPan; delta = mouseStates.getPosition() - m_StartPan; m_vStartEye = pCamera->getEyePosition(); m_vStartCenter = pCamera->getCenter(); m_vStartUpVector = pCamera->getUp(); } m_LastPan = mouseStates.getPosition(); if (mouseStates.isRightButtonPressed()) { wheel(-delta.y()); } else { rotate(delta.x(), delta.y()); } } } }
U32 ImpatientWheel(U32 prt) { int c = 0; if (kbhit()) { c = GET_KEY(); if (c == ESC) { /* * Eat all keystrokes, user may have * been hammering escape key trying * to get out. */ flushKbd(); sheSaidQuit = YES; return (1); } else Gripe(); } wheel(prt); return (0); }
//Plays a song according to what top hat (D-Pad) button is pressed task musicalButtons() { while(true) { if(joystick.joy1_TopHat==1) { champions(); } else if(joystick.joy1_TopHat==2) { impossible(); } else if(joystick.joy1_TopHat==3) { mario(); } else if(joystick.joy1_TopHat==4) { gangnam(); } else if(joystick.joy1_TopHat==5) { jones(); } else if(joystick.joy1_TopHat==6) { wheel(); } else if(joystick.joy1_TopHat==7) { hall(); } else if(joystick.joy1_TopHat==8) { circus(); } } }
/*! Processes the key press event \a e. */ void QGLView::keyPressEvent(QKeyEvent *e) { QGLCamera *camera; qreal sep; if ((d->options & QGLView::CameraNavigation) == 0) { QGLWidget::keyPressEvent(e); return; } switch (e->key()) { case Qt::Key_Escape: case Qt::Key_Q: { if (parentWidget() == 0) close(); } case Qt::Key_Left: { if ((e->modifiers() & Qt::ShiftModifier) != 0) { pan(-10, 0); } else if ((e->modifiers() & Qt::ControlModifier) != 0) { camera = this->camera(); sep = camera->eyeSeparation(); sep -= (sep / 10.0f); if (sep < 0.0f) sep = 0.0f; camera->setEyeSeparation(sep); e->accept(); return; } else { rotate(-10, 0); } } break; case Qt::Key_Right: { if ((e->modifiers() & Qt::ShiftModifier) != 0) { pan(10, 0); } else if ((e->modifiers() & Qt::ControlModifier) != 0) { camera = this->camera(); sep = camera->eyeSeparation(); sep += (sep / 10.0f); camera->setEyeSeparation(sep); e->accept(); return; } else { rotate(10, 0); } } break; case Qt::Key_Up: { if ((e->modifiers() & Qt::ControlModifier) != 0) wheel(120); else if ((e->modifiers() & Qt::ShiftModifier) != 0) pan(0, -10); else rotate(0, -10); } break; case Qt::Key_Down: { if ((e->modifiers() & Qt::ControlModifier) != 0) wheel(-120); else if ((e->modifiers() & Qt::ShiftModifier) != 0) pan(0, 10); else rotate(0, 10); } break; } QGLWidget::keyPressEvent(e); }