Problem Set #1
Problem Set #1
Hi, Problem Set #1 is posted on the course website at:
http://www.mat.ucsb.edu/594cm/ProblemSet1.html
Please post a reply that includes the image you be emulating (for problem 3) and a brief description of how you plan to visualize it by Thursday's class.
-Angus
http://www.mat.ucsb.edu/594cm/ProblemSet1.html
Please post a reply that includes the image you be emulating (for problem 3) and a brief description of how you plan to visualize it by Thursday's class.
-Angus
Re: Problem Set #1
Does anyone have the final pixel locations for the point given vertex point? I got an answer, but its off the screen. I haven't checked it with code yet, but it would be really nice to see what other people are getting for final pixel coordinates. I got x = 8 px, y = -23 px...
let me know.
let me know.
Re: Problem Set #1
Hi, I thought I'd give you a way to double check the first problem.
The X pixel of the projected point (in pixels) should be 241.
The X position of the unprojected point (in world coordinates) should be -.762.
To double check your results (of the first problem), you can use the following openGL commands:
//PROJ
gluPerspective(60f, (float)width/(float)height, 1f, 100f);
//MV
glTranslatef(0f, 0f, -10f);
glRotatef(-45f, 0f, 1f, 0f);
glTranslatef(.5f, 1f, -2f);
//
and then draw a point.
-Angus
The X pixel of the projected point (in pixels) should be 241.
The X position of the unprojected point (in world coordinates) should be -.762.
To double check your results (of the first problem), you can use the following openGL commands:
//PROJ
gluPerspective(60f, (float)width/(float)height, 1f, 100f);
//MV
glTranslatef(0f, 0f, -10f);
glRotatef(-45f, 0f, 1f, 0f);
glTranslatef(.5f, 1f, -2f);
//
and then draw a point.
-Angus
Last edited by angus on Tue Apr 13, 2010 10:40 am, edited 1 time in total.
-
- Posts: 2
- Joined: Thu Apr 08, 2010 10:30 am
Re: Problem Set #1
hmm.....
I have a question regarding the glTranslatef(.5f, 1f, -2f);
Is this an important transformation or is would a a glVertex3f(.5f, 1f, -2f) not do the same thing??
Also when converting from NCR to Screen coords, whats the conversion?
Is it simply x_ndc*width/2 (and same for y)
or (x_ndc + 1)*width/2 (which would simply centre the (0,0) coords. so I guess the difference would just be whatever -200, -150.
this doesn't help me though.
depending on my first question I either get:
X = 41 or X = 75
depending on my second question this could then be 200 more...
Checking this in OpenGL using what angus posted gives me a point right in the top corner so maybe I have more issues than I thought!!
I have a question regarding the glTranslatef(.5f, 1f, -2f);
Is this an important transformation or is would a a glVertex3f(.5f, 1f, -2f) not do the same thing??
Also when converting from NCR to Screen coords, whats the conversion?
Is it simply x_ndc*width/2 (and same for y)
or (x_ndc + 1)*width/2 (which would simply centre the (0,0) coords. so I guess the difference would just be whatever -200, -150.
this doesn't help me though.
depending on my first question I either get:
X = 41 or X = 75
depending on my second question this could then be 200 more...
Checking this in OpenGL using what angus posted gives me a point right in the top corner so maybe I have more issues than I thought!!
-
- Posts: 1
- Joined: Tue Apr 06, 2010 9:13 am
Re: Problem Set #1
Hi all,
I ended up doing the first problem on mathematica and I got:
xpix = 247.848
ypix = 177.784
so that is the closest i have gotten to the answer. And I have attached the code that I used to get my answer.
Also I pretty much followed the end from this http://www.songho.ca/opengl/gl_transform.html
I ended up doing the first problem on mathematica and I got:
xpix = 247.848
ypix = 177.784
so that is the closest i have gotten to the answer. And I have attached the code that I used to get my answer.
Also I pretty much followed the end from this http://www.songho.ca/opengl/gl_transform.html
- Attachments
-
- problem1.pdf
- (106.94 KiB) Downloaded 446 times
Re: Problem Set #1
Hi Ben, you can find actual openGL source code online if you want to track down exactly what's going on behind the scenes.
glTranlslatef(x, y, z); glVertex3f(0, 0, 0) should be the same as glVertex(x, y , z);
-Angus
glTranlslatef(x, y, z); glVertex3f(0, 0, 0) should be the same as glVertex(x, y , z);
-Angus
Re: Problem Set #1
i believe: it's (x_ndc + 1)*width/2 .benalunjones wrote:hmm.....
Is it simply x_ndc*width/2 (and same for y)
or (x_ndc + 1)*width/2 (which would simply centre the (0,0) coords. so I guess the difference would just be whatever -200, -150.
source for my belief: http://www.opengl.org/sdk/docs/man/xhtml/glViewport.xml
Re: Problem Set #1
is anybody else getting this? Using the transformation matrices described here: http://www.songho.ca/opengl/gl_transform.html the following are the results i get:angus wrote:Hi, I thought I'd give you a way to double check the first problem.
The X pixel of the projected point (in pixels) should be 241.
The X position of the unprojected point (in world coordinates) should be -.762.
Eye_Point =
-1.0607 1.0000 -11.7678 1.0000
Clip_Point =
-1.3778 1.7321 9.9853 11.7678
NDC_Point =
-0.1171 0.1472 0.8485
Window_Point =
176.5828 172.0779 57.7857
Something's awfully wrong!
Re: Problem Set #1
Hi, it sounds like some of you are having issues with Problem #1.
Here is my Projection matrix after setting gluPerspective with a fovy of 60, and aspectRation of 400/300=1.333 and a near of 1 and a far of 100:
+1.299038 +0.000000 +0.000000 +0.000000
+0.000000 +1.732051 +0.000000 +0.000000
+0.000000 +0.000000 -1.020202 -2.020202
+0.000000 +0.000000 -1.000000 +0.000000
And here is the modelview after translating by -10 then rotating by -45f around the Y axis:
+0.707107 +0.000000 -0.707107 +0.000000
+0.000000 +1.000000 +0.000000 +0.000000
+0.707107 +0.000000 +0.707107 -10.000000
+0.000000 +0.000000 +0.000000 +1.000000
When I call gluProject I get: x=241.5236805518332
If you look at the gluProject source code you will find that it simply follows the path of the vertex pipeline as shown in the slides or in the redbook and you can print out the various steps to check with your calculations.
HTH, Angus
Here is my Projection matrix after setting gluPerspective with a fovy of 60, and aspectRation of 400/300=1.333 and a near of 1 and a far of 100:
+1.299038 +0.000000 +0.000000 +0.000000
+0.000000 +1.732051 +0.000000 +0.000000
+0.000000 +0.000000 -1.020202 -2.020202
+0.000000 +0.000000 -1.000000 +0.000000
And here is the modelview after translating by -10 then rotating by -45f around the Y axis:
+0.707107 +0.000000 -0.707107 +0.000000
+0.000000 +1.000000 +0.000000 +0.000000
+0.707107 +0.000000 +0.707107 -10.000000
+0.000000 +0.000000 +0.000000 +1.000000
When I call gluProject I get: x=241.5236805518332
If you look at the gluProject source code you will find that it simply follows the path of the vertex pipeline as shown in the slides or in the redbook and you can print out the various steps to check with your calculations.
HTH, Angus
Re: Problem Set #1
Hmmm... Problem solved. It was an error in the Model View matrix. I was calculating with angle = 45! Anyway previously I was getting it as:
0.7071 0 +0.7071 0
0 1.0000 0 0
-0.7071 0 0.7071 -10.0000
0 0 0 1 .0000
so this changed everything! Now I get the same results... Anyway thanks for the quick reply.
0.7071 0 +0.7071 0
0 1.0000 0 0
-0.7071 0 0.7071 -10.0000
0 0 0 1 .0000
so this changed everything! Now I get the same results... Anyway thanks for the quick reply.