Okay, I’ve been turning the rusty cogs of my A level Maths experience, but I cannot get this to work…
I have two points:
var N_Ix
var N_Iy
var N_Iz
var N_Jx
var N_Jy
var N_Jz
And I’ve managed to get the required length by doing:
var memberLength:Number = Math.sqrt((deltaX * deltaX) + (deltaY * deltaY) + (deltaZ * deltaZ));
And positioned the beam (a cube with height = memberLength) in the middle of the two points like so:
//These need to be put midway between the two nodes.
member.x = N_Ix - (deltaX/2);
member.y = N_Iy - (deltaY/2);
member.z = N_Iz - (deltaZ/2);
(I’m not quite sure why I’m subracting half the difference from what I thought was the starting point inds the mid point, I guess I have the points the wrong way round in my mind…)
But now am tearing my hair out trying to apply trigonometry to those 3d points.
In my mind, I’m thinking to just do it in two steps, to find the Z rotation, just taking into account the deltas on the x,y plane, and then find the X rotation by just taking into account the deltas on the y,z plane…
member.rotationZ = Math.atan(deltaY/deltaX)/(Math.PI/180);
member.rotationX = Math.atan(deltaY/deltaZ)/(Math.PI/180);
Buut, after doing that, and converting the result into degrees, I’m still not getting it…
Stumped…