Click here to Skip to main content
15,888,401 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: adding the image in Menu Pin
Richard MacCutchan23-Sep-11 0:01
mveRichard MacCutchan23-Sep-11 0:01 
QuestionDirectory Size Pin
john563222-Sep-11 17:06
john563222-Sep-11 17:06 
QuestionRe: Directory Size Pin
David Crow22-Sep-11 17:17
David Crow22-Sep-11 17:17 
AnswerRe: Directory Size Pin
john563222-Sep-11 17:41
john563222-Sep-11 17:41 
AnswerRe: How to get size of all files in a directory Pin
Software_Developer22-Sep-11 22:26
Software_Developer22-Sep-11 22:26 
QuestionCode Signing Considerations Pin
Bram van Kampen22-Sep-11 13:39
Bram van Kampen22-Sep-11 13:39 
Questionuse of child CFrameWnd in Visual Studio 2008 [SOLVED] Pin
Jim Crafton22-Sep-11 4:22
Jim Crafton22-Sep-11 4:22 
QuestionPlease give me some idea 3D surface of revolution Pin
appollosputnik22-Sep-11 4:17
appollosputnik22-Sep-11 4:17 
Dear Friends
I have a dataset like below. 1 means Straight line with startPointX,startPointY,endPointX,endPointY.

//////////////////////////////////////////////////////////////
1 0.000000 24.600000 -15.500000 28.575000
1 -15.500000 28.575000 -37.700000 28.575000
1 -37.700000 28.575000 -37.700000 36.515000
1 -37.700000 36.515000 -59.920000 36.515000
1 -178.200000 52.000000 -138.200000 52.000000
1 0.000000 24.600000 0.000000 19.000000
1 -125.421613 36.515000 -138.200000 52.000000
1 -123.421613 36.515000 -107.873000 36.515000
1 -100.000000 19.000000 0.000000 19.000000
1 -105.873000 36.515000 -94.557821 36.515000
1 -66.103821 36.515000 -88.374000 36.515000
1 -100.000000 19.000000 0.000000 19.000000
1 0.000000 19.000000 0.000000 24.600000
1 0.000000 24.600000 -15.500000 28.575000
1 -15.500000 28.575000 -37.700000 28.575000
1 -37.700000 28.575000 -37.700000 36.515000
1 -37.700000 36.515000 -59.920000 36.515000
1 -66.103821 36.515000 -88.374000 36.515000
1 -94.557821 36.515000 -105.873000 36.515000
1 -107.873000 36.515000 -123.421613 36.515000
1 -125.421613 36.515000 -138.200000 52.000000
1 -138.200000 52.000000 -178.200000 52.000000
1 -115.000000 0.000000 -115.000000 15.000000
1 -115.000000 15.000000 -100.000000 15.000000
1 -100.000000 15.000000 -100.000000 19.000000
1 -100.000000 19.000000 0.200000 19.000000
1 0.200000 19.000000 0.000000 19.000000
1 0.000000 19.000000 0.000000 24.574923
1 0.000000 24.574923 -0.000000 24.600000
1 0.000000 24.600000 -15.500000 28.575000
1 -15.500000 28.575000 -37.700000 28.575000
1 -37.700000 28.575000 -37.700000 36.515000
1 -37.700000 36.515000 -59.920000 36.515000
1 -59.920000 36.515000 -66.103821 36.515000
1 -66.103821 36.515000 -88.374000 36.515000
1 -88.374000 36.515000 -94.557821 36.515000
1 -94.557821 36.515000 -105.873000 36.515000
1 -105.873000 36.515000 -107.873000 36.515000
1 -107.873000 36.515000 -123.421613 36.515000
1 -123.421613 36.515000 -125.421613 36.515000
1 -125.421613 36.515000 -138.200000 52.000000
1 -138.200000 52.000000 -178.200000 52.000000
1 -178.200000 52.000000 -178.200000 52.500000
1 -178.200000 52.500000 -178.200000 55.000000
1 -178.200000 55.000000 -190.000000 55.000000
1 5.000000 0.000000 5.000000 55.000000
1 5.000000 55.000000 -190.000000 55.000000
//////////////////////////////////////////////////////////////

I have to construct a profile which I can easily do by making a GL_LINES.

After that I need rotate the profile by x-axis and construct a surface of revolution. Please giveme some idea how can I achieve this. I have done something but I am not getting the surface.


Like I am storing the original startPoints and endPoints in an array with assuming z=0.
Then rotating each point by x-axis. so x-values will be same and y and z values I am calculating using this formula.
y = y cosq - z sinq;
z = ysinq + zcosq;

Is this correct...?? Then I am defining a number of loops and in loop I am creating GL_QUADS for each startPoint and endPoint...
1st loop 1ststartPoint, 1stLoop 1stendPoint
2nd loop 1stStartPoint, 2nd loop 1stEndPoint...


But I am not getting any 3D surface. Please help me.........Check the code below.


//////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct point3D{
float x;
float y;
float z;
}POINT3D;

int count1;
POINT3D *startPoints, *endPoints;

void CRevolutionProjView::drawProfile(CString filename)
{
pFrame->m_wndStatusBar.SetPaneText(0,L"DrawProfile !!");

// profile to be drawn

GLfloat PI = 4 * atan(1.0);

//file needs be open
double startPX, startPY, endPX, endPY;
double cenX, cenY, cenZ, rad, startA, endA;
ifstream indata; // indata is like cin
int id; // variable for input value
indata.open(filename); // opens the file
if(!indata) { // file couldn't be opened
cerr << "Error: file could not be opened" << endl;
exit(1);
}
count1=0;
while ( !indata.eof() ) { // keep reading until end-of-file
indata >> id;
cout << "The id is " << id << endl;
if(id==1)
{
indata >> startPX >> startPY >> endPX >> endPY;
glBegin(GL_LINES);
glVertex2f(startPX, startPY); // origin of the line
glVertex2f(endPX, endPY); // ending point of the line
glEnd();

if(count1==0)
{
startPoints = (POINT3D *)malloc(sizeof(POINT3D));
endPoints = (POINT3D *)malloc(sizeof(POINT3D));
}
else
{
startPoints = (POINT3D *)realloc(startPoints,sizeof(POINT3D)*(count1+1));
endPoints = (POINT3D *)realloc(endPoints,sizeof(POINT3D) * (count1+1));

}
startPoints[count1].x = startPX;
startPoints[count1].y = startPY;
startPoints[count1].z = 0.0f;
endPoints[count1].x = endPX;
endPoints[count1].y = endPY;
endPoints[count1].z = 0.0f;
count1++;
}
}
indata.close();
cout << "End-of-file reached.." << endl;

}

void CRevolutionProjView::drawSurface()
{

double PI = 4.0 * atan(1.0);

//I have x and y points;

//count1 = numberof points

//theta = 0 to 360 degs.

//nsweep = number of sweeps. 360/nsweep = each angle;
int nsweep=4;

//no of profiles = nsweep + 1...

//each profile will have count1 no of lines...so count1 startpoints and count1 endPoints...

//so...total startPoints and endPoints for (nsweep+1) profiles = (nsweep+1) * count1...

POINT3D *totalStartPoints, *totalEndPoints;
totalStartPoints = new POINT3D[(nsweep+1)*count1];
totalEndPoints = new POINT3D[(nsweep+1)*count1];
int cnt1=0;
double theta, inter;
inter = (360/nsweep) * (PI/180);
theta = 0;
for(int i=0; i<(nsweep+1); i++)
{
for(int j=0; j
AnswerRe: Please give me some idea 3D surface of revolution Pin
Stefan_Lang22-Sep-11 22:39
Stefan_Lang22-Sep-11 22:39 
QuestionHow to free the memory if memory is allocation using memset Pin
hema_soft21-Sep-11 23:05
hema_soft21-Sep-11 23:05 
AnswerRe: How to free the memory if memory is allocation using memset PinPopular
Niklas L21-Sep-11 23:12
Niklas L21-Sep-11 23:12 
AnswerRe: How to free the memory if memory is allocation using memset Pin
CPallini21-Sep-11 23:49
mveCPallini21-Sep-11 23:49 
AnswerRe: You can use the function - free() after first calling malloc() Pin
Software_Developer21-Sep-11 23:54
Software_Developer21-Sep-11 23:54 
AnswerRe: How to free the memory if memory is allocation using memset Pin
Erudite_Eric22-Sep-11 2:58
Erudite_Eric22-Sep-11 2:58 
Questionc++ objects, I don't get it - IIS ADSI object Pin
jkirkerx21-Sep-11 18:57
professionaljkirkerx21-Sep-11 18:57 
AnswerRe: c++ objects, I don't get it - IIS ADSI object Pin
XTAL25621-Sep-11 21:04
XTAL25621-Sep-11 21:04 
AnswerRe: c++ objects, I don't get it - IIS ADSI object Pin
Jim Crafton22-Sep-11 4:27
Jim Crafton22-Sep-11 4:27 
GeneralRe: c++ objects, I don't get it - IIS ADSI object Pin
jkirkerx22-Sep-11 6:17
professionaljkirkerx22-Sep-11 6:17 
GeneralRe: c++ objects, I don't get it - IIS ADSI object Pin
Jim Crafton22-Sep-11 6:24
Jim Crafton22-Sep-11 6:24 
GeneralRe: c++ objects, I don't get it - IIS ADSI object Pin
jkirkerx22-Sep-11 6:52
professionaljkirkerx22-Sep-11 6:52 
Questionlanguage problem in C .. Pin
gateway2321-Sep-11 0:52
gateway2321-Sep-11 0:52 
AnswerRe: language problem in C .. Pin
Stefan_Lang21-Sep-11 1:39
Stefan_Lang21-Sep-11 1:39 
AnswerRe: IsTextUnicode function Pin
Software_Developer21-Sep-11 7:31
Software_Developer21-Sep-11 7:31 
QuestionCombob box get hide at mouse release Pin
Amrit Agr21-Sep-11 0:15
Amrit Agr21-Sep-11 0:15 
AnswerRe: Combob box get hide at mouse release Pin
Code-o-mat21-Sep-11 9:04
Code-o-mat21-Sep-11 9:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.