Advertisement

Weird Error, or im a retard, pick one

Started by August 08, 2002 08:51 PM
2 comments, last by sic_nemesis 22 years, 6 months ago
i have this code

 int head_ang=m_limbs[HBODY_HEAD].m_angle;
    //vector2D angle=point-midpoint;
    vector2D ortho( -fixsin(itofix(head_ang)) , fixcos(itofix(head_ang)) );
    //ortho=orthogonal(ortho);
    double ang=dot_product_normalize(ortho,point-midpoint);
    double fart=ang;
    if(ang>0)
    {
        head_ang=head_ang+1;
    }
    else if(ang<0)
    {
        head_ang=head_ang-1;
    }
    textprintf(screen,font,40,40,65535,"%d    %d   ",int(fart),head_ang);
    //this sees if the angle is in range
    if(angle_in_range(
        head_ang&255,
        (m_limbs[m_limbs[HBODY_HEAD].m_parent].m_angle+m_limbs[HBODY_HEAD].m_lbound)&255,
        (m_limbs[m_limbs[HBODY_HEAD].m_parent].m_angle+m_limbs[HBODY_HEAD].m_rbound)&255))    
    {
        m_limbs[HBODY_HEAD].m_angle=head_ang&255;
    }
 
it works, even the dot product and ortho stuff go me! anyways at the part that says if(ang>0) will not work if i have ANY form of ang(the dot product in it) at all. this works everytime: head_ang=head_ang-1; but this will not work EVER head_ang=head_ang+(fart*0)+1; or head_ang=head_ang+(fart-fart)+1; or head_ang=head_ang+(ang*0)+1; or head_ang=head_ang+ang; any of those, the dot product (ang) is zero, and head_ang outputs at 0. why is that? aslo, whnever the dot product is outside of the range of the head, it comes out as zero.. i am confused and i dont get it :/
______________blah
I just made some few tests, and the problem is when any of the elements have a value of 1.#INF00

so i think you could do a _isnan() // Included in the header.

something like:

ang = whatever;

if (!_isnan(ang)) ang = 0; // If ang = 1.#INF00 then set it to zero.


hope it helped.


cheers,




fatal error C1004: unexpected end of file found
Swedish: #Gamedev.se on EFNET
Advertisement
#1.INF00 isn''t a NaN, it''s an infinity. You have a division by zero somewhere.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Well the function works anyway


fatal error C1004: unexpected end of file found
Swedish: #Gamedev.se on EFNET

This topic is closed to new replies.

Advertisement