Sine Cosine and Tangent

Started by Igglyboo, February 01, 2009, 08:47:33 PM

Previous topic - Next topic

Igglyboo

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.

Almas

You could use the Maclaurin Approximations to them, which would take about 4-5 lines in ASM (or more, depending on accuracy desired).

Igglyboo

I actually found the function in the game and called it but only for cos.
I will look into those for sin and tan

Fred

You're really going into math codes Igglyboo  :P
If someone helped you press the thank you button.

Link

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
}

Almas

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)

Link

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 ;)

Igglyboo

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.

Link

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!