From: C. Skluzacek (csklu_pf++at++yahoo.com)
Date: 08/03/2003 04:14:43
Hi Kevin, (en Simon),
I just use the following functions which seem a lot
simpler (and not Performer dependent although the
coordinate system is). Also have a corresponding
hpToXYZ function useful for setting infinite light
coordinates from orientation angles which seems to me
a bit more consistent with spotlight orientation.
//============================================================================
// NAME: xyzToHP
/// Convert a unit vector to heading and pitch
/// Default position (heading = 0, pitch = 0) is along
the +Y axis.
/// Heading increases around +Z axis
/// Pitch increases around +X axis
// ++at++param x,y,z incoming vector components
// ++at++param h,p outgoing heading and pitch angles in
degrees
// ++at++param normalized x,y,z is normalized
//============================================================================
static void
xyzToHP( double x, double y, double z, double & h,
double & p, bool normalized = false )
{
if ( !normalized ) {
double r = sqrt( x*x + y*y + z*z );
x /= r;
y /= r;
z /= r;
}
double xy = sqrt( x*x + y*y );
h = atan2(y,x) * RADTODEG - 90; // 0 heading is
along +Y instead of +X
p = atan2(z,xy) * RADTODEG;
} // xyzToHP
Then do the following for the lookat:
pfVec3 from, to;
pfVec3 xyz = to - from;
pfVec3 hpr;
xyzToHP( xyz[PF_X], xyz[PF_Y], xyz{PF_Z], hpr[PF_H],
hpr[PF_P] );
channel->setView( from, hpr );
--- Simon.Mills++at++esa.int wrote:
>
> Hi,
>
> there isn't a direct equivalent, however I saved
> this posting with a reply to
> your question it from a long time ago (and never
> actually used it). May it
> can help you.
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
This archive was generated by hypermail 2b29 : Sun Aug 03 2003 - 04:16:19 PDT