Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: c4ooo on March 04, 2015, 07:14:46 am

Title: How to calculate (using trig) rotation in axe?
Post by: c4ooo on March 04, 2015, 07:14:46 am
i wanted to make a 3d game, but as ime not sure how to use the sin and cos function in axe as they return unexpected values.
How would i go about implementing rotation (for now, if i know haw to rotate round y i can rotate around any thing) around the y axis?
Thank you;
Title: Re: How to calculate (using trig) rotation in axe?
Post by: Sorunome on March 04, 2015, 07:49:22 am
The sin( and the cos( functions both return values from -127 to +127. The period is from 0 to 256, so if you were to draw a sine curve it starts at 0, crosses the x-axis at 128 and ends again on the x-axis on 256.
Title: Re: How to calculate (using trig) rotation in axe?
Post by: c4ooo on March 04, 2015, 09:58:01 pm
The sin( and the cos( functions both return values from -127 to +127. The period is from 0 to 256, so if you were to draw a sine curve it starts at 0, crosses the x-axis at 128 and ends again on the x-axis on 256.

Yes. But if it returns values from -127 to +127, will that mean that I devide the final out put by 127? That's the part I don't get.
if you can provide some code that rotates (x,y) around the z axis that would be nice. (Originally I said y but I ment z)
Title: Re: How to calculate (using trig) rotation in axe?
Post by: Sorunome on March 05, 2015, 07:55:45 am
According to https://www.siggraph.org/education/materials/HyperGraph/modeling/mod_tran/3drota.htm you have
Code: [Select]
x' = x*cos q - y*sin q
y' = x*sin q + y*cos q
z' = z

so in axe you'd do something like

Code: [Select]
x' = ((x*cos(q)) - (y*sin(q)))/127
y' = ((x*sin(q)) + (y*cos(q)))/127
z' = z

Note that you do not have floating point numbers in axe, so you divide as late as possible
Title: Re: How to calculate (using trig) rotation in axe?
Post by: c4ooo on March 05, 2015, 01:04:03 pm
Ok thanks! Going to try it out. Its just that i tried to look at the 3d cube demo program and got confused by the code!
Title: Re: How to calculate (using trig) rotation in axe?
Post by: TheMachine02 on March 05, 2015, 03:59:08 pm
You also have to take care that you need a signed division (and not the unsigned) wich is //.
As a side note, dividing by 127 is mathematicly correct, but you doesn't want to do that  :P as it is verrry slow. Divide by 128 instead (and btw, the precision loss is almsot nothing)