Need Help.. vector3df with double/float parameter

Discussion about Irrlicht's Java wrapper
Post Reply
munemune
Posts: 9
Joined: Sun Nov 23, 2008 10:45 am

Need Help.. vector3df with double/float parameter

Post by munemune »

Hi, i need help with jirr. This my problem :
to use vector3df with float parameter u just neet to add 'f' right? like this :

vector3df(2.6f,3.2f,2.0f)

But what in the case, the parameter i want input is from another calculation, like :

x=Math.cos((180)*Math.PI/180));
y=Math.cos((180)*Math.PI/180));
z=Math.cos((180)*Math.PI/180));

in vector3df just i put the parameter like this :

vector3df(x,y,z)

But, it wont work!!! The java compiler say error about :
"cannot find symbol"
"symbol : constructor vector3df(double,double,double)"
"location : class net.sf.jirr.vector3df"

Anyone can help?
Thanks.
johnrico2000
Posts: 6
Joined: Fri Aug 29, 2008 10:16 pm

Post by johnrico2000 »

Hi

The vector3df(...) constructor demands numbers of data type "float". The result of Math.cos(...) is of data type "double". You just have to perform a simple type cast of the values from double to float like that:

float x = (float)Math.cos(a double value);

In your case it would be

float x = (float)Math.cos((180)*Math.PI/180);
float y = (float)Math.cos((180)*Math.PI/180);
float z = (float)Math.cos((180)*Math.PI/180);

This values should work with the vector3df(x,y,z) constructor.

I hope I could help
Frank
munemune
Posts: 9
Joined: Sun Nov 23, 2008 10:45 am

Post by munemune »

Thank for your reply.

But type cast it still wont work. Its like in this case : vector3df(2.7,3.0,9), its produce same error.

Anyway after i digg with jirr source code, i found solution to manipulate vector3df.

to get the x,y,z coordinate in jirr, is using method getX(),getY(),getZ()
and to set x,y,z coordinate in jirr, is using method setX(),setY(),setZ()

The c++ code to set X coordinate like this, coor.X =Math.cos((180)*Math.PI/180));
In jirr u must write coor.setX((float)Math.cos((180)*Math.PI/180)))

Hope, JIrr will have a good documentation in the future :)
Post Reply