def represent_in_local_coordinates(self, point): """Represents a point in the frame's local coordinate system. Parameters ---------- point : :obj:`list` of :obj:`float` A point in world XY. Returns ------- :obj:`list` of :obj:`float` A point in the local coordinate system of the frame. Examples -------- >>> f = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15]) >>> pw1 = [2, 2, 2] >>> pf = f.represent_in_local_coordinates(pw1) >>> pw2 = f.represent_in_global_coordinates(pf) >>> allclose(pw1, pw2) True """ pt = Point(*subtract_vectors(point, self.point)) T = inverse(matrix_from_basis_vectors(self.xaxis, self.yaxis)) pt.transform(T) return pt
def represent_in_global_coordinates(self, point): """Represents a point from local coordinates in the world coordinate system. Parameters ---------- point : :obj:`list` of :obj:`float` A point in local coordinates. Returns ------- :obj:`list` of :obj:`float` A point in the world coordinate system. Examples -------- >>> f = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15]) >>> pw1 = [2, 2, 2] >>> pf = f.represent_in_local_coordinates(pw1) >>> pw2 = f.represent_in_global_coordinates(pf) >>> allclose(pw1, pw2) True """ T = matrix_from_frame(self) pt = Point(*point) pt.transform(T) return pt
f = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15]) T = Transformation.from_frame(f) Tinv = T.inverse() I = Transformation() print(I == T * Tinv) f1 = Frame([2, 2, 2], [0.12, 0.58, 0.81], [-0.80, 0.53, -0.26]) f2 = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15]) T = Transformation.from_frame_to_frame(f1, f2) f1.transform(T) print(f1 == f2) f = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15]) T = Transformation.from_frame(f) p = Point(0, 0, 0) p.transform(T) print(allclose(f.point, p)) f1 = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15]) T = Transformation.from_frame(f1) points = [[1.0, 1.0, 1.0], [1.68, 1.68, 1.27], [0.33, 1.73, 0.85]] points = transform_points(points, T) trans1 = [1, 2, 3] angle1 = [-2.142, 1.141, -0.142] scale1 = [0.123, 2, 0.5] T = matrix_from_translation(trans1) R = matrix_from_euler_angles(angle1) S = matrix_from_scale_factors(scale1) M = multiply_matrices(multiply_matrices(T, R), S) # M = compose_matrix(scale1, None, angle1, trans1, None)