def get_placement_score(reference_rb, rb): reference_centroid = reference_rb.get_coordinates() centroid = rb.get_coordinates() translation_vector = reference_centroid - centroid distance = translation_vector.get_magnitude() ref_coords = [m.get_coordinates() for m in reference_rb.get_members()] coords = [m.get_coordinates() for m in rb.get_members()] if(len(ref_coords) != len(coords) ): raise ValueError( "Mismatch in the number of members: reference model %d, " \ "model to measure %d " % (len(ref_coords), len(coords)) ) TT = alg.get_transformation_aligning_first_to_second(coords, ref_coords) P = alg.get_axis_and_angle( TT.get_rotation() ) angle = P.second return distance, angle
def get_placement_score_from_coordinates(model_coords, native_coords): """ Computes the position error (placement distance) and the orientation error (placement angle) of the coordinates in model_coords respect to the coordinates in native_coords. placement distance - translation between the centroids of the coordinates placement angle - Angle in the axis-angle formulation of the rotation aligning the two rigid bodies. """ native_centroid = alg.get_centroid(native_coords) model_centroid = alg.get_centroid(model_coords) translation_vector = native_centroid - model_centroid distance = translation_vector.get_magnitude() if (len(model_coords) != len(native_coords)): raise ValueError("Mismatch in the number of members %d %d " % (len(model_coords), len(native_coords))) TT = alg.get_transformation_aligning_first_to_second( model_coords, native_coords) P = alg.get_axis_and_angle(TT.get_rotation()) angle = P.second return distance, angle
def get_placement_score_from_coordinates(model_coords, native_coords): """ Computes the position error (placement distance) and the orientation error (placement angle) of the coordinates in model_coords respect to the coordinates in native_coords. placement distance - translation between the centroids of the coordinates placement angle - Angle in the axis-angle formulation of the rotation aligning the two rigid bodies. """ native_centroid = alg.get_centroid(native_coords) model_centroid = alg.get_centroid(model_coords) translation_vector = native_centroid - model_centroid distance = translation_vector.get_magnitude() if(len(model_coords) != len(native_coords)): raise ValueError( "Mismatch in the number of members %d %d " % ( len(model_coords), len(native_coords))) TT = alg.get_transformation_aligning_first_to_second(model_coords, native_coords) P = alg.get_axis_and_angle(TT.get_rotation()) angle = P.second return distance, angle