Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Quaternion Rotations  (Read 1572 times)
0 Members and 1 Guest are viewing this topic.
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Posted 2005-03-20 13:44:38 »

Hi

I'm mot quite sure, if have missed something, or if it is supposed to be like that, or if it is a bug. I wrote a small programm to get the grip on these Odejava rotations. Why I wrote it see also http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=physics;action=display;num=1111085614
Here is the code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
        Odejava.getInstance();
        world = new World();
        GeomBox boxG = new GeomBox(280, 60,240);
        boxG.setQuaternion(new Quat4f(0,0.707f,0.707f,0));
        GeomTransform t = new GeomTransform();
        t.setEncapsulatedGeom(boxG);
        Body b = new Body("boxBody",world);
        b.addGeom(t);
        b.adjustMass(1);
        System.out.println("boxG: "+boxG.getQuaternion());
        System.out.println("t :"+t.getQuaternion());
        System.out.println("b :"+b.getQuaternion());


When I execute this code it prints these Quaternions:
1  
2  
3  
boxG: (0.0, 0.7071068, 0.7071068, 0.0)
t :(NaN, NaN, NaN, NaN)
b :(0.0, 0.0, 0.0, 1.0)


Why is t = (NaN, NaN, NaN, NaN) - It doesn't look correct, but the Box is transformed anyways ... correctly.

Arne

:: JOODE :: Xith3d :: OdeJava ::
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #1 - Posted 2005-03-20 19:58:45 »

what happens if you add a t.setQuaternion in there I wounder?

What is the position for each?

Do you know what NaN means?  It literally stands for Not a Number and normally means there is some problem with your simulation.

Will.

Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #2 - Posted 2005-03-21 09:53:38 »

Quote
what happens if you add a t.setQuaternion in there I wounder?

I set t to (0,0.707,0.707,0), then it prints this:

boxG: (0.0, 0.7071068, 0.7071068, 0.0)
t :(0.0, 0.0, 0.0, 1.0)
b :(0.0, 0.70710677, 0.70710677, 0.0)

This is strange, because it is still transformed like when not using  t.setQuaternion(0.0, 0.7071068, 0.7071068, 0.0) - at least it looks like it, when I show it with RunDemo.

When I set t.setQuaternion(0,0,0,1) it's the same output as by not setting it.

Quote
What is the position for each?

I'm not setting any positions so they're all (0|0|0). I checked this also by printing them.

Quote
Do you know what NaN means?  It literally stands for Not a Number and normally means there is some problem with your simulation.


Yeah, division by 0 or something like that. The only thing is, that the code I printed was all the code the constructer of my test class consistet of. Ok - I added t also to a Vector, for being able to show it with RunDemo.

:: JOODE :: Xith3d :: OdeJava ::
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #3 - Posted 2005-03-27 12:57:50 »

Hi

I solved why I get all the NaN-values !!! I checked the odejava source and performed the transformations odejava is doing for my problem myself. It's actually only the code of updataCachedTransform in GeomTransform.
I wrote this code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
        Quat4f g = new Quat4f(0,0.707f,0.707f,0); // the quaternion of the encapsulated geom
       Matrix4f mg = new Matrix4f();
        mg.set(g); //all rotations are transformed into matrices
       Quat4f b = new Quat4f(0,0,0,1); // the quaternion of the body
       Matrix4f mb = new Matrix4f();
        mb.set(b);
        b.mul(g);  // for comparing the different results I multiplied the quaternions
       mb.mul(mg); // and the matrices
       System.out.println(b); //printing the result of the Quaternion multiplication - the quat result is also transformed into a matrix
       System.out.println();
        Matrix4f res = new Matrix4f();
        res.set(b);
        System.out.println(res);
        System.out.println("--------------------------------");
//printing the result of the Matrix multiplication - the matrix result is also transformed into a quad - this is the way odejava does it
       Quat4f mres = new Quat4f();
        mb.get(mres);
        System.out.println(mres);
        System.out.println();
        System.out.println(mb);


I get this output:

(0.0, 0.7071068, 0.7071068, 0.0)

-1.0000002, 0.0, 0.0, 0.0
0.0, -1.1920929E-7, 1.0000001, 0.0
0.0, 1.0000001, -1.1920929E-7, 0.0
0.0, 0.0, 0.0, 1.0

--------------------------------
(NaN, NaN, NaN, NaN)

-1.0000002, 0.0, 0.0, 0.0
0.0, -1.1920929E-7, 1.0000001, 0.0
0.0, 1.0000001, -1.1920929E-7, 0.0
0.0, 0.0, 0.0, 1.0

I think it is obvious, that the matrix isn't transformed correctly into a quat.

:: JOODE :: Xith3d :: OdeJava ::
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (22 views)
2014-09-19 03:14:18

Dwinin (35 views)
2014-09-12 09:08:26

Norakomi (64 views)
2014-09-10 13:57:51

TehJavaDev (90 views)
2014-09-10 06:39:09

Tekkerue (44 views)
2014-09-09 02:24:56

mitcheeb (65 views)
2014-09-08 06:06:29

BurntPizza (48 views)
2014-09-07 01:13:42

Longarmx (35 views)
2014-09-07 01:12:14

Longarmx (40 views)
2014-09-07 01:11:22

Longarmx (37 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!