Order of rotation for MechJoint.rx,ry,rz 

I'm making two nuerons to enable flight, one a thruster and another a wing
shape. But to make this accurate i need to transform the axis's of the joint
to its rotation. so i know what direction of thrust i should aply it.
However order is important. If I rotate Z around the x before the y, I can
get diffeent results then if i rotate the around the y before the x. So i
would like to know what order its applyed in the program.

Also on that note what is a joints length axis? (debating about making the
thrust go along the stick instead of local z-axis)

This is such a fun program

Forums: 
Maciej Komosinski's picture

Dear Matthew,

> I'm making two nuerons to enable flight, one a thruster and another a wing
> shape. But to make this accurate i need to transform the axis's of the joint
> to its rotation. so i know what direction of thrust i should aply it.
> However order is important. If I rotate Z around the x before the y, I can
> get diffeent results then if i rotate the around the y before the x. So i
> would like to know what order its applyed in the program.

Currently, in FramScript you do not have access to all properties
required to properly make the thruster neuron. As thrust is on our
"to do" list, we decided to make it and it will be present in the next
Framsticks release.

Thanks,

MacKo

Maciej Komosinski wrote:
> Dear Matthew,
>
> Currently, in FramScript you do not have access to all properties
> required to properly make the thruster neuron. As thrust is on our
> "to do" list, we decided to make it and it will be present in the next
> Framsticks release.

Thank you for adding it. Though curious as to what i am missing to make it.

Cause i have it more or less working as long as you use small values of
thrust.

I responded whilst I was at work so here is my full nueron.
I can't see what i am missing (other then making some sort of max thrust
param and make it unchangeable via mutations)

I had to abandon the rotate thrust axis concept, was missing some rx, and
ry's for the joint. Was this what was unavailable?

So instead i used the part locations to determine the axis of thrust. This
is actually cheaper computationally. only one sqrt instead of 2 cos, and 2
sins.

For fun, here is a "lander" with its last thruster thrust messed up. its
kinda fun to watch.

(rrCCXCCXX[*][Thrust,-1:0.5],,rrCCXCCXX[*][Thrust,-1:0.5],,rrCCXCCXX[*][Thru
st,-1:-1])

and here is the nueron defination:

class:
name:Thrust
longname:Thruster(EXTREAMLY EXPERIMETAL!)
prefinputs:1
prefoutput:0
preflocation:2
code:~
function init() {}
function vnormalize(v){
var dist =
Math.sqrt(v.get(0)*v.get(0)+v.get(1)*v.get(1)+v.get(2)*v.get(2));
if (dist <= 0.0) {
Simulator.message("Thrust normlized is 0 or negative: "+dist,2);
return;
}
v.set(0,v.get(0)/dist);
v.set(1,v.get(1)/dist);
v.set(2,v.get(2)/dist);
}
function go()
{
var jointnum=n.j;
var cr=Neuro.creature;
var mj = cr.getMechJoint(jointnum);
var j = cr.getJoint(jointnum);
var mp1 = cr.getMechPart(j.p1);
var mp2 = cr.getMechPart(j.p2);
var tAxis= Vector.new();

//x axis Substraction method
tAxis.add(mp1.x-mp2.x);
tAxis.add(mp1.y-mp2.y);
tAxis.add(mp1.z-mp2.z);
//Simulator.message("["+jointnum+"]Begin vnormalize",0);
vnormalize(tAxis);
//Simulator.message("["+jointnum+"]Axis of thrust:
"+tAxis[0]+","+tAxis[1]+","+tAxis[2],0);
//Simulator.message("["+jointnum+"]Pos 1:
"+mp1.x+","+mp1.y+","+mp1.z,0);
//Simulator.message("["+jointnum+"]Pos 2:
"+mp2.x+","+mp2.y+","+mp2.z,0);

//SHould put a cap of 0.1 to 0.2 here
var thrust= (Neuro.weightedInputSum)/10.0;

//consume energy
cr.energy = cr.energy - cr.energy_m*thrust;

//get total mass thrusted
var tmass = mp1.m+mp2.m;
//Simulator.message("["+jointnum+"]Mass:
"+mp1.m+"+"+mp2.m+"="+tmass,0);

// convert thrust to velocity
thrust = thrust / tmass;

//apply thrust to part1
mp1.vx = mp1.vx + thrust*tAxis[0];
mp1.vy = mp1.vy + thrust*tAxis[1];
mp1.vz = mp1.vz + thrust*tAxis[2];

//apply thrust to part2
mp2.vx = mp2.vx + thrust*tAxis[0];
mp2.vy = mp2.vy + thrust*tAxis[1];
mp2.vz = mp2.vz + thrust*tAxis[2];
//Simulator.message("["+jointnum+"]Thrust: "+thrust,0);

//Simulator.message("["+jointnum+"]New Velocity1:
"+(mp1).vx+","+mp1.vy+","+mp1.vz,0);
//Simulator.message("["+jointnum+"]New Velocity2:
"+(mp2).vx+","+mp2.vy+","+mp2.vz,0);
}
~

Szymon Ulatowski's picture

Matthew Corey Brown wrote:

> I had to abandon the rotate thrust axis concept, was missing some rx, and
> ry's for the joint. Was this what was unavailable?
>
> So instead i used the part locations to determine the axis of thrust.
[...]

at first i thought you are going to attach the thrust neuron to the
creature's part. it would be impossible without knowing the part's
orientation.
the joint solution gives you one vector from the part locations (that
was clever ;-)) and as we all have seen :-) it is sufficient if we want
to apply the force along the stick axis.
the axis (stick) orientation could be calculated from the part's
orientation so all our problems are connected with the fact, that the
orientation is not accessible in framscript (but it will be in the next
release).

> For fun, here is a "lander" with its last thruster thrust messed up. its
> kinda fun to watch.
>
> (rrCCXCCXX[*][Thrust,-1:0.5],,rrCCXCCXX[*][Thrust,-1:0.5],,rrCCXCCXX[*][Thru
> st,-1:-1])

cool! :-)

sz.