yaba

08-07-2002, 05:16 PM

maybe this question doesn't belong in this forum but I was trying to do this in opengl for a trackball so...

I was wondering if someone could explain this code I found for projecting 2D points onto a hemisphere...especially the (*) parts

Vec3f v;

float d;

(*) v.x = (2.0*point.x - windowSize.x) / windowSize.x;

(*) v.y = (windowSize.y - 2.0*point.y) / windowSize.y;

v.z = 0.0;

d = v.Length();

d = (d<1.0) ? d : 1.0;

(*) v.z = sqrtf(1.001 - d*d);

v.Normalize(); // Still need to normalize, since we only capped d, not v.

return v;

Thanks.

I was wondering if someone could explain this code I found for projecting 2D points onto a hemisphere...especially the (*) parts

Vec3f v;

float d;

(*) v.x = (2.0*point.x - windowSize.x) / windowSize.x;

(*) v.y = (windowSize.y - 2.0*point.y) / windowSize.y;

v.z = 0.0;

d = v.Length();

d = (d<1.0) ? d : 1.0;

(*) v.z = sqrtf(1.001 - d*d);

v.Normalize(); // Still need to normalize, since we only capped d, not v.

return v;

Thanks.