All pastes #799393 Raw Edit

Unnamed

public text v1 · immutable
#799393 ·published 2007-11-27 16:40 UTC
rendered paste body
#include <math.h>
#include "highgui.h"
#define _ANCHO_ 400
#define _ALTO_ 300
#define _PI_ 3.14159265

int main ( void )
{
	int xinicial = 180 ;
	int yinicial = 140 ;
	int radio = 100 ;
	int contador = 0 ;
	int repeticiones = 10 ;
	DWORD tinicial, tevaluacion;
	float frecuencia = 0.25 ;
	float factor_tiempo ;
	CvRect pieza ;
	pieza.height = 20 ;
	pieza.width = 40 ;
	pieza.x = xinicial ;
	pieza.y = yinicial ;
	IplImage * imagen ;
	imagen = cvCreateImage( cvSize( _ANCHO_ , _ALTO_ ) , 8 , 3 ) ;
	cvNamedWindow( "imagen" , 1 ) ;
	tinicial = GetTickCount() ;
	factor_tiempo = 2 * _PI_ * frecuencia / 1000 ;
	while ( contador < repeticiones )
	{
		cvZero( imagen ) ;
		tevaluacion = GetTickCount() ;
		if ( factor_tiempo * ( tevaluacion - tinicial) > _PI_)
		{
			cvWaitKey(200);
			tinicial = tevaluacion ;
			contador++ ;
		}
		if ( factor_tiempo * ( tevaluacion - tinicial) < _PI_ / 2)
		{
			pieza.x = xinicial - radio * sin( factor_tiempo * ( tevaluacion - tinicial ) ) ;
			pieza.y = yinicial + radio * cos( factor_tiempo * ( tevaluacion - tinicial ) ) ;
		}
		if ( factor_tiempo * ( tevaluacion - tinicial) > _PI_ / 2 && factor_tiempo * ( tevaluacion - tinicial) < _PI_ )
		{
			pieza.x = xinicial - radio * sin( factor_tiempo * ( tevaluacion - tinicial ) ) ;
			pieza.y = yinicial - radio * cos( factor_tiempo * ( tevaluacion - tinicial ) ) ;
		}

		cvRectangle( imagen ,cvPoint( pieza.x , pieza.y ) , cvPoint( pieza.x + pieza.width,pieza.y + pieza.height ) , CV_RGB( 255 , 0 , 0 ) );
		cvRectangle( imagen ,cvPoint( pieza2.x , pieza2.y ) , cvPoint( pieza2.x + pieza2.width,pieza2.y + pieza2.height ) , CV_RGB( 255 , 0 , 0 ) );
		cvShowImage( "imagen" , imagen );
		cvWaitKey( 1 );
	}
	return 0;
}