# Terabyte88

Member

3

117 Neutral

• Rank
Newbie
1. ## How does java find sine and cosine?

Ok this question has been bugging me for months now. How does java find sine and cosine? I’m working on trying to make a game that is a simple platformer something like super Mario or Castlevania. I attempted to make a method that would rotate an image for me and then resize the JLabel to fit that image. I found an algorithm that worked and was able to accomplish my goal. However all I did was copy and past the algorithm any one can do that I want to understand the math behind it. So far I have figured everything out except one part. The methods sin and cos in the math class. They work and I can use them but I have no idea how java get its numbers.   It would seem there is more then one way to solve this problem for now I’m interested in how java does it. I looked into the taylor series but I’m not sure that is how java does it. But if java does use the taylor series I would like to know how that algorithm is right all the time (I am aware that it is an approximation). I’ve also heard of the CORDIC algorithm but I don’t know much about it as I do with the taylor series which I have programmed into java even though I don’t understand it. If CORDIC is how its done I would like to know how that algorithm is always right. It would seem it is also possible that the java methods are system dependent meaning that the algorithm or code used would differ from system to system. If the methods are system dependent then I would like to know how Windows gets sine and cosine. However if it is the CPU itself that gets the answerer I would like to know what algorithm it is using(I run an AMD Turion II Dual-Core Mobile M520 2.29GHz).   I have looked at the score code of the Math class and it points to the StrictMath class. However the StrictMath class only has a comment inside it no code. I have noticed though that the method does use the keyword native. A quick Google search suggest that this keyword enables java to work with other languages and systems supporting the idea that the methods are system dependent. I have looked at the java api for the StrictMath class (http://docs.oracle.com/javase/7/docs/api/java/lang/StrictMath.html) and it mentions something called fdlimb. The link is broken but I was able to Google it (http://www.netlib.org/fdlibm/).   It seems to be some sort of package written in C. while I know java I have never learned C so I have been having trouble deciphering it. I started looking up some info about the C language in the hopes of getting to bottom of this but it a slow process. Of cores even if did know C I still don’t know what C file java is using. There seems to be different version of the c methods for different systems and I can’t tell which one is being used. The API suggest it is the "IEEE 754 core function" version (residing in a file whose name begins with the letter e). But I see no sin method in the e files. I have found one that starts with a k which I think is sort for kernel and another that starts with an s which I think is sort for standard. The only e files I found that look similar to sin are e_sinh.c and e_asin.c which I think are different math functions. And that’s the story of my quest to fiend the java algorithms for sine and cosine.   Somewhere at some point in the line an algorithm is being called upon to get these numbers and I want to know what it is and why it works(there is no way java just gets these numbers out of thin air).

3. ## Student with good Programming skills looking to get started on 2d platformer.

Started learning my way around eclipse one thing I’m trying to do is get my code to run outside of eclipse (having players download eclipse just to run a game would be odd) any ideas on how to make that work. I’ve been experimenting with jar files but no luck.
4. ## Student with good Programming skills looking to get started on 2d platformer.

Ok I am currently attending collage majoring in computer programming. I have taken many classes for different languages (C#, C++, Java, VB, ActionScript). I have gotten an A in all my programming class and have been studying computer programming since high school. This has all been an effort to become a game developer. But the job market being what it is (I live in the USA) I have decided that the only way I can make games is if I do it myself. So I searched the net and found this site and have posted this topic in the hopes of some guidance. Maybe some advice on books and articles I should read or some open source code I could use as an example maybe a good compiler or whatever words of wisdom you might have. I have already decided what type of game to make and what language to do it in along with a few concepts about what the game will look like. It’s going to be a 2d platformer akin to games like Castlevania 4 or Donkey Kong Country. As for the programming language I have decided to write it in Java. In my java class we used TextPad to write the code so I’m thinking I’ll use that but I’m open to suggestions. Something’s I not sure how I’m going to make. The graphics I’m thinking MS paint or paint.net one idea I have is to use my sister’s digital camera to take pictures and use that as a base. I could also do what Donkey Kong Country did and use 3d models as the base for 2d sprites. As for the music I not sure I know I can use Audacity to edit the sound but as for making it I haven’t figured that out yet. I’m not looking to make anything fancy here I just want to do the best I can and any help I can get along the way would be appreciated Thank you.[img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]