computational geometry - python implementation of 3D rigid body translation and rotation -
i've been trying work out how solve following problem using python:
- we have points a, b, c, d form rigid body
- some unknown 3d translation , rotation applied rigid body
- we know coordinates a, b, c
- we want calculate coordinates d
what know far:
- trying "straightforward" euler angle calculations seems bad idea due gimbal lock etc.
step 4 therefore involve transformation matrix, , once know rotation , translation matrix looks step easy using 1 of these:
what can't work out how can calculate rotation , translation matrices given "new" coordinates of a, b, c.
i can see in general case (non-rigid body) rotation part of wahba's problem, think rigid bodies there should faster way of calculating directly working out set of orthogonal unit vectors using points.
for set of corresponding points you're trying match (with possible perturbation) i've used svd (singular value decomposition), appears exist in numpy.
an example of technique (in python even) can found here, haven't evaluated correctness.
what you're going "basis transform" or "change of basis" represented transformation matrix. assuming 3 known points not collinear, can create initial basis by:
- computing vectors: x=(b-a) , y=(c-a)
- normalize x (x = x / magnitude(x))
- project y onto x (proj_y = x dot y * x)
- subtract projection y (y = y - proj_y)
- normalize y
- compute z = x cross y
that gives initial x,y,z coordinate basis a. same new points, , second basis b. want find transform t take point in , convert b (change of basis). part easy. can invert transform points normal basis, use b transform second one. since orthonormal, can transpose inverse. "new d" equal d * inverse(a) * b. (though depending on representation, may need use b * inverse(a) * d.)
you need have familiarity matrices that. representation of vectors , matrices inform order multiply matrices t (t either inverse(a)*b or b*inverse(a)).
to compute basis matrix vectors x=(x1,x2,x3), y=(y1,y2,y3), z=(z1,z2,z3) populate as:
| x1 y1 z1 | | x2 y2 z2 | | x3 y3 z3 |
Comments
Post a Comment