Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: squidgetx on November 19, 2010, 07:55:10 pm
-
Ok, so I'm looking at these trig routines, and so I see that the period is 256 and that the amplitude is 127. What does this mean? As in, how can I use them to behave the same way as the 'normal' trig functions? I suppose that.....it's like a new 'measurement' of angles, in addition to radians and degrees....?
So if 1 period in radians = 2pi
1 period in degrees = 360 = 180/pi times radian measure
1 period in Axe = 256 = 256/360 times degree measure = 256(180)/360pi times radian measure = 128/pi times radian measure....or 32/45 times degree measure
amplitude in degrees=1
amplitude in Axe= 127 times 1
So does this mean that I should take my number , multiply by 32/45, take the sine of it, and divide by 127? But then, that would probably give me 0 all the time since Axe rounds down...
-
Yeah, that's pretty much it. They're called binary degrees, if you're wondering. You can't really have an amplitude of 1 since that would involve decimals, which could get nasty. But you can always divide it by whatever number applies so you get the amplitude you want.
And as for the period, it's actually really convenient if you think about it. For example, say you want something that draws a line going in a circle, like a hand on a clock. You'd do something like
:For(A,0,255)
:Line(47,31,sin(A)//8+47,31-cos(A)//8)
:DispGraph
:End
As you can see, having 255 be the period works because a single-byte number can just keep looping on forever, and each time it gets back to zero again, the sine function goes on unbroken. And because of this, you can store both the angle value and the function value as a single byte with maximal accuracy.
-
So if I inflate all my numbers by a factor of 128, then I could take the sine of 32/45's of whatever degree measure and it would be fine then, right?
-
So if I inflate all my numbers by a factor of 128, then I could take the sine of 32/45's of whatever degree measure and it would be fine then, right?
Yeah, just multiply the degree measure by 45/32 (not 32/45) and treat the result as inflated by 128, and it'll work just like degrees.
-
Wait, shouldn't it be 32/45 ???
For example, 90 degrees times 32/45 = 64, which I think corresponds correctly to a period of 256 whereas 90 degrees times 45/32 is 126.5625...
-
Wait, shouldn't it be 32/45 ???
For example, 90 degrees times 32/45 = 64, which I think corresponds correctly to a period of 256 whereas 90 degrees times 45/32 is 126.5625...
Er, sorry. I got them confused. Just watch me fail my next math test by doing everything by 256s x.x
-
Lol nice.
Is it true then that inflating all numbers by 128 would give the best precision too?
-
In this case, in a single byte, yeah. That way, it uses the entire scale (0 to 255) to fit decimals from -1 to 1 with as much precision as possible.
-
Wait, the output-ed value is only 1 byte?
-
Wait, the output-ed value is only 1 byte?
Well, no, never mind. Guess it's just more convenient to work with than 0-65535 :D
EDIT: Good point, why not make the range from -255 to 255? That could make it match the fixed point math stuff...
Feature request?
-
If you need really accurate sine and cosine routines, might I suggest this (http://ourl.ca/4129/130460)? :)
-
If you need really accurate sine and cosine routines, might I suggest this (http://ourl.ca/4129/130460)? :)
Runer, would these be accurate enough to use in a triangle solver?
-
They provide pretty good accuracy, probably less than 0.01% or so error :P The accuracy is just about as good as you can get with 2-byte values.
-
If you're trying to make a triangle solver, it would be much easier to write in BASIC. Axe is designed for games and so the math functions are optimized for speed and size instead of precision. Trig functions are uncommon in calculator games (unless its an attempt at 3D) which is why there is only minimal support for them.
-
You could always implement the functions in Assembly.
For example, this guy did it in ARM:
http://www.coranac.com/2009/07/sines/ (http://www.coranac.com/2009/07/sines/)
-
i know, but it'd be cool to write a triangle solver in axe. regardless, i have one (almost) finished in BASIC which is only missing the ambiguous case.
-
I fear the grayscale quadratic solver axe port is next...
-
It'd be difficult to do in Axe. The first imaginary number might crash the program. You'd have to go into ASM to handle those.
-
Someone should write a quadratic solver. Maybe I'll do it if I have time.
Off topic, but Qwerty.55, your sig is bringing back horrible memories of quantum physics, having to solve for the energy levels of multi-electron atoms. The DE's got really really ugly...
-
lol that would be funny in some ways actually, although not as much as if the first Axe program ever released on ticalc.org was a quadratic solver. That happened to BBC Basic. :P
-
Someone should write a quadratic solver. Maybe I'll do it if I have time.
Off topic, but Qwerty.55, your sig is bringing back horrible memories of quantum physics, having to solve for the energy levels of multi-electron atoms. The DE's got really really ugly...
Glad to hear it ;D
I use that bloody equation more than I'd like to (IE more than not at all).
-
The DE's got really really ugly...
For some reason, all I can think of is the register. :P
-
The DE's got really really ugly...
For some reason, all I can think of is the register. :P
Same here. I got confused there for a bit :D
-
Okay, bumping this.
I'm struggling to understand. According to Axe the cosine of 0 is 127. How do I get 1 out of this?
-
Divide by 128. Unfortunately, you'll lose 1/128th :( Read my slope physics tutorial for more help on this :) (Edit; I see you are. Never mind then :P)
-
I thought that was the case, however, cos(45) returns 63 in Axe. cos(45) is approximately equal to .7071, however, 63/128 is .4922.
-
The sine and cosine functions in Axe use binary degrees because they're much more optimized. That means 256 degrees in a circle instead of 360. cos(32) would return a value much closer to what you're expecting.
-
Hmm. Okay, I think I understand better.
Thanks!