Free Rotation Joint SixDofJoint help

Sounds good, will try that thanks !

Sorry for the good will abuse, but how do I get the applied physics vector in this case in order to “fix” it in the right projection ?

I dont know if I am in the right path but I did :

@Override public void physicsTick(PhysicsSpace arg0, float arg1) {
    Vector3f posJoint = distObjNode.getWorldTranslation();
    Vector3f posObj   = distObjRigid.getPhysicsLocation();
    Vector3f fromObjToJoint = new Vector3f( posObj.x - posJoint.x , posObj.y - posJoint.y , posObj.z - posJoint.z );
    Vector3f newlinear =  FastMath.interpolateLinear(0.5f, distObjRigid.getLinearVelocity() , fromObjToJoint );
    distObjRigid.setLinearVelocity(newlinear);

    System.out.println(  distObjRigid.getLinearVelocity()  );
}

It didnt work, the object simple goes to infinity very fast lol :blush:

Am I in the right path ?

Just thought I’d point out that this vector is named exactly opposite of what it actually is. It’s a vector that points from joint to object.

I guess just the name is right then … But I tried to change to it :

Vector3f fromObjToJoint = new Vector3f( posJoint.x - posObj.x , posJoint.y - posObj.y , posJoint.z - posObj.z );

Now the object rotates as crazy but dont move anywhere.
Is this logic right ?

(shrug) I don’t really know what the logic is trying to do… so I can’t say. I just noticed that either the name or the math was wrong for that particular vector.

Perhaps if you described what you want to have happen in the physics tick using human words and not code then it would be clearer.

I have objects in orbit of a planet, some objects are using joints, but for this particular object, I need it to rotate in all directions, and there is no distance joint in JM3 ( not yet I hope ), so I came here to get some alternatives.
@normen give me the suggestion to change the direction on the physics tick using the setlinear, so this is a try to archive this.
I was in hope that if I take the currently linear vector and interpolate with the vector into the core of the planet, I would force an orbit, but its not working…

The circular motion is a circle (so a sinus) and the velocity is the vector from the current position to the next position on that circle. You can also rotate a vector using tpf as outlined in the math for dummies tutorial to describe the intended path.

Yes, thats true, you explain a lot with a few worlds, I just figure out that what I need is an angle.
But how to get this angle ? I am having bad time to try to understand this.
This angle suppose to be an angle between the actual velocity vector and some kind of plot in the planet sphere of it, or maybe I am just complicating things ?

Please do me the favor and actually look at the math for dummies tutorial so what I say isn’t futile.

Lets say you want the object to rotate at a distance of 100 around the z axis. Then this pseudo code would basically do that, you might have to adapt a bit (and remove possible mistakes I made :P):

// define start position relative to planet
Vector rotVec = Vector(100,0,0); 
// find actual start position
Vector startPos = planetPos + rotVec;
 // put physics object to start position
object.setPosition(startPos);
// in update loop / physics update
update(tpf){
  Quaternion rotQuat = quaternion.fromAngleAxis(0.1*tpf, Vector_Z);
  // rotate vector a bit for new position
  rotQuat.mult(rotVec);
  // find direction to new position
  Vector direction = (planetPos + rotVec) - object.position;
  direction.normalize();
  // needed speed depends on circle size (2*Pi*radius) and the speed you rotate the vector 
  direction.mult(0.1*tpf * (2*Pi*100));
  object.setVelocity(direction);
}

Well, my problem I guess is that I dont know the angle … I dont remember trigonometry details anymore, but if someone knows if this is the right direction I just go reading some old books.

http://postimg.org/image/s4v0xpm67/

I even tried to adapt your code in the physics tick:

    float tpf = arg1;
    int radios = 2; float Pi= FastMath.PI ;
    Vector3f posJoint = distObjNode.getWorldTranslation();
    Vector3f posObj   = distObjRigid.getPhysicsLocation();
    Quaternion rotQuat = distObjRigid.getPhysicsRotation().fromAngleAxis(0.1f*tpf, Vector3f.UNIT_Z);
    Vector3f rotVec = new Vector3f(radios,0,0);
    rotQuat.mult(rotVec);
    Vector3f direction = new Vector3f( posJoint.x+rotVec.x-posObj.x  , posJoint.y+rotVec.y-posObj.y , posJoint.z+rotVec.z-posObj.z ).normalize();
    direction.mult(0.1f*tpf * (2*Pi*radios));
    distObjRigid.setLinearVelocity(direction);

Its just moving the object at right and stops, and stays there.

Because you don’t do that part in the update(tpf) continuously. And there is no angles in that code apart from the quaternion.

Edit: Ah and if you do that continuously you do too much continuously, the vector gets recreated each time instead of rotated further - only do whats in the update(tpf) continuously, you obviously have to keep the rotVec to be able to rotate it further - I have a feeling you didn’t read the math for dummies rotation tutorial :frowning:

What do you mean about the update(tpf), should the physics tick update the tpf ?
Yes, I dont have the angle yet, I guess the angle I need is the one from the picture right ?
I have read the doc, what part of it should be usefull here ?

  1. update(tpf) is the pseudo-code for the continuous update loop - which should basically be your physics tick, yes.
  2. The one about rotating a vector. You do realize how that rotVec represents your offset of the orbiting object to the planet, yes? Imagine how when you keep rotating that vector it describes the path of your orbit - all without angles (again apart from the quaternion angle you rotate it with).

Now I understood the logic, but I am not sure why its not working.
The planet core is on 0,0,0 , the object pos is on 0 , -2 , 0.
If I mult the rot vector : rotQuat.mult(new Vector3f(0,radios,0));
It goes to the 0 distance from the planet core and works, but with 0 distance.
Maybe its not working because the pos of the object is 0,-2,0 ?

Not NEW vector, you need to mult THAT ONE vector, and then the new vector that results from that (or rather that changed vector). What you do is reset the clock to 12 each time and wonder why each hour it shows 1 o’clock…

Or maybe you forgot to set the initial position of the object…? Look at my pseudo-code again, line for line. Please do a bit of homework instead of letting me do everything for you.

Yes, I saw it, changed but same results :

On class declaration :

int radios = 2; 
Vector3f rotVec = new Vector3f(0,radios,0);

On Physics trick :

    float tpf = arg1;
    float Pi= FastMath.PI ;
    Vector3f posJoint = distObjNode.getWorldTranslation();
    Vector3f posObj   = distObjRigid.getPhysicsLocation();

    Quaternion rotQuat = distObjRigid.getPhysicsRotation().fromAngleAxis(0.1f*tpf, Vector3f.UNIT_Y);
    rotQuat.mult(rotVec);

    Vector3f direction = new Vector3f( posJoint.x+rotVec.x-posObj.x  , posJoint.y+rotVec.y-posObj.y , posJoint.z+rotVec.z-posObj.z ).normalize();
    direction.mult(0.1f*tpf * (2*Pi*radios));
    distObjRigid.setLinearVelocity(direction);

Where do you set the initial location for distObjRigid? And why the heck do you add and substarct only the x values of the vectors???

vector1 + vector2 in my pseudo code means vector1.add(vector2) in real code… Please, think a bit… Don’t just put in some code and post here again if it doesn’t work right away.

I found out trowing some balls into the object that its going to the pos ( 0 , 2 , 0 )…
Maybe I should put a if to see if the current linear velocity is 0 do nothing or something similar ?

First correct that code, don’t just add the x values… And I don’t know what you mean by that sentence, you found out what? You set the linear velocity… why would it be anything you didn’t set.