WiiRd forum

Wii & Gamecube Hacking => Wii Game hacking help => Topic started by: Igglyboo on February 01, 2009, 08:47:33 PM

Title: Sine Cosine and Tangent
Post by: Igglyboo on February 01, 2009, 08:47:33 PM
Is it possible to(easily) use these functions in ASM?
I have a really good idea on how to use them but I don't want to use a huge insert for them.
Title: Re: Sine Cosine and Tangent
Post by: Almas on February 01, 2009, 09:29:16 PM
You could use the Maclaurin Approximations to them, which would take about 4-5 lines in ASM (or more, depending on accuracy desired).
Title: Re: Sine Cosine and Tangent
Post by: Igglyboo on February 02, 2009, 12:57:26 AM
I actually found the function in the game and called it but only for cos.
I will look into those for sin and tan
Title: Re: Sine Cosine and Tangent
Post by: Fred on February 02, 2009, 07:24:09 AM
You're really going into math codes Igglyboo  :P
Title: Re: Sine Cosine and Tangent
Post by: Link on February 03, 2009, 09:44:38 AM
if you have a cosine function then you're set!

pseudo code

function cosine(x) //base function

function sine(x) {
    param=x-pi/2
    val=cosine(param)
    return val
}

function tangent(x) {
    a=sine(x)
    b=cosine(x)
    val=a/b
    return val
}
Title: Re: Sine Cosine and Tangent
Post by: Almas on February 03, 2009, 12:13:11 PM
Out of curisioity, does the Wii function using degrees, radians or gradients?

But yes, if you have cos, you can attain the others in a variety of ways.

sin(x) = cos(90-x) = cos(pi/2 - x)
sin²(x) = 1-cos²(x)

tan(x) = sin(x)/cos(x)
tan²(x) = 1-1/cos²(x)
Title: Re: Sine Cosine and Tangent
Post by: Link on February 03, 2009, 12:28:59 PM
Quote from: Almas on February 03, 2009, 12:13:11 PM
Out of curisioity, does the Wii function using degrees, radians or gradients?

It would be the first time I saw a programming language not using radians - in 97% they do, degrees are used in 2.9% - gradients probably in the 0.1% I never saw ;)
Title: Re: Sine Cosine and Tangent
Post by: Igglyboo on February 03, 2009, 01:51:42 PM
It uses radians, I had to multipy by pi/180 to get it to work.
I found the other two trig functions by loading the system menu into IDA, they are the same in brawl.
Title: Re: Sine Cosine and Tangent
Post by: Link on February 03, 2009, 02:16:04 PM
Quote from: Igglyboo on February 03, 2009, 01:51:42 PM
It uses radians, I had to multipy by pi/180 to get it to work.
I found the other two trig functions by loading the system menu into IDA, they are the same in brawl.

Probably Nintendo SDK then - sine and cosine are essential functions when programming games and as the platform does not have them I guess the Nintendo SDK ships them then!