@medeek I am not sure what the goal is here, but when I use your code with inputs of [1,0,0] and [5,3,2], then apply the resulting tot_trans to [1,0,0], I get a result of [0.742781, 0.8557086, 0.371391] which is neither the second vector, not any multiple of it (i.e. it does not lie along [5,3,2])
The following method however works for any two input vectors (with credit to @eneroth3 for her planar_angle method which I incorporated):
def find_rot_trans (vec1, vec2)
norm = (vec1 * vec2).normalize
rot_angle = Math.atan2((vec1 * vec2) % norm, vec1 % vec2)
tr = Geom::Transformation.rotation(ORIGIN, norm, rot_angle)
A test for this method is:
def test_rotation (vec1, vec2)
tr = find_rot_trans vec1, vec2 # Find rotation transformation
vec3 = vec1.transform tr # Test by applying to 'vec1'
if vec3.samedirection? vec2
puts "This works!" # Resulting transformed vector is parallel to original 'vec2'
puts "This did NOT work"
There is a possibility I misinterpreted your problem, in which case it would be great if you express it as a test method as I have done.