Esempio n. 1
0
//debug code
int main(void){
	PLL_Init(Bus80MHz);	// bus clock at 50 MHz
  Output_Init();
	SYSCTL_RCGCGPIO_R |= 0x20;       // activate port F
	//ADC0_InitTimer0ATriggerSeq3(2, F30HZ); // ADC channel 0, 1000 Hz sampling
	ADC0_InitTimer0ATriggerSeq3PD3(F30HZ);
  //ADC0_InitSWTriggerSeq3_Ch9();
	while((SYSCTL_PRGPIO_R&0x0020) == 0){};// ready?
  GPIO_PORTF_DIR_R |= 0x02;        // make PF1 output (PF1 built-in LEDs)
  GPIO_PORTF_AFSEL_R &= ~0x02;     // disable alt funct on PF1
  GPIO_PORTF_DEN_R |= 0x02;        // enable digital I/O on PF1
                                   // configure PF1 as GPIO
  GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF0FF)+0x00000000;
  GPIO_PORTF_AMSEL_R = 0;          // disable analog functionality on PF
  EnableInterrupts();

	plotInit();
		
	while(1){
		GPIO_PORTF_DATA_R ^= 0x02;           // toggle LED
		//ADCvalue = ADC0_InSeq3();
		temperature = adcToTemp(ADCvalue + offset);
		plotPoint();
		ST7735_SetCursor(1,2);
		ST7735_sDecOut2(temperature);
		ST7735_SetCursor(2,1);
		ST7735_OutUDec(ADCvalue + offset);
	}
}
void SocSystem_Analytical::displayState(const arr& q,const arr *invQ,const char *text){
  cout <<"gnuplot state display " <<text <<endl;
  plotGnuplot();
  plotClear();
  plotPoints(obstacles);
  plotPoint(q);
  arr C;
    inverse_SymPosDef(C,(*invQ));
    plotCovariance(q,C);
  plot();
}
Esempio n. 3
0
void bezier(wcPt3D * ctrlPts, GLint nCtrlPts,GLint nBezCurvePts)
{
    wcPt3D bezCurvePt;

    GLfloat u;

    GLint* C, k;

    C = new GLint[nCtrlPts];

    binomialCoeffs(nCtrlPts-1,C);

    for( k = 0; k <= nBezCurvePts; k++)
    {
        u = GLfloat(k) / GLfloat(nBezCurvePts);

        computeBezPt(u,&bezCurvePt,nCtrlPts,ctrlPts,C);

        plotPoint(bezCurvePt);
    }

    delete [] C;
}
Esempio n. 4
0
//Draws the 3D scene
void drawScene() {
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
	glLoadIdentity(); //Reset the drawing perspective
	
	Coord tail1 = rotateAlongXYZ(_tail1, _current_angle);
	Coord tail2 = rotateAlongXYZ(_tail2, _current_angle);
	Coord tail3 = rotateAlongXYZ(_tail3, _current_angle);
	Coord tail4 = rotateAlongXYZ(_tail4, _current_angle);
	Coord tail5 = rotateAlongXYZ(_tail5, _current_angle);
	Coord tail6 = rotateAlongXYZ(_tail6, _current_angle);
	Coord tail7 = rotateAlongXYZ(_tail7, _current_angle);
	Coord tail8 = rotateAlongXYZ(_tail8, _current_angle);
	Coord offset = _offset;

			
   	glBegin(GL_QUADS); // Bottom face
    
	glColor4f(0,0,1,1);
	plotPoint(tail1, offset);
	plotPoint(tail2, offset);  
	plotPoint(tail3, offset);
	plotPoint(tail4, offset);
	
	glColor4f(0,1,0,1);
	plotPoint(tail5, offset);
	plotPoint(tail6, offset);  
	plotPoint(tail7, offset);
	plotPoint(tail8, offset);  
	
	glColor4f(0,1,1,1);
	plotPoint(tail1, offset);
	plotPoint(tail2, offset);  
	plotPoint(tail5, offset);
	plotPoint(tail6, offset);  
    
	glColor4f(1,0,0,1);
	plotPoint(tail1, offset);
	plotPoint(tail4, offset);  
	plotPoint(tail5, offset);
	plotPoint(tail8, offset);  
	
	glColor4f(1,0,1,1);
	plotPoint(tail2, offset);
	plotPoint(tail3, offset);  
	plotPoint(tail6, offset);
	plotPoint(tail7, offset); 
	
	glColor4f(1,1,0,1);
	plotPoint(tail3, offset);
	plotPoint(tail4, offset);  
	plotPoint(tail7, offset);
	plotPoint(tail8, offset);  
	
	glEnd(); 
	
	glutSwapBuffers();
}
void mouseLnPlot(GLint xMouse, GLint yMouse){
	plotPoint(xMouse,  winHeight - yMouse);
	glFlush();
}
void mousePtPlot(GLint button, GLint action, GLint xMouse, GLint yMouse){
	EDGE *ptr;
	int j=0;
	PLG *PLGptr;

	if(flag == 9) return;

	//按下左鍵
	if(button == GLUT_LEFT_BUTTON && action == GLUT_DOWN){
		//第二個點
		if(flag == 1){
			//存入邊
			listhead = listLink(listhead, &current, previousX, previousY, xMouse, winHeight - yMouse, 1);
			counti++;
			//畫出外框
			
			glColor3f(0.0,  1.0,  0.0);
			glBegin(GL_LINES);
				glVertex2i(previousX,  previousY);
				glVertex2i(xMouse,	winHeight - yMouse);
			glEnd();
		}
		//第一個點
		if(flag == 0){
			//紀錄起始點
			startX = xMouse;
			startY = winHeight - yMouse;
			flag = 1;
		}
		//紀錄上一個點

		else if(flag == 4){

			printf("triangle start\n");
			PLGptr = polygonlist;
			
			for(j=1;;j++){
				triangulation(PLGptr->list, trianglehead);
				PLGptr = PLGptr->next;
				if(PLGptr == NULL)	break;
			}
			PrintTRG(trianglehead);
			glFlush();

			printf("triangle finish\n");
			flag = 5;

		}
		else if(flag == 5){
			printf("drawing start\n");
			fillcollor(trianglehead);
			printf("drawing finish\n");
			flag = 9;
		}
		if(flag != 5 || flag != 9){
			previousX = xMouse;
			previousY = winHeight - yMouse;
			plotPoint(xMouse,  winHeight - yMouse);
		}
		if(flag == 3)	flag = 4;
	}
	//按下右鍵
	if(button == GLUT_RIGHT_BUTTON && action == GLUT_DOWN && doneflag == 0){
		//把最後一個點和起始點連接
		listhead = listLink(listhead, &current, previousX, previousY,startX, startY, 1);
		polygonlist = polygon_link(polygonlist, listhead, &PLGcurrent);
			glColor3f(0.0,  1.0,  0.0);
			glBegin(GL_LINES);
				glVertex2i(previousX,  previousY);
				glVertex2i(startX,	startY);
			glEnd();		
		flag = 4;
		//畫出外框
		glFlush();
		printf("draw contour finish\n");
		doneflag = 1;
	}
	glFlush();
}