- #1
dadin22
- 5
- 0
Homework Statement
Assuming an orthographic projection, the sphere projects into a circle on the image plane.
compute the normal vector to the sphere’s surface at a given point(x,y). The Sphere's center coordinates x,y are known as well as the radius. The resulting normal is in 3d coordinate system. the origin of vector is in sphere's center. its x-axis and y-axis parallel to the image's x-axis and y-axis. z-axis should be as such to form a orthonormal right-hand coordinate system.
Homework Equations
Our surface is a Lambertian surface.
The Attempt at a Solution
double phi=atan(yp/xp);
cout<<phi;
cout<<" "<<xp<<" "<<yp;//
double zp=90*cos(phi);
double z = sqrt((r*r)-(x*x)-(y*y));
// (xp-x)^2 + (yp-y)^2 + (zp-z)^2 = R
/* tangent vector with respect to image plane */
double tx = -sin(phi);
double ty = cos(phi);
double tz = 0;
/* tangent vector with respect to sphere */
double sx = cos(phi)*(-sin(90));
double sy = sin(phi)*(-sin(90));
double sz = cos(90);
/* normal is cross-product of tangents */
double nx = ty*sz - tz*sy;
double ny = tz*sx - tx*sz;
double nz = tx*sy - ty*sx;
/* normalize normal */
double length = sqrt(nx*nx + ny*ny + nz*nz);
nx /= length;
ny /= length;
nz /= length;
cout<<brightest_Pixel;
cout<<" "<<length;