Some Modest Advice for Graduate Students

Some Modest Advice for Graduate Students

by Stephen C. Stearns

Always Prepare for the Worst.
Some of the greatest catastrophes in graduate education could have been avoided by a little intelligent foresight. Be cynical. Assume that your proposed research might not work, and that one of your faculty advisers might become unsupportive or even hostile. Plan for alternatives.


Nobody cares about you.
In fact, some professors care about you and some don't. Most probably do, but all are busy, which means in practice they cannot care about you because they don't have the time. You are on your own, and you had better get used to it. This have a lot of implications. Here are two important ones:

1. You had better decide early on that you are in charge of your program. The degree you get is yours to create. Your major professor can advise you and protect you to a certain extent from bureaucratic and financial demons, but he should not tell you what to do. That is up to you. If you need advice, ask for it: that's his job.

2. If you want to pick somebody's brains, you'll have to go to him or her, because they won't be comming to you.


To Be Continued

by 꽁치 | 2007/04/13 20:27 | 트랙백

Parametric Equation of a Sphere and Texture Mapping

Parametric Equation of a Sphere

and Texture Mapping

See also Creating spherical texture from 6 views

Written by Paul Bourke
August 1996


One possible parameterisation of the sphere will be discussed along with the transformation required to texture map a sphere. An angle parameterisation of the sphere is

    x = r sin(theta) cos(phi)
    y = r sin(theta) sin(phi)
    z = r cos(theta)

where r is the radius, theta the angle from the z axis (0 <= theta <= pi), and phi the angle from the x axis (0 <= phi <= 2pi). Textures are conventionally specified as rectangular images which are most easily parameterised by two cartesian type coordinates (u,v) say, where 0 <= u,v <= 1. The equation above for the sphere can be rewritten in terms of u and v as

    x = r sin(v pi) cos(u 2 pi)
    y = r sin(v pi) sin(u 2 pi)
    z = r cos(v pi)

Solving for the u and v from the above gives

    v = arccos(z/r) / pi
    u = ( arccos(x/(r sin(v pi))) ) / (2 pi)

So, given a point (x,y,z) on the surface of the sphere the above gives the point (u,v) each component of which can be appropriately scaled to index into a texture image.

Note

  • A sphere cannot be "unwrapped" without distortion, for example, the length between points on the sphere will not equal the distance between points on the unwrapped plane.

  • When implementing this in code it is important to note that most implementations of arccos() returns value from 0 to pi and not 0 to 2 pi as the the formula above assumes. The second half cycle of the arccos function is obtained by noticing the sign of the y value. So the transformation written in C might be as follows

#define PI 3.141592654#define TWOPI 6.283185308void SphereMap(x,y,z,radius,u,v)double x,y,z,r,*u,*v;{   *v = acos(z/radius) / PI;   if (y >= 0)      *u = acos(x/(radius * sin(PI*(*v)))) / TWOPI;   else      *u = (PI + acos(x/(radius * sin(PI*(*v))))) / TWOPI;}

There are still two special points, the exact north and south poles of the sphere, each of these two points needs to be "spread" out along the whole edge v=0 and v=1. In the formula above this is where sin(v pi) = 0.




OpenGL sphere with texture coordinates

Written by Paul Bourke
January 1999

A more efficient contribution by Federico Dosil: sphere.c


While straightforward many people seem to have trouble creating a sphere with texture coordinates. Here's the way I do it (written for clarity rather than efficiency).

Note

  • The whole line at the North pole and the South pole texture map onto a single point at the poles.

  • While this linear mapping of lines of latitude is fine for general textures, it may not be correct for particular image textures such as maps of the Earth. In those cases the latitude texture coordinates need to be matched to the latitude function used to make the image.

  • On many implementations triangle strips are muck efficient than quad strips. On the other hand triangle strips don't look so good in wireframe mode. Depending on personal taste the line glBegin(GL_QUAD_STRIP); can be replaced with glBegin(GL_TRIANGLE_STRIP);

/*   Create a sphere centered at c, with radius r, and precision n   Draw a point for zero radius spheres*/void CreateSphere(XYZ c,double r,int n){   int i,j;   double theta1,theta2,theta3;   XYZ e,p;   if (r < 0)      r = -r;   if (n < 0)      n = -n;   if (n < 4 || r <= 0) {      glBegin(GL_POINTS);      glVertex3f(c.x,c.y,c.z);      glEnd();      return;   }   for (j=0;j<n/2;j++) {      theta1 = j * TWOPI / n - PID2;      theta2 = (j + 1) * TWOPI / n - PID2;      glBegin(GL_QUAD_STRIP);      for (i=0;i<=n;i++) {         theta3 = i * TWOPI / n;         e.x = cos(theta2) * cos(theta3);         e.y = sin(theta2);         e.z = cos(theta2) * sin(theta3);         p.x = c.x + r * e.x;         p.y = c.y + r * e.y;         p.z = c.z + r * e.z;         glNormal3f(e.x,e.y,e.z);         glTexCoord2f(i/(double)n,2*(j+1)/(double)n);         glVertex3f(p.x,p.y,p.z);         e.x = cos(theta1) * cos(theta3);         e.y = sin(theta1);         e.z = cos(theta1) * sin(theta3);         p.x = c.x + r * e.x;         p.y = c.y + r * e.y;         p.z = c.z + r * e.z;         glNormal3f(e.x,e.y,e.z);         glTexCoord2f(i/(double)n,2*j/(double)n);         glVertex3f(p.x,p.y,p.z);      }      glEnd();   }}

It is a ssmall modification to enable one to create subsets of a sphere....3 dimensional wedges. As an example see the following code.

/*   Create a sphere centered at c, with radius r, and precision n   Draw a point for zero radius spheres   Use CCW facet ordering   "method" is 0 for quads, 1 for triangles      (quads look nicer in wireframe mode)   Partial spheres can be created using theta1->theta2, phi1->phi2   in radians 0 < theta < 2pi, -pi/2 < phi < pi/2*/void CreateSphere(XYZ c,double r,int n,int method,   double theta1,double theta2,double phi1,double phi2){   int i,j;   double t1,t2,t3;   XYZ e,p;   /* Handle special cases */   if (r < 0)      r = -r;   if (n < 0)      n = -n;   if (n < 4 || r <= 0) {      glBegin(GL_POINTS);      glVertex3f(c.x,c.y,c.z);      glEnd();      return;   }   for (j=0;j<n/2;j++) {      t1 = phi1 + j * (phi2 - phi1) / (n/2);      t2 = phi1 + (j + 1) * (phi2 - phi1) / (n/2);      if (method == 0)         glBegin(GL_QUAD_STRIP);      else         glBegin(GL_TRIANGLE_STRIP);      for (i=0;i<=n;i++) {         t3 = theta1 + i * (theta2 - theta1) / n;         e.x = cos(t1) * cos(t3);         e.y = sin(t1);         e.z = cos(t1) * sin(t3);         p.x = c.x + r * e.x;         p.y = c.y + r * e.y;         p.z = c.z + r * e.z;         glNormal3f(e.x,e.y,e.z);         glTexCoord2f(i/(double)n,2*j/(double)n);         glVertex3f(p.x,p.y,p.z);         e.x = cos(t2) * cos(t3);         e.y = sin(t2);         e.z = cos(t2) * sin(t3);         p.x = c.x + r * e.x;         p.y = c.y + r * e.y;         p.z = c.z + r * e.z;         glNormal3f(e.x,e.y,e.z);         glTexCoord2f(i/(double)n,2*(j+1)/(double)n);         glVertex3f(p.x,p.y,p.z);      }      glEnd();   }}
sphere.c

by 꽁치 | 2007/04/12 10:25 | 트랙백

LSB and MSB

LSB : Least Significant Byte

MSB : Most Significant Byte

컴퓨터에서 Bytes 의 순서에 의한 구분입니다.

Bytes 를 표현하는 순서는 두 가지 경우가 있습니다.

Little Endian  방식의 컴퓨터에서는 double word의 각 byte를 아래와 같이 표현합니다.
7 6 5 4 3 2 1 0
길이가 8byte인 double word 값에서 가장 중요한 Byte(MSB; 가장 큰 수를 표현하는 부분)가 먼저오고 가장 중요하지 않은 Byte(LSB; 가장 작은 수를 표현하는 부분) 마지막(little end)에 옵니다. 인텔계열이 보통 이와 같습니다. (사람이 쓰는 방식과 같습니다.)

Big Endian 방식은 위와 반대로
0 1 2 3 4 5 6 7  와 같이 거꾸로 표현합니다.
가장 큰 수를 표현할 수 있는 byte  가 가장 마지막에 (Big end) 옵니다.

LSB executable 은 Little Endian 방식의 CPU에서 동작할 수 있는 실행파일이고,
MSB executable 은 Big  Endian 방식의 CPU에서 동작할 수 있는 실행파일입니다.

크로스 컴파일러는 CPU와 다른 방식의 executable 파일을 만들어 주는 컴파일러 입니다.

by 꽁치 | 2007/04/11 17:56 | 트랙백

액자걸기

 


바로 이 와이어 걸이와 나사못을 가지고...

http://77g.com/shopping/prod_list.asp?ct=4&subct=06&gu=와이어걸이 <= 여기서 샀다.

그냥 벽에 못을 박고서 걸으려고 하다가 기왕이면 좀 더 정성을 들이기로 하고 몇일동안 궁리를 한 끝에 위와 같은 와이어 걸이로 미술관처럼(?) 걸었다.  동생에게 드릴을 빌리고(누가 그러더라, 드릴은 남자의 로망이고, 오븐은 여자의 로망이라고... ^^; ) 콘크리트용 6.5mm 드릴 날('기리'라고 하더군)을 철물점에서 사다가 인터넷으로 구매한 와이어걸이와 나사못이 배달되어 오기를 기다렸다가 멋지게 해치운 것이다.

1차로 거실에 4점과 신발장 옆에 1점을 걸었다.  액자 몇 개 걸었을 뿐인데 분위기가 확 틀려졌다.
2차로 안방과 컴퓨터 방에도 걸어야 하는데 요건 아직 작업을 못했다.

벽에다 액자를 걸려고 한다면 와이어걸이로 거는 것을 추천한다.  액자의 크기에 따라서 길이를 조절할 수도 있고, 사용하지 않는다면 와이어걸이를 빼놓으면 되니 이모저모 편하다.

동생이 알려준 tip인데, 벽에 드릴질을 할 때에 진공청소기로 흡입하면서 하면 가루나 먼지를 하나도 날리지 않고 깨끗하게 작업할 수 있다.

by 꽁치 | 2006/12/28 18:06 | Living | 트랙백

◀ 이전 페이지          다음 페이지 ▶