|
From: Ron A. <rr...@ro...> - 2008-01-05 22:29:29
|
I want to add a vector in world relative coordinates to objects in a
rotated frame. It first needs to be translated to frame coordinates.
I can do this for single axis, but when the frame rotation involves
rotation of more than one axis, I can't seem to get it correct.
It would be nice to have these three functions ...
# The current world_space_function.
def frame_to_world_pos(pos, frame):
""" Frame position in world space coordinates. """
x_axis = norm(frame.axis)
z_axis = norm(cross(frame.axis, frame.up))
y_axis = norm(cross(z_axis, x_axis))
return frame.pos+pos.x*x_axis+pos.y*y_axis+pos.z*z_axis
def world_to_frame_pos(pos, frame):
""" World position in frame space coordinates. """
???
return frame_pos
def frame_to_frame_pos(pos, frame1, frame2):
""" Frame position in other frame space coordinates. """
wpos = frame_to_world_pos(pos, frame1)
return world_to_frame_pos(wpos, frame2)
Is there an easy way to move objects from frame to frame and keep their
orientation relative to world space?
Thanks, Ron
|