예제 #1
0
//DONE
//given path --> find if next coordinate is outside of map
//not sure if i need to check for size of char array
static int isLegalPathToCamp(path destination) {
    assert(strlen(destination)  <  PATH_LIMIT);
    int isLegal = TRUE;
    int i = 0;
    coordinates oldxy;
    coordinates newxy;
    oldxy.x = 5;
    oldxy.y = 0;
    oldxy.direction = SOUTH_EAST;
    newxy = oldxy;
    //testing if is even legal path input
    while(destination[i] != '\0'  &&  i < PATH_LIMIT) {
        if(!(destination[i] == 'L' ||
             destination[i] == 'R' || destination[i] == 'B')) {
            isLegal = FALSE;
        }
        i++;
    }
    //code for checking size of char array
    //testing if path goes into water
    i = 0;
    while(isLegal == TRUE  &&  destination[i] != '\0'  &&
          i < PATH_LIMIT) {
        newxy = newCoords(newxy, destination[i]);
        newxy.direction = newDirection(newxy.direction,
                                       destination[i]);
        if(isInBounds(newxy) == FALSE) {
            isLegal = FALSE;
        }
        i++;
    }
    return isLegal;
}
예제 #2
0
	void UIInLink::move(const Vector2f& amountToMove)
	{
		UINodeLink::move(amountToMove);

		if(m_linkStrip != nullptr)
		{
			CanvasCoordinates newCoords(getParentCanvas(), getAbsoluteCoordinates() + Vector2f(0.0, getSize().y * .25f));
			m_linkStrip->updateEndPoint(newCoords);
		}
	}
예제 #3
0
	void UIOutLink::move(const Vector2f& amountToMove)
	{
		UINodeLink::move(amountToMove);

		CanvasCoordinates newCoords(getParentCanvas(), getAbsoluteCoordinates() + Vector2f(0.0, getSize().y * .25f));
		for(auto it = m_linkStrips.begin(); it != m_linkStrips.end(); ++it)
		{
			(*it)->updateStartPoint(newCoords);
		}
	}
예제 #4
0
PopupWindow* PopupWindowsStack::newWindow()
{
	qDebug() << Q_FUNC_INFO << "{";
	PopupWindow* p = new PopupWindow(newCoords());
	connect(p, SIGNAL(closePopupWindow()), this, SLOT(windowClosed()));
	connect(p, SIGNAL(mouseEntered()), this, SIGNAL(mouseEntered()));
	connect(p, SIGNAL(mouseLeaved()), this, SIGNAL(mouseLeaved()));
	existingWindows.append(p);
	shownWindows.append(p);	
	qDebug() << Q_FUNC_INFO << "}";
	return p;
}
예제 #5
0
void PopupWindowsStack::retranslateWindowsGeometry()
{
	qDebug() << Q_FUNC_INFO << "{";
	QList<PopupWindow*>::iterator it = shownWindows.begin();
	quint32 i = 1;
	for (; it != shownWindows.end(); ++it)
	{
		QRect g = newCoords(i);
		(*it)->setGeometry(g);
		++i;
	}
	qDebug() << Q_FUNC_INFO << "}";
}
예제 #6
0
//DONE
//tests given a path returns the coordinates it points to
static coordinates getCoords(path vertexPath) {
    coordinates xycoord;
    xycoord.x = 5;
    xycoord.y = 0;
    xycoord.direction = SOUTH_EAST;
    int i = 0;
    while(i < PATH_LIMIT  &&  vertexPath[i] != '\0') {  
        xycoord = newCoords(xycoord, vertexPath[i]);
        xycoord.direction = newDirection(xycoord.direction,
                                         vertexPath[i]);
        i++;
    }
    return xycoord;
}
예제 #7
0
//DONE
//must have an arc connected to it & not blocked by campus
//given destination --> if there is an arc on it --> cannot place
//given resources
static int isLegalBuildARC(Game g, action a) {
    int isLegal = TRUE;
    int arcTests[3] = {TRUE, TRUE, TRUE};
    int player = getWhoseTurn(g);
    coordinates xycoord1;
    coordinates xycoord2;
    //if path is actual a legal path
    if(isLegalPathToARC(a.destination) == FALSE) {
        isLegal = FALSE;
    }
    //if already owned
    if(isLegal == TRUE) {
        if(getARC(g, a.destination) != 0) {
            isLegal = FALSE;
        }
    }
    //if not enough resources
    if(g->students[player][STUDENT_BPS] < 1 ||
       g->students[player][STUDENT_BQN] < 1) {
        isLegal = FALSE;
    }

    //Board state exceptions
    xycoord1 = getCoords(a.destination);
    xycoord2 = newCoords(xycoord1, 'B');
    //test if arc has campus next to it
    //test if has path but not blocked by campus
    //get what coordinate it is on and then get next coordinate
    //then test if next coordinates has arcs next to them
    if(hasVertexARC(g, xycoord1) == FALSE  &&
       (!(getCampusWithCoord(g, xycoord2) == player  ||
       getCampusWithCoord(g, xycoord2) == player + 3))) {
        arcTests[0] = FALSE;
    } 
    if(hasVertexARC(g, xycoord2) == FALSE  &&
       (!(getCampusWithCoord(g, xycoord1) == player  ||
       getCampusWithCoord(g, xycoord1) == player + 3))) {
        arcTests[1] = FALSE;
    }
    if((hasVertexARC(g, xycoord1) == FALSE  &&
       hasVertexARC(g, xycoord2) == FALSE)) {
        arcTests[2] = FALSE;
    }
    if(isLegal == TRUE) {
        if(!(arcTests[0] || arcTests[1] || arcTests[2])) {
            isLegal = FALSE;
        }
    }
    return isLegal;
}
예제 #8
0
void PopupWindowsStack::showAllUnclosedWindows()
{
	qDebug() << Q_FUNC_INFO << "{";
	QList<PopupWindow*>::iterator it = existingWindows.begin();
	quint32 i = 1;
	for (; it != existingWindows.end(); ++it)
	{
		(*it)->setNotToClose(true);
		(*it)->setGeometry(newCoords(i));
		(*it)->show();
		++i;
	}
	qDebug() << Q_FUNC_INFO << "}";
}
cv::Mat CalculateAlignedImage( cv::Mat originalImage, cv::Mat opticalFlowMap )
{
    RELEASE_ASSERT( !originalImage.empty() );
    RELEASE_ASSERT( !opticalFlowMap.empty() );
    RELEASE_ASSERT( opticalFlowMap.data != 0 );
    RELEASE_ASSERT( originalImage.size() == opticalFlowMap.size() );

    std::vector<cv::Mat> originalImageChannels;
    cv::split( originalImage, originalImageChannels );
    cv::Mat originalImageR = originalImageChannels[0];

    RELEASE_ASSERT( !originalImageR.empty() );
    RELEASE_ASSERT( originalImageR.data != 0 );
    RELEASE_ASSERT( originalImageR.channels() == 1 );

    cv::Mat alignedImage( opticalFlowMap.rows, opticalFlowMap.cols, CV_8UC1 );

    for ( int y = 0; y < opticalFlowMap.rows; y++ )
    {
        for ( int x = 0; x < opticalFlowMap.cols; x++ )
        {
            alignedImage.at< unsigned char >( y, x ) = 127;
        }
    }

    for ( int y = 0; y < opticalFlowMap.rows; y++ )
    {
        for ( int x = 0; x < opticalFlowMap.cols; x++ )
        {
            unsigned char originalColor = originalImageR.at< unsigned char >( y, x );
            cv::Vec2f     opticalFlow   = opticalFlowMap.at< cv::Vec2f >( y, x );

            cv::Vec2i newCoords( (int)floor( x + opticalFlow[ 0 ] ), (int)floor( y + opticalFlow[ 1 ] ) );

            if ( newCoords[ 1 ] >= 0 && newCoords[ 1 ] < opticalFlowMap.rows &&
                 newCoords[ 0 ] >= 0 && newCoords[ 0 ] < opticalFlowMap.cols )
            {
                alignedImage.at< unsigned char >( newCoords[ 1 ], newCoords[ 0 ] ) = originalColor;
            }
        }
    }

    return alignedImage;
}
예제 #10
0
 // ---------------------------------------------------------------------------
 // CGpxConverterAO::CalculateBoundaries
 // Calculate min and max coordinates for tracklog
 // ---------------------------------------------------------------------------
void CGpxConverterAO::CalculateBoundaries()
	{
	LOG("CGpxConverterAO::CalculateBoundaries start");
	const TInt KMaxLat = 90;
	const TInt KMinLat = -90;
	const TInt KMaxLon = 180;
	const TInt KMinLon = -180;
	if ( !iBoundaries )
		{
		iBoundaries = new TBoundaries;	
		iBoundaries->minLatitude = KMaxLat;
		iBoundaries->maxLatitude = KMinLat;
		iBoundaries->minLongitude = KMaxLon;
		iBoundaries->maxLongitude = KMinLon;
		iBoundaries->distance = 0;
		}
	
	if( !Math::IsNaN( iTempItem.iLatitude ) && !Math::IsNaN( iTempItem.iLongitude ))
		{
		TReal32 distance;
		if ( !iLastCoords ) 
			{
			iLastCoords = new TCoordinate( iTempItem.iLatitude, iTempItem.iLongitude );
			}
		else
			{
			TCoordinate tempCoord( iTempItem.iLatitude, iTempItem.iLongitude );
			TLocality newCoords( tempCoord, iTempItem.iHdop );
			TInt err = newCoords.Distance(*iLastCoords, distance);
			if ( err == KErrNone )
				{
				delete iLastCoords;
				iLastCoords = new TCoordinate( tempCoord );
				iBoundaries->distance += distance;
				}
			}		
		iBoundaries->maxLatitude = Max( iBoundaries->maxLatitude, iTempItem.iLatitude );
		iBoundaries->minLatitude = Min( iBoundaries->minLatitude, iTempItem.iLatitude );
		iBoundaries->maxLongitude = Max( iBoundaries->maxLongitude, iTempItem.iLongitude );
		iBoundaries->minLongitude = Min( iBoundaries->minLongitude, iTempItem.iLongitude );
		}
	LOG("CGpxConverterAO::CalculateBoundaries end");
	}
예제 #11
0
파일: mount.cpp 프로젝트: cardinot/kstars
void Mount::updateTelescopeCoords()
{
    double ra, dec;

    if (currentTelescope && currentTelescope->getEqCoords(&ra, &dec))
    {
        telescopeCoord.setRA(ra);
        telescopeCoord.setDec(dec);
        telescopeCoord.EquatorialToHorizontal(KStarsData::Instance()->lst(), KStarsData::Instance()->geo()->lat());

        raOUT->setText(telescopeCoord.ra().toHMSString());
        decOUT->setText(telescopeCoord.dec().toDMSString());
        azOUT->setText(telescopeCoord.az().toDMSString());
        altOUT->setText(telescopeCoord.alt().toDMSString());

        dms lst = KStarsData::Instance()->geo()->GSTtoLST( KStarsData::Instance()->clock()->utc().gst() );
        dms ha( lst.Degrees() - telescopeCoord.ra().Degrees() );
        QChar sgn('+');
        if ( ha.Hours() > 12.0 ) {
            ha.setH( 24.0 - ha.Hours() );
            sgn = '-';
        }
        haOUT->setText( QString("%1%2").arg(sgn).arg( ha.toHMSString() ) );
        lstOUT->setText(lst.toHMSString());

        double currentAlt = telescopeCoord.altRefracted().Degrees();

        if (minAltLimit->isEnabled()
             && ( currentAlt < minAltLimit->value() || currentAlt > maxAltLimit->value()))
        {
            if (currentAlt < minAltLimit->value())
            {
                // Only stop if current altitude is less than last altitude indicate worse situation
                if (currentAlt < lastAlt && (abortDispatch == -1 || (currentTelescope->isInMotion()/* && ++abortDispatch > ABORT_DISPATCH_LIMIT*/)))
                {
                    appendLogText(i18n("Telescope altitude is below minimum altitude limit of %1. Aborting motion...", QString::number(minAltLimit->value(), 'g', 3)));
                    currentTelescope->Abort();
                    //KNotification::event( QLatin1String( "OperationFailed" ));
                    KNotification::beep();
                    abortDispatch++;
                }
            }
            else
            {
                // Only stop if current altitude is higher than last altitude indicate worse situation
                if (currentAlt > lastAlt && (abortDispatch == -1 || (currentTelescope->isInMotion()/* && ++abortDispatch > ABORT_DISPATCH_LIMIT*/)))
                {
                    appendLogText(i18n("Telescope altitude is above maximum altitude limit of %1. Aborting motion...", QString::number(maxAltLimit->value(), 'g', 3)));
                    currentTelescope->Abort();
                    //KNotification::event( QLatin1String( "OperationFailed" ));
                    KNotification::beep();
                    abortDispatch++;
                }
            }
        }
        else
            abortDispatch = -1;

        lastAlt = currentAlt;

        newCoords(raOUT->text(), decOUT->text(), azOUT->text(), altOUT->text());

        newStatus(currentTelescope->getStatus());

        if (currentTelescope->isConnected())
            QTimer::singleShot(UPDATE_DELAY, this, SLOT(updateTelescopeCoords()));
    }
}
// TODO add implementation
Rect LucasKanadeTracker::getNewCoords(Mat& previous, Mat& current, Rect oldCoords) {
	Rect newCoords(oldCoords);
	return newCoords;
}