void Task2::DrawHyperbola(){ viewer->clear(); CreateAxis(); float u= minu; //Create a hyperbola for(int i=0; i < NumSamples; i++){ u = u + (maxu-minu)/NumSamples; //Relative to the axis X float pointX = (a * cosh(u)); float pointX2 = -(a * cosh(u)); float pointY =(b * sinh(u)); double rad = 45*3.1415926/180; float newX = pointX * cos(rad) - pointY * sin(rad) +scatterOrigin[0]; float newX2 = pointX2 * cos(rad) - pointY * sin(rad)+scatterOrigin[0]; float newY = pointY * cos(rad) + pointX * sin(rad)+scatterOrigin[1]; float newY2 = pointY * cos(rad) + pointX2 * sin(rad)+scatterOrigin[1]; const Vector2f A = makeVector2f(newX,newY); const Vector2f B= makeVector2f(newX2,newY2); CreateParaline(newX,newY); CreateParaline(newX2,newY2); //Drawing the points on the screen viewer->addPoint(A); viewer->addPoint(B); } // display changes viewer->refresh(); }
void Task2::NegativeSlope() { viewer->clear(); CreateAxis(); float pointX= scatterOrigin[0]; float pointY= Yorigo; Vector4f color=makeVector4f(1,0,0,1); int size= 5; float pace=(endAxisX[0]-scatterOrigin[0])/NumSamples; for(int i=0; i<=NumSamples; i++){ Vector2f scatterPoint= makeVector2f(pointX,pointY); viewer->addPoint(scatterPoint); CreateParaline(pointX, pointY); pointX+= pace; pointY= slope*(pointX-scatterOrigin[0])+Yorigo; } // display changes viewer->refresh(); }
void Task2::DrawCircle(){ viewer->clear(); CreateAxis(); //Traslating the point of center to the right coordinate float xCenter = Center[0]+scatterOrigin[0]; float yCenter = Center[1]+scatterOrigin[1]; //Create a circle by iterating over 360 degrees. for(int i=1; i < NumSamples; i++){ float pointX = xCenter + Radius * cos(2 * 3.14159265 * float(i)/float(NumSamples-1)); float pointY = yCenter + Radius * sin(2 * 3.14159265 * float(i)/float(NumSamples-1)); //radiens not degrees const Vector2f A = makeVector2f(pointX,pointY); CreateParaline(pointX,pointY); viewer->addPoint(A); } // display changes viewer->refresh(); }
void CCrossBoardIniFile::FileImport(LPCTSTR lpFilename) { m_HoleNum=::GetPrivateProfileInt("钻孔","个数",0,lpFilename); if(m_HoleNum<=0)return; CreateChartFrame(); CreateChartHeader(lpFilename); CreateChartFooter(lpFilename); double spaceX = 90; double spaceY = 110; m_nPaperCount = m_HoleNum / 8 + 1; //short nPapers = m_HoleNum / 8 + 1; short curHoleID = 0; for (int i=0;i<m_nPaperCount;i++) { short nHoles; if (m_nPaperCount-i-1 > 0)nHoles = 8; else nHoles = m_HoleNum - i * 8; //short nRows = m_HoleNum - CADLayer* pLayer; pLayer=new CADLayer(); m_pGraphics->m_pLayerGroup->AddLayer(pLayer); char layerNum[4]; itoa(i+1,layerNum,10); strcpy(pLayer->m_Name,layerNum); strcpy(pLayer->m_LTypeName,"CONTINUOUS"); if (i == 0) pLayer->m_nColor=7; else pLayer->m_nColor=-7; CADGraphics::CreateHandle(pLayer->m_Handle); int curLayerIndex = m_pLayerGroup->indexOf(layerNum);; for (int j=0;j<nHoles;j++) { curHoleID++; if (j>3) { CreateComment(m_FrameLeft+30+spaceX*(j-4),m_FrameTop-110-spaceY,curLayerIndex,curHoleID,lpFilename); CreateAxis(m_FrameLeft+30+spaceX*(j-4),m_FrameTop-110-spaceY,curLayerIndex); } else { CreateComment(m_FrameLeft+30+spaceX*j,m_FrameTop-110,curLayerIndex,curHoleID,lpFilename); CreateAxis(m_FrameLeft+30+spaceX*j,m_FrameTop-110,curLayerIndex); } } } }