gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > 2 questions (sin/cos table & normals)

#144754 - Noda - Tue Nov 06, 2007 6:02 pm

Hello!

To use the sin/cos table with degree angles I use a function like this:

Code:
// sine function
int32 sinf32(f32 angle)
{
    return (SIN[(int)((angle * LUT_SIZE) / 360) & LUT_MASK]);
}


but how to deal with radian angles?

My second question is concerning cubes & normal:

Will it make a change if for a cube model I define a normal per vertices or per face? will it make the lightning smoother along a face if I use a normal per vertices? (if so, what would be the formula to calculate the normal for a vertice?)

Thanks ;)

#144760 - Miked0801 - Tue Nov 06, 2007 8:13 pm

Convert from radians to your table size. You could just convert radians to degrees to table size, but it'd be better to do it in one step

2*PI Radians = 360 degrees therefore 1 radian = 360 / (2 * PI) = 180 / PI ~= 57.30 degrees.

On the Cube thing, as long as you are using flat lighting, I don't see a difference in having more normals. A normal per face should suffice. Mathematically speaking - the hardware may differ.

#144927 - Noda - Fri Nov 09, 2007 9:29 am

Thanks!

concerning the normals on the cube, it has the effect I thought: defining a normal per vertice instead of per face cause the shading to be smoothed insteead of being flat on a face... ;)