Moving along another object's local coordinates

Hey fellow Blenderheads…

I was wondering whether it’s possible to move an object along a different object’s local coordinates, both in Blender and in the Game Engine (using python if necessary). I’m essentially trying to move a sphere in the direction that arrow-shaped object is pointing, with the user moving the sphere forwards with “upkey” and rotating the arrow with “leftkey” and “rightkey.” Maybe I could track the arrow’s rotational movement to a property or something like that?

Happy Blendering!!!

Musicaljelly

Yes it is possible.

First you have to get the Orientation of the object and use your calculus skills to extract the 3 rotation values out of a matrix. Once you have the radians for all three axises convert the radian to tan (slop) and manipulate the slop as you see fit.

lol. Those aren’t calculus skills. I had to do that in 8th grade in IMP

lol, what, calculating the height of a ladder if it makes a 60 degrees angle with a 5m tall building?

lol. Those aren’t calculus skills. I had to do that in 8th grade in IMP
Right

What I was referring to was that you would need to get the Orientation (3X3 matrix) and convert it to Euler angles like so:


def getEulerAngles(matrix):
    rotation = [0,0,0]
    rotation[0] = atan2(-matrix[1][2],matrix[1][1])
    rotation[1] = asin(matrix[1][0])
    rotation[2] = atan2(-matrix[2][0],matrix[0][0])
    return rotation

Then convert the returned Euler angles (which are returned as radians) to tan and get the hyperbola from the tan angles. Next, divide the distance you want to move on an axis from the hyperbola . The value dist/hyperbola should then be multiplied by the tan. If done correctly with all three axises, you will get the new x,y,z position based on the Orientation.

If were both thinking of the same thing, I seriously doubt that you would learn something like this is 8th grade. Perhaps you learned a simple 2d concept of this idea in grade school , but don’t forget that this is 3D. If you do not account the 3th axis, you will get gimbol lock and many other troublesome problems and errors.

musicaijelly: if the “mathematical” ways seems too complex, you could just set the Orientation equal to the Orientation of the other object. Then use a motion actor to move along the local axis. Once the object is moved, you could set your object back to it’s original Orientation stored in memory.

If were both thinking of the same thing

I wasn’t thinking the same thing, I was mocking him :wink:

I wasn’t thinking the same thing, I was mocking him :wink:

lol, I know. That wasn’t directed towards you.

Oops, my bad

ya. we didn’t do anything even close to that complicated. All we did was convert coordinates and crap into matrices and get them from matrices. lol