int main() { int test; scanf("%d",&test); //printf("%lf\n",sqrt(2.0)); for(int tt = 1 ; tt <= test ;tt ++) { for(int i=0;i<4;i++) { scanf("%lf %lf",&x[i],&y[i]); } a[0] = 0; a[1] = 2;a[2] = 1;a[3] = 3; int flag = 0; if(pan())flag=1; a[0] = 0; a[1] = 1;a[2] = 2;a[3] = 3; if(pan())flag=1; a[0] = 0; a[1] = 1 ; a[2] = 3;a[3] = 2; if(pan())flag=1; if(tt != 1)printf("\n"); if(flag == 1) printf("Case %d:\nYes\n",tt); if(flag == 0) printf("Case %d:\nNo\n",tt); } }
void WaypointCamera::setOriginTarget(){ originTarNode.resetTransform(); originTarNode.setPosition(getPosition()); pan(-180); // Fix for camera orientation originTarNode.setOrientation(getOrientationQuat()); pan(180); // Fix for camera orientation }
int main(void) { int f,res,b[300],ji; char a[300][20],c[20]; while(scanf("%s",&a[0])!=EOF) { strcpy(c,a[0]); res=pan(a[0]); ji=1; for(ji=1;0==res;ji++) { b[ji]=tod(a[ji-1]); fan(a[ji-1]); b[ji]=b[ji]+tod(a[ji-1]); tos(b[ji],a[ji]); res=pan(a[ji]); } printf("%d\n",ji-1); printf("%s",c); for(f=1;f<ji;f++) { printf("--->"); printf("%s",a[f]); } printf("\n"); } return 0; }
void Camera::setMotionAdjustment(const QVector3D& vector) { Q_D(Camera); if (d->motionAdjustment != vector) { d->motionAdjustment = vector; if (vector.x() == 0.0f && vector.y() == 0.0f) { // If the vector is centered, then don't perform any rotations. d->motionQuaternion = QQuaternion(); } else { // Determine the pan and tilt angles from the vector. QVector3D view = -vector.normalized(); if (view.z() < 0.0f) view = -view; qreal xangle = asin(view.x()) * 180.0f / M_PI; qreal yangle = asin(-view.y()) * 180.0f / M_PI; // Construct the pan and tilt quaternions. if (qFuzzyIsNull(xangle)) d->motionQuaternion = tilt(yangle); else if (qFuzzyIsNull(yangle)) d->motionQuaternion = pan(xangle); else d->motionQuaternion = tilt(yangle) * pan(xangle); } emit viewChanged(); } }
int main() { ssc_init("/dev/ttyUSB0", 9600); pan( 0 ); tilt( 0 ); cascade = (CvHaarClassifierCascade*)cvLoad( "cascade.xml", 0, 0, 0 ); if( !cascade ) { fprintf( stderr, "ERROR: Could not load classifier cascade\n" ); return 1; } storage = cvCreateMemStorage(0); struct camera *cam = init_camera( LCAM ); load_params( cam ); cvNamedWindow( "Face", CV_WINDOW_AUTOSIZE ); CvPoint pt1, pt2; CvRect *r; CvSeq *faces; float multip = 0.1; int x_diff, y_diff; while( cvWaitKey( 10 ) == -1 ) { cap_frame( cam ); undistort( cam ); cvClearMemStorage( storage ); faces = cvHaarDetectObjects( cam->undist, cascade, storage, 1.1, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize(40, 40) ); if (faces->total > 0) { ; r = (CvRect*)cvGetSeqElem( faces, 0 ); pt1.x = r->x; pt2.x = r->x + r->width; pt1.y = r->y; pt2.y = r->y + r->height; cvRectangle( cam->undist, pt1, pt2, CV_RGB(255,0,0), 3, 8, 0 ); x_diff = (cam->frame->width / 2) - (r->x + (r->width/2)) ; y_diff = (cam->frame->height / 2) - (r->y + (r->height/2)) ; pan( -(int)(x_diff * multip) ); tilt( (int)(y_diff * multip) ); } cvShowImage( "Face", cam->undist ); } cvDestroyAllWindows(); cvReleaseMemStorage( &storage ); free_camera( cam ); }
void WaypointCamera::setSnapToTarget(bool snap){ if(snap == true){ camState = WAYPOINT_CAM_STATE_TARGET; // Update the prev target node preTarNode.resetTransform(); preTarNode.setPosition(getPosition()); pan(-180); // Fix for camera orientation preTarNode.setOrientation(getOrientationQuat()); pan(180); // Fix for camera orientation }else{ camState = WAYPOINT_CAM_STATE_FREE; } }
WaypointCamera::WaypointCamera(){ // Initialize the current and previous targets for cam curTarNode.setPosition(getPosition()); pan(-180); // Fix for camera orientation curTarNode.setOrientation(getOrientationQuat()); pan(180); // Fix for camera orientation preTarNode = curTarNode; // The camrea origin starts off as the default camera positoin. originTarNode = preTarNode; arrivedAtTarget = false; isMoving = false; }
//------------------------------------------------------------------------------ //! bool CameraManipulator::onPointerMove( const Event& ev ) { if( _mode == 0 ) return false; switch( _mode ) { case 1: { float radP = CGM::degToRad( _grabPos.x - ev.position().x ); float radS = CGM::degToRad( ev.position().y - _grabPos.y ); radP *= _direction; if( _isLocked ) { orbit( radP*0.75f, radS*0.75f ); } else { tilt( radP*0.25f, radS*0.25f ); } return true; } break; case 2: forward( ev.position() ); return true; case 3: pan( ev.position() ); return true; default:; } return false; }
SDL_Surface *zoom100(SDL_Surface *image, SDL_Rect *pos, double *scale) { SDL_Surface *result = SDL_ConvertSurface(image, image->format, image->flags); if (result == (SDL_Surface *) (NULL)) { fprintf(stderr, "\n Error from ConvertSurface()\n\n"); quit(); } if (*scale < 1.0) { pos->x /= *scale; pos->y /= *scale; pos->x -= SCREENWIDTH * (1-(1 / *scale)) * 0.5; pos->y -= SCREENHEIGHT * (1-(1 / *scale)) * 0.5; } else { pos->x += SCREENWIDTH * (1-*scale) * 0.5; pos->y += SCREENHEIGHT * (1-*scale) * 0.5; pos->x /= *scale; pos->y /= *scale; } pan(result, pos, 0, 0); *scale = 1.0; return result; }
AREXPORT bool ArAMPTU::panTilt_i(double panDeg, double tiltDeg) { if (panDeg > getMaxPosPan_i()) panDeg = getMaxPosPan_i(); if (panDeg < getMaxNegPan_i()) panDeg = getMaxNegPan_i(); if (tiltDeg > getMaxPosTilt_i()) tiltDeg = getMaxPosTilt_i(); if (tiltDeg < getMaxNegTilt_i()) tiltDeg = getMaxNegTilt_i(); if (myPan - panDeg == 0 && myTilt - tiltDeg == 0) return true; if (myPan - panDeg == 0) return tilt(tiltDeg); if (myTilt - tiltDeg == 0) return pan(panDeg); myPan = panDeg; myTilt = tiltDeg; myPacket.empty(); myPacket.byteToBuf(ArAMPTUCommands::PANTILT); myPacket.byte2ToBuf(ArMath::roundInt(myPan + (getMaxPosPan_i() - getMaxNegPan_i())/2)); myPacket.byteToBuf(ArMath::roundInt(myTilt + (getMaxPosTilt_i() - getMaxNegTilt_i())/2)); return sendPacket(&myPacket); }
void BassPlayer::playPreproccessing() { emit statusChanged(media_title, LoadedMedia); BASS_CHANNELINFO info; if (BASS_ChannelGetInfo(chan, &info)) channelsCount(info.chans); else channelsCount(2); if (eq_in_use) registerEQ(); #ifdef BASS_USE_TEMPO applyTempoToChannel(); newTempoProcessing(tempo()); #endif setSampleRateQuality(); newVolumeProcessing(volume()); newPanProcessing(pan()); if (BASS_ChannelPlay(chan, true)) { // stalled with big sized video files playPostprocessing(is_paused); syncHandle = BASS_ChannelSetSync((HSYNC)chan, BASS_SYNC_END, 0, &endTrackSync, this); syncDownloadHandle = BASS_ChannelSetSync(chan, BASS_SYNC_DOWNLOAD, 0, &endTrackDownloading, this); // BASS_SYNC_STALL // mixtime only Sync when playback of the channel is stalled/resumed. // param : not used. data : 0 = stalled, 1 = resumed. } else { proceedErrorState(); qCritical() << "IS NOT PLAYED"; } }
void CommandInterpreter::handleCommand(TACommand command) { XTestGrabControl(display, True); printf("COMMAND: %i, %i, %i, %i, %f\n", command.type, command.touch, command.xDifference, command.yDifference, command.zoomValue); switch(command.type) { case TACommandTypeZoom: zoom(command); break; case TACommandTypePan: pan(command); break; case TACommandTypeRotate: rotate(command); break; default: break; } XSync(display, 0); XTestGrabControl(display, False); usleep(100); }
void Viewport::mouseMoveEvent(QMouseEvent *event) { _dragging = true; _current_pos = event->pos(); QGraphicsView::mouseMoveEvent(event); if (scene->mouseGrabberItem() == NULL) { if (event->buttons() == Qt::LeftButton) { pan(_click_pos_world - sceneToWorld(mapToScene(event->pos()))); } else if (event->buttons() == Qt::RightButton && !angle_locked) { QPointF d = _click_pos - event->pos(); pitch = fmin(0, fmax(-M_PI, pitch - 0.01 * d.y())); yaw = fmod(yaw + M_PI - 0.01 * d.x(), M_PI*2) - M_PI; _click_pos = event->pos(); update(); scene->invalidate(QRect(),QGraphicsScene::ForegroundLayer); emit(viewChanged()); } } updateInfo(); }
void MdispGtkView::FillDisplay( bool on ) { if(m_MilDisplay) { // Fill display is incompatible with pan. pan( 0, 0 ); if(on) { // disable temporary using user's XDisplay // filldisplay can generate excessive expose ( paint) event // this can freeze main menu window MdispControl(m_MilDisplay,M_WINDOW_ANNOTATIONS,M_NULL); } else { MdispControl(m_MilDisplay,M_WINDOW_ANNOTATIONS,M_PTR_TO_DOUBLE(GDK_WINDOW_XDISPLAY(m_window->window))); } //Using MIL, enable/disable Fill Display Mode [CALL TO MIL] MdispControl(m_MilDisplay, M_FILL_DISPLAY, on ? M_ENABLE : M_DISABLE); m_isFillDisplayEnabled = on; UpdateContentSize(); } }
int main() { int f,i; while(scanf("%d",&nn)!=EOF) { group=nn; n=2*group; for(i=1;i<=nn;i++) { for(f=1;f<=nn;f++) { scanf("%d",&b[i][f]); } } if(0 == pan()) { printf("NO\n"); continue; } for(now=1;now<=31;now++) { chu(); for(i=1;i<=nn;i++) { for(f=i+1;f<=nn;f++) { if(i == f) { continue; } else if((i%2)==0 && (f%2)==0) { huo(i,f); } else if((i%2)==1 && (f%2)==1) { yu(i,f); } else { yihuo(i,f); } } } slove(); if(0 == check()) { printf("NO\n"); break; } } if(32 == now) { printf("YES\n"); } } return 0; }
void QuatTrackBall::roll_ball(const Vec2i& v) { if(v[0] < 0 || v[0] >= static_cast<int>(width) || v[1] < 0 || v[1] >= static_cast<int>(height)) return; Vec2f w = scalePoint(v); switch (current_action) { case ROTATE_ACTION: rotate(w); break; case PAN_ACTION: pan(w); break; case ZOOM_ACTION: zoom(w); break; case NO_ACTION: default: break; } last_pos = w; }
static int checkmouse(void) /* return button touched if any */ { int c, b; char *p; extern int confirm(int); b = waitdown(); last_but = 0; last_hit = -1; c = 0; if (button3(b)) { last_hit = emenuhit(3, &mouse, &mbut3); last_but = 3; } else if (button2(b)) { last_hit = emenuhit(2, &mouse, &mbut2); last_but = 2; } else { /* button1() */ pan(); last_but = 1; } waitup(); if (last_but == 3 && last_hit >= 0) { p = m3[last_hit]; c = p[strlen(p) - 1]; } if (c == '?' && !confirm(last_but)) last_hit = -1; return last_but; }
void DisplayGroupGraphicsView::gestureEvent( QGestureEvent* evt ) { QGesture* gesture = 0; if( ( gesture = evt->gesture( Qt::SwipeGesture ))) { evt->accept( Qt::SwipeGesture ); swipe( static_cast< QSwipeGesture* >( gesture )); } else if( ( gesture = evt->gesture( PanGestureRecognizer::type( )))) { evt->accept( PanGestureRecognizer::type( )); pan( static_cast< PanGesture* >( gesture )); } else if( ( gesture = evt->gesture( PinchGestureRecognizer::type( )))) { evt->accept( PinchGestureRecognizer::type( )); pinch( static_cast< PinchGesture* >( gesture )); } else if( ( gesture = evt->gesture( Qt::TapGesture ))) { evt->accept( Qt::TapGesture ); tap( static_cast< QTapGesture* >( gesture )); } else if( ( gesture = evt->gesture( Qt::TapAndHoldGesture ))) { evt->accept( Qt::TapAndHoldGesture ); tapAndHold( static_cast< QTapAndHoldGesture* >( gesture )); } }
void Camera::mouseInput( int x, int y, int Button, int State) { if(State == GLUT_DOWN) { if(m_LastMouseX==-1) m_LastMouseX = x; if(m_LastMouseY==-1) m_LastMouseY = y; if( Button == GLUT_LEFT_BUTTON ) { rotate((float)x, (float)y ); } else if( Button == GLUT_RIGHT_BUTTON) { pan( (float)(m_LastMouseX-x)*0.01f, (float)(m_LastMouseY-y)*0.01f ); } else if( Button == GLUT_MIDDLE_BUTTON) { zoom( (float)(m_LastMouseY-y)*0.01f ); } } else { m_Position += m_Panning + m_Zoom + m_Rotation; m_Target += m_Panning; m_Panning = Vector(0,0,0); m_Zoom = Vector(0,0,0); m_Rotation = Vector(0,0,0); m_LastMouseX = -1; m_LastMouseY = -1; } }
void Navigation::panningProcess(const QPoint & mouse) { assert(PanInteraction == m_mode); // The first click of the interaction yields a object space position m_i0. // this point is our constraint for panning, that means for every mouse // position there has to be an appropriate positioning for the scene, so // that the point under the mouse remains m_i0. // With this point and the up normal we build a plane, that defines the // panning space. For panning, a ray is created, pointing from the screen // pixel into the view frustum. This ray then is converted to object space // and used to intersect with the plane at p. // The delta of m_i0 and p is the translation required for panning. // constrain mouse interaction to viewport (if disabled, could lead to mishaps) const QPoint clamped( clamp(0, m_camera.viewport().width(), mouse.x()) , clamp(0, m_camera.viewport().height(), mouse.y())); bool intersects; m_i1 = mouseRayPlaneIntersection(intersects, clamped, m_i0, m_viewProjectionInverted); if (intersects) pan(m_i0 - m_i1); }
void GLWidget::mouseMoveEvent(QMouseEvent *event) { int dx = event->x() - lastPos.x(); int dy = event->y() - lastPos.y(); if (event->buttons() & Qt::LeftButton) { // Es canvien els angles de visio de la camera segons el desplacament // Si hi ha un desplacament en X del viewport, es canviara l angle Y // Si hi ha un desplacament en Y del viewport, es canviara l angle X setYRotation( 8 * dx); setXRotation( 8 * dy); } else if (event->buttons() & Qt::RightButton) { // panning pan(dx, dy); } else if (event->buttons() & Qt::MidButton) { // zoom if (lastPos.y() > event->y()) zoom(-0.05, dy); else zoom(0.05, dy); } lastPos = event->pos(); }
void WorldInHandNavigation::panProcess(const glm::ivec2 & mouse) { if (PanInteraction != m_mode || !m_refPositionValid) return; // The first click of the interaction yields an object space position m_referencePosition. // this point is our constraint for panning, that means for every mouse // position there has to be an appropriate positioning for the scene, so // that the point under the mouse remains m_referencePosition. // With this point and the up normal we build a plane, that defines the // panning space. For panning, a ray is created, pointing from the screen // pixel into the view frustum. This ray then is converted to object space // and used to intersect with the plane at p. // The delta of m_referencePosition and p is the translation required for panning. // constrain mouse interaction to viewport (if disabled, could lead to mishaps) const glm::ivec2 clamped( glm::clamp(mouse.x, 0, m_viewportCapability.width()), glm::clamp(mouse.y, 0, m_viewportCapability.height())); bool intersects = false; m_modifiedPosition = mouseRayPlaneIntersection(intersects, clamped, m_referencePosition, glm::vec3(0.f, 1.f, 0.f)); if (intersects) pan(m_referencePosition - m_modifiedPosition); }
void mgv_action_pan(Widget w, XEvent *ev, String *argv, Cardinal *argc) { MGV *m; char *cmd; USEUP(argc); w = wl_findup(w, "mainWindow"); XtVaGetValues(w, XmNuserData, &m, NULL); assert(MgvOK(m)); cmd = lowdup(*argv); if(strcmp(cmd, "begin") == 0) { m->startx = ev->xbutton.x; m->starty = ev->xbutton.y; } else if(strcmp(cmd, "end") == 0) { m->startx = m->curx = -1; m->starty = m->cury = -1; } else if(strcmp(cmd, "pan") == 0) { m->curx = ev->xbutton.x; m->cury = ev->xbutton.y; pan(m, m->startx - m->curx, m->starty - m->cury); } else { wl_warn(m->ghost, mgv_s(w, MgvSbadArgument), "mgvPan", *argv); } XtFree(cmd); }
void DisplayGroupGraphicsView::gestureEvent( QGestureEvent* event ) { if( QGesture* gesture = event->gesture( Qt::SwipeGesture )) { event->accept( Qt::SwipeGesture ); swipe( static_cast< QSwipeGesture* >( gesture )); } else if( QGesture* gesture = event->gesture( Qt::PanGesture )) { event->accept( Qt::PanGesture ); pan( static_cast< QPanGesture* >( gesture )); } else if( QGesture* gesture = event->gesture( Qt::PinchGesture )) { event->accept( Qt::PinchGesture ); pinch( static_cast< QPinchGesture* >( gesture )); } else if( QGesture* gesture = event->gesture( Qt::TapGesture )) { event->accept( Qt::TapGesture ); tap( static_cast< QTapGesture* >( gesture )); } else if( QGesture* gesture = event->gesture( Qt::TapAndHoldGesture )) { event->accept( Qt::TapAndHoldGesture ); tapAndHold( static_cast< QTapAndHoldGesture* >( gesture )); } }
bool TrackballTransformManipulator::updateFrame( float dt ) { bool result = false; if( m_transformPath && getViewState() && getRenderTarget() ) { switch( m_mode ) { case Mode::ROTATE: result = rotate(); break; case Mode::PAN: result = pan(); break; case Mode::DOLLY: result = dolly(); break; default: break; } } return result; }
void inventory::form_from_map(game *g, point origin, int range) { items.clear(); for (int x = origin.x - range; x <= origin.x + range; x++) { for (int y = origin.y - range; y <= origin.y + range; y++) { if (g->m.has_flag(sealed, x, y)) continue; for (int i = 0; i < g->m.i_at(x, y).size(); i++) if (!g->m.i_at(x, y)[i].made_of(LIQUID)) add_item(g->m.i_at(x, y)[i]); // Kludges for now! ter_id terrain_id = g->m.ter(x, y); furn_id furniture_id = g->m.furn(x, y); if ((g->m.field_at(x, y).findField(fd_fire)) || (terrain_id == t_lava)) { item fire(g->itypes["fire"], 0); fire.charges = 1; add_item(fire); } if (terrain_id == t_water_sh || terrain_id == t_water_dp){ item water(g->itypes["water"], 0); water.charges = 50; add_item(water); } int vpart = -1; vehicle *veh = g->m.veh_at(x, y, vpart); if (veh) { const int kpart = veh->part_with_feature(vpart, vpf_kitchen); const int weldpart = veh->part_with_feature(vpart, vpf_weldrig); if (kpart >= 0) { item hotplate(g->itypes["hotplate"], 0); hotplate.charges = veh->fuel_left("battery", true); add_item(hotplate); item water(g->itypes["water_clean"], 0); water.charges = veh->fuel_left("water"); add_item(water); item pot(g->itypes["pot"], 0); add_item(pot); item pan(g->itypes["pan"], 0); add_item(pan); } if (weldpart >= 0) { item welder(g->itypes["welder"], 0); welder.charges = veh->fuel_left("battery", true); add_item(welder); item soldering_iron(g->itypes["soldering_iron"], 0); soldering_iron.charges = veh->fuel_left("battery", true); add_item(soldering_iron); } } } } }
bool CameraTool2D::doStartMouseDrag(const InputState& inputState) { if (pan(inputState)) { m_lastMousePos = Vec2f(static_cast<float>(inputState.mouseX()), static_cast<float>(inputState.mouseY())); return true; } return false; }
void motion(int x, int y) { if (mot == PAN) pan(x, y); else if (mot == ROT) rotate(x, y); }
void Canvas::wheelEvent(QWheelEvent *event) { QVector3D a = sceneToWorld(mapToScene(event->pos())); scale *= pow(1.001, -event->delta()); QVector3D b = sceneToWorld(mapToScene(event->pos())); pan(a - b); emit(viewChanged()); }
void FixedRatioTransform::setView(double zoom, QPointF dataPoint, QPointF scenePoint) { zoom = clamp(zoom, m_minZoom, m_maxZoom); m_zoom = zoom; QPointF p1 = -toPoint(dataToScene(toSize(m_dataRect.topLeft()))); QPointF p2 = -toPoint(dataToScene(toSize(m_dataRect.bottomRight()))); m_clampRect = QRectF(p1, p2).normalized(); pan(dataPoint, scenePoint); }