def project_point_line_xy(point, line): """Project a point onto a line in the XY plane. Parameters ---------- point : list of float XY(Z) coordinates of the point. line : tuple Two points defining the projection line. Returns ------- list XYZ coordinates of the projected point, with Z=0. Notes ----- For more info, see [1]_. References ---------- .. [1] Wiki Books. *Linear Algebra/Orthogonal Projection Onto a Line*. Available at: https://en.wikibooks.org/wiki/Linear_Algebra/Orthogonal_Projection_Onto_a_Line. """ a, b = line ab = subtract_vectors_xy(b, a) ap = subtract_vectors_xy(point, a) c = vector_component_xy(ap, ab) return add_vectors_xy(a, c)
def mirror_point_point_xy(point, mirror): """Mirror a point about a point. Parameters: point (sequence of float): XY coordinates of the point to mirror. mirror (sequence of float): XY coordinates of the mirror point. """ return add_vectors_xy(mirror, subtract_vectors_xy(mirror, point))
def mirror_point_point_xy(point, mirror): """Mirror a point about a point. Parameters ---------- point : list of float XY(Z) coordinates of the point to mirror. mirror : list of float XY(Z) coordinates of the mirror point. Returns ------- list of float The mirrored point, with Z=0. """ return add_vectors_xy(mirror, subtract_vectors_xy(mirror, point))
def mirror_point_line_xy(point, line): """Mirror a point about a line. Parameters ---------- point : list of float XY(Z) coordinates of the point to mirror. line : tuple Two points defining the line. XY(Z) coordinates of the two points defining the mirror line. Returns ------- list of float The mirrored point, with Z=0. """ closest = closest_point_on_line_xy(point, line) return add_vectors_xy(closest, subtract_vectors_xy(closest, point))
def project_point_line_xy(point, line): """Project a point onto a line. Parameters: point (sequence of float): XY coordinates. line (tuple): Two points defining a line. Returns: list: XY coordinates of the projected point. References: https://en.wikibooks.org/wiki/Linear_Algebra/Orthogonal_Projection_Onto_a_Line """ a, b = line ab = subtract_vectors_xy(b, a) ap = subtract_vectors_xy(point, a) c = vector_component_xy(ap, ab) return add_vectors_xy(a, c)
def closest_point_on_line_xy(point, line): """Compute closest point on line (continuous) to a given point lying in the XY-plane. Parameters ---------- point : sequence of float XY(Z) coordinates of a point. line : tuple Two XY(Z) points defining a line. Returns ------- list XYZ coordinates of closest point (Z = 0.0). """ a, b = line ab = subtract_vectors_xy(b, a) ap = subtract_vectors_xy(point, a) c = vector_component_xy(ap, ab) return add_vectors_xy(a, c)
def translate_points_xy(points, vector): """Translate points and in the XY plane. Parameters ---------- points : list of point A list of points. vector : vector A translation vector. Returns ------- list of point The translated points in the XY plane (Z=0). Examples -------- >>> """ return [add_vectors_xy(point, vector) for point in points]
def translate_points_xy(points, vector): return [add_vectors_xy(point, vector) for point in points]