Java - Maths Package

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

Java - Maths Package

Postby GMorgan » Sat Dec 16, 2006 6:28 pm

Does anyone know if there are any existing maths packages for Java. There is a Vector class in 1.5 but it has nothing to do with vectors.

What I'm looking for is something along the line of a Scalar class with a ScalarMaths class. Then a Vector2D/Maths class etc.

I need it for a game I'm writing (finally getting around to that now my coursework is done for a few weeks). I'll quite happily implement it myself but wanted to check if anyone knows of an existing package. Google tends to leave me looking at mountains of hits for the aforementioned Vector class (which is just a collection).
GMorgan
LXF regular
 
Posts: 684
Joined: Thu Jan 12, 2006 6:58 pm
Location: South Wales, UK

RE: Java - Maths Package

Postby jjmac » Mon Dec 18, 2006 10:35 pm

A maths class !

Java has always had math classes ... Just looking at knoppix 5.0.1's bundled java,

/usr/lib/j2se1.4-sun/jre/lib/rt.jar

Which has numerous math related classes.

>>
There is a Vector class in 1.5 but it has nothing to do with vectors.
>>

Thats just a type of array that will allow hold different 'types'. Along with built in methods for access.

As i remember it, java has had built in math from the beginning, which, of course, has just been going through progressive development over time.

>>
Google tends to leave me looking at mountains of hits for the aforementioned Vector class (which is just a collection).
>>

Thats because, thats what they mean by a vector.

You probably need to get a hold of a graphical app along the lines of what you want to do. One with the souces available, and just use that as a kind of example, to see what classes their using for their math.


jm
http://counter.li.org
#313537

The FVWM wm -=- www.fvwm.org -=-

Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ...
jjmac
LXF regular
 
Posts: 1996
Joined: Fri Apr 08, 2005 1:32 am
Location: Sydney, Australia

RE: Java - Maths Package

Postby GMorgan » Mon Dec 18, 2006 11:04 pm

It has a Maths class but it doesn't do what I want. I should have been more specific in the title. At the moment it has good support for scalar mathematics but I've seen nothing that looks like i,j,k vector mathematics.

I'm hoping to simplify all the movement in a game by simply using vectors. So a displacement would just be done by adding 2 vectors together and such. Just takes all the work out of implementation for future by bundling the motion into one package that can then just be used repeatedly.

For what I'm working on it would probably be easier to just dump such considerations directly into the game but it would spoil my sense of aesthetics ;).
GMorgan
LXF regular
 
Posts: 684
Joined: Thu Jan 12, 2006 6:58 pm
Location: South Wales, UK

RE: Java - Maths Package

Postby jjmac » Tue Dec 19, 2006 9:30 am

I used to have a java applet that did a 'asteroids' type of game. It was created around 1.0, but worked really well. And had another thing that just faded in with a banner that said water, with lapping water as a back drop. They were both good small programs and were in windows. I guess if you could find something that exists that is close to what you want to do, and the source is available ... it might contain some hints. Even to possibly extend an existing class ?

jm
http://counter.li.org
#313537

The FVWM wm -=- www.fvwm.org -=-

Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ...
jjmac
LXF regular
 
Posts: 1996
Joined: Fri Apr 08, 2005 1:32 am
Location: Sydney, Australia

RE: Java - Maths Package

Postby TonyLB » Thu Dec 21, 2006 10:24 pm

Have a look at the Java3D package. That's oriented towards 3D graphics and has (amongst other things) a javax.vecmath package which contains various point, vector2D and vector3D classes along with manipulation methods, invertions, quaternions and lots more. Just about everything you need for graphics manipulation.

Java3D has been OS for quite a while now after Sun let it go (they are focusing more on jogl), and we're up to version 1.5 beta

https://java3d.dev.java.net/ and http://www.java3d.org/

Tony
In the beginning was nothing, which exploded! (Lords and Ladies, Terry Pratchett)
TonyLB
LXF regular
 
Posts: 112
Joined: Tue Apr 12, 2005 7:08 pm
Location: Wirral, UK

RE: Java - Maths Package

Postby GMorgan » Sat Dec 23, 2006 12:43 am

I'll have a look. According to that site the vecmath project is under the JRL. I'll have to have a read of it, I'd be hoping to strip it out and put it directly in a package if at all possible. I'd rather not have to force people to install all of Java3D.
GMorgan
LXF regular
 
Posts: 684
Joined: Thu Jan 12, 2006 6:58 pm
Location: South Wales, UK


Return to Programming

Who is online

Users browsing this forum: No registered users and 6 guests