// reset vector from rectangular coordinates if form is // RECT (the default) or else from polar coordinates if // form is POL void Vector:: reset(double n1, double n2, Mode form) { mode = form; if (form == RECT) { x = n1; y = n2; set_mag(); set_ang(); } else if (form == POL) { mag = n1; ang = n2 / Rad_to_deg; set_x(); set_y(); } else { cout << "Incorrect 3rd argument to Vector() -- "; cout << "vector set to 0\n"; x = y = mag = ang = 0.0; mode = RECT; } }
void Vector::set(double n1, double n2, char form) { mode = form; if ( form == 'r') { x = n1; y = n2; set_mag(); set_ang(); } else if (form = 'p') { mag = n1; ang = n2 / Rad_to_deg; set_x(); set_y(); } else { cout << "Incorrect form\n"; cout << "vector set to 0\n"; x = y = mag = ang = 0.0; mode = 'r'; } }
void Vector::reset(double n1, double n2, Mode form = RECT) { mode = form; if (form == RECT) { x = n1; y = n2; set_mag(); set_ang(); } else if (form == POL) { mag = n1; ang = n2 / Rad_to_deg; set_x(); set_y(); } else { cout << "Niepoprawny trzci argument set() -- zeruję wektor" << endl; x = y = mag = ang = 0.0; mode = RECT; } }
Vector::Vector(double n1, double n2, Mode form = RECT) { mode = form; if (form == RECT) { x = n1; y = n2; set_mag(); set_ang(); } else if (form == POL) { mag = n1; ang = n2 / Rad_to_deg; set_x(); set_y(); } else { cout << "Niepoprawna wartość trzeciego argumentu Vector() -- zeruję wektor" << endl; x = y = mag = ang = 0.0; mode = RECT; } }
void CPyramidModel::Init ( trVertex3D rPos, trVertex3D rScale, float fRot) { if (iGLListID != -1) glDeleteLists(iGLListID,1); iGLListID = glGenLists(1); float fTexureUnits = 4.0f; glNewList(iGLListID,GL_COMPILE); glPushMatrix(); glTranslatef(rPos.x, rPos.y, rPos.z); glRotatef(fRot, 0, 0, 1); glBegin(GL_QUADS); // lets hope they make them quads into strips // z+ side glNormal3f(0,0,-1); glTexCoord2f(0,0); glVertex3f(-rScale.x,-rScale.y,0); glTexCoord2f(0,rScale.y/fTexureUnits*2); glVertex3f(-rScale.x,rScale.y,0); glTexCoord2f(rScale.x/fTexureUnits*2,rScale.y/fTexureUnits*2); glVertex3f(rScale.x,rScale.y,0); glTexCoord2f(rScale.x/fTexureUnits*2,0); glVertex3f(rScale.x,-rScale.y,0); glEnd(); trVertex3D rVec1,rVec2,rNorm; glBegin(GL_TRIANGLES); // y+ Side // compute a normal rVec1.x = rScale.x; rVec1.y = -rScale.y; rVec1.z = rScale.z; rVec2.x = rScale.x*2; rVec2.y = 0; rVec2.z = 0; cross(rVec1,rVec2,rNorm); set_mag(rNorm,1.0f); glNormal3f(rNorm.x,rNorm.y,rNorm.z); glTexCoord2f(0,0); glVertex3f(-rScale.x,rScale.y,0); glTexCoord2f(rScale.x/fTexureUnits,rScale.z/fTexureUnits); glVertex3f(0,0,rScale.z); glTexCoord2f(rScale.x/fTexureUnits*2,0); glVertex3f(rScale.x,rScale.y,0); // x+ Side // compute a normal rVec1.x = rScale.x; rVec1.y = -rScale.y; rVec1.z = rScale.z; rVec2.x = 0; rVec2.y = -rScale.y*2; rVec2.z = 0; cross(rVec2,rVec1,rNorm); set_mag(rNorm,1.0f); glNormal3f(rNorm.x,rNorm.y,rNorm.z); glTexCoord2f(0,0); glVertex3f(rScale.x,rScale.y,0); glTexCoord2f(rScale.x/fTexureUnits,rScale.z/fTexureUnits); glVertex3f(0,0,rScale.z); glTexCoord2f(rScale.x/fTexureUnits*2,0); glVertex3f(rScale.x,-rScale.y,0); // y- Side // compute a normal rVec1.x = -rScale.x; rVec1.y = rScale.y; rVec1.z = rScale.z; rVec2.x = -rScale.x*2; rVec2.y = 0; rVec2.z = 0; cross(rVec1,rVec2,rNorm); set_mag(rNorm,1.0f); glNormal3f(rNorm.x,rNorm.y,rNorm.z); glTexCoord2f(0,0); glVertex3f(rScale.x,-rScale.y,0); glTexCoord2f(rScale.x/fTexureUnits,rScale.z/fTexureUnits); glVertex3f(0,0,rScale.z); glTexCoord2f(rScale.x/fTexureUnits*2,0); glVertex3f(-rScale.x,-rScale.y,0); // x- Side // compute a normal rVec1.x = -rScale.x; rVec1.y = rScale.y; rVec1.z = rScale.z; rVec2.x = 0; rVec2.y = rScale.y*2; rVec2.z = 0; cross(rVec2,rVec1,rNorm); set_mag(rNorm,1.0f); glNormal3f(rNorm.x,rNorm.y,rNorm.z); glTexCoord2f(0,0); glVertex3f(-rScale.x,-rScale.y,0); glTexCoord2f(rScale.x/fTexureUnits,rScale.z/fTexureUnits); glVertex3f(0,0,rScale.z); glTexCoord2f(rScale.x/fTexureUnits*2,0); glVertex3f(-rScale.x,rScale.y,0); glEnd(); glPopMatrix(); glEndList(); if (iSelList != -1) glDeleteLists(iSelList,1); iSelList = glGenLists(1); glNewList(iSelList,GL_COMPILE); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glPushMatrix(); glTranslatef(rPos.x, rPos.y, rPos.z); glRotatef(fRot, 0, 0, 1); float fOffset = 2.5f; float fLen = 5.0f; glBegin(GL_LINES); DrawSelectGrid(fOffset,fLen,rScale); glEnd(); glPopMatrix(); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glEndList(); }