GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: Add Line Numbers


A Paste by Anonymous
kRotator LookAt(kVector v1, kVector v2)
{
    kRotator Result;
    float yawangle, tanangle1;
    float pitchangle, tanangle2;

    tanangle1 = (v1.Z-v2.Z) / (v1.X-v2.X);
    tanangle2 = (v1.Y-v2.Y) / (v1.Z-v2.Z);
    
    if (v1.X < v2.X)
        yawangle = atan(tanangle1);
    else
        yawangle = atan(tanangle1)+pi;

    pitchangle = atan(tanangle2);

    Result.Yaw = (yawangle*-radtodeg)-90;
    Result.Pitch = (pitchangle*-radtodeg);
    Result.Roll = 0;

    return Result;
}