The subject of the thread sort of exhausts the question - I'm trying to implement sin/cos calculation in my project and seeing that the DS *hates* floats, standard cos(angle) sin(angle) functions from math.h are out of question.
Besides, for some odd reason, Visual C++ Express 2008 rejects the function whenever I'm trying to pass an argument into it (error 'cos' undeclared) while it works perfectly fine if I simply input a number and I don't have a devkitPro template for the 2010 Edition which apparently fixed this issue (I already googled it, it was a re-occouring thing).
So, I came to the conclusion that I can go in either of ways - I can create an array of possible values for Sin/Cos *or* I can create a custom function that will count Sin/Cos according to Fixed Point Arithmetic in real-time.
What's your take on the issue? How would you approach it?
Thanks in advance for any tips.
Sine/Cosine as Fixed Point Math
Re: Sine/Cosine as Fixed Point Math
floats are only a problem on the ds if you are using them in high use areas - for instance floating point software 3d texture mapping probably is not going to perform well. If you are using floats sparingly then they are not a problem.
Not sure what you mean by "Visual C++ Express 2008 rejects the function" - are you talking about Intellisense? That does not really matter so much as gcc is actually doing the compiling not visual studio - it just means you do not have intellisense paths/settings setup correctly for your project. if you are getting a linker error then make sure you add libm to your library list in your makefile. change
to:
If you are calling sin/cos a few times per frame it is not going to hurt anything.
Not sure what you mean by "Visual C++ Express 2008 rejects the function" - are you talking about Intellisense? That does not really matter so much as gcc is actually doing the compiling not visual studio - it just means you do not have intellisense paths/settings setup correctly for your project. if you are getting a linker error then make sure you add libm to your library list in your makefile. change
Code: Select all
LIBS := -lnds9
Code: Select all
LIBS := -lnds9 -lm
Re: Sine/Cosine as Fixed Point Math
also, libnds has fixed point sin/cos functions that you can use.
http://libnds.devkitpro.org/a00150.html
http://libnds.devkitpro.org/a00150.html
Re: Sine/Cosine as Fixed Point Math
What I meant by "rejects" is that when I include the Math.h file and use the standard cos(); function with a value, such as cos(123); it compiles perfectly fine and the resulting build calculates the value, however when I pass an argument, such as cos(AVariable); the compiler informs me that "cos" is an undeclared function, which is a load of croak. This happens regardless of what type AVariable is - I tried double, I tried float, same result. I checked it online and it appears to be a problem that "sometimes" occours in 2008's edition and Microsoft's only patch for it is "Install the 2010 Edition", so yeah.
However, as mentioned in the post directly above, I already switched to the built-in functions and they're working just fine.
However, as mentioned in the post directly above, I already switched to the built-in functions and they're working just fine.
-
- Site Admin
- Posts: 1856
- Joined: Tue Aug 09, 2005 3:21 am
- Location: UK
- Contact:
Re: Sine/Cosine as Fixed Point Math
I'm not really sure how MSVS 2008 can affect devkitARM like this, what were you trying to compile? A snippet of code would be useful.
Re: Sine/Cosine as Fixed Point Math
I'm 100% certain that this is not an issue with devkitPro - it's an issue with 2008 Express. I tried compiling literally the same code for Windows Console and the DS (of course with DS-specific functions in the DS version) with the same result, and a best code snippet I could give to you is simply "just the includes and main" with "just cos(angle);" because even cutting it down to literally just this causes an error.
Not to worry though, I'm using the Fixed Point functions now and it's working just dandy.
Not to worry though, I'm using the Fixed Point functions now and it's working just dandy.
Who is online
Users browsing this forum: No registered users and 26 guests