Log In  


There is a sine and cosine function but no tangent function. Anyone have a function of their own?

math feature
P#48004 2018-01-09 18:46 ( Edited 2018-01-10 18:37)


The simplest way would be to use the trigonometric identities.

Specifically, the one that says tan θ = sin θ / cos θ.

That gives:

function tan(a)
    return sin(a)/cos(a)

Note though that this starts to fall apart in the vicinity of 90° and 270°, since pico-8's fixed-point variables can't represent the large numbers around those values, or the infinite values at them, but realistically you wouldn't be using tan() for angles like that anyway, because it wouldn't be useful.

P#48010 2018-01-10 00:10 ( Edited 2018-01-10 13:12)



This is another one of those functions that I think it's dumb for pico-8 not to include. Yeah, we can make it ourselves, but... seriously... just include it, it's a fundamental thing.

P#48011 2018-01-10 00:11



Thank you!

P#48049 2018-01-10 18:37

Log in to post a comment


New User | Account Help
:: New User
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2018-10-20 06:05 | 0.221s | 1572k | Q:12