void Turtle::moveTo(PV2D* p, bool draw){ PV2D old = PV2D(*pos); pos->x = p->x; pos->y = p->y; if (draw){ //Draw line from 'old' to 'p' } }
void Circulo::crearLados(){ GLdouble cx = centro.x; GLdouble cy = centro.y; for(int i = 0; i < 20; i++) { GLdouble theta = 2.0f * 3.1415926f * GLdouble(i) / GLdouble(20);//get the current angle GLdouble x = radio * cos(theta);//calculate the x component GLdouble y = radio * sin(theta);//calculate the y component lados[i] = PV2D(x + cx,y + cy); } }
PV2D PV2D::operator+(const PV2D &p){ return PV2D(x+p.x,y+p.y); }
PV2D PV2D::normalizar(){ return PV2D((1/(sqrt(pow(x,2)+pow(y,2))))*x,(1/(sqrt(pow(x,2)+pow(y,2))))*y); }
PV2D PV2D::normalDr(){ return PV2D(y,-x); }
PV2D PV2D::normalIz(){ return PV2D(-y,x); }
PV2D PV2D::operator*(const GLdouble &a){ return PV2D(x*a,y*a); }
PV2D PV2D::operator/(const int &a){ return PV2D(x/a,y/a); }
PV2D PV2D::operator-(const PV2D &p){ return PV2D(x-p.x,y-p.y); }
//--------------------------------------------------------------------------- void __fastcall TGLForm2D::FormCreate(TObject *Sender) { hdc = GetDC(Handle); SetPixelFormatDescriptor(); hrc = wglCreateContext(hdc); if(hrc == NULL) ShowMessage(":-)~ hrc == NULL"); if(wglMakeCurrent(hdc, hrc) == false) ShowMessage("Could not MakeCurrent"); //Cor de fondo de la ventana glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //inicialización del volumen de vista xRight=400.0; xLeft=-xRight; yTop=250; yBot=-yTop; //Radio del volumen de vista == 1 //inicialización del puerto de vista //ClientWidth=400; //ClientHeight=400; RatioViewPort=1.0; // inicialización de las variables del programa tR = new Triangle(PV2D(xRight-30, yTop+20), PV2D(xRight-30, yBot-20), PV2D(xRight+300, yBot-20)); tT = new Triangle(PV2D(xLeft-20, yTop-30), PV2D(xRight+20, yTop-30), PV2D(xRight+20, yTop+450)); tL = new Triangle(PV2D(xLeft+30, yBot-20), PV2D(xLeft+30, yTop+20), PV2D(xLeft-300, yTop+20)); tB = new Triangle(PV2D(xRight+20, yBot+30), PV2D(xLeft-20, yBot+30), PV2D(xLeft-20, yBot-450)); t1 = new Triangle(PV2D(200, 0), PV2D(200, 200), PV2D(160, 160)); t2 = new Triangle(PV2D(-250, 0), PV2D(-250, -150), PV2D(-210, -210)); c1 = new Circle(PV2D(-200, 80), 30); c2 = new Circle(PV2D(250, -90), 30); obstacles.push_back(tR); obstacles.push_back(tT); obstacles.push_back(tL); obstacles.push_back(tB); obstacles.push_back(t1); obstacles.push_back(t2); obstacles.push_back(c1); obstacles.push_back(c2); //Set timer properties Timer->Enabled = false; Timer->Interval = 1; }
PV2D Turtle::getPosition(){ return PV2D(*pos);//CHECK It must return a clone }
PV2D PV2D::operator-(const PV2D &o) { return PV2D(this->x - o.x, this->y - o.y); }