def compute_reflection_plane(plane: Plane, ray: Ray) -> Ray:
    all_intersections = ray.intersection(plane)
    if len(all_intersections) != 1:
        return None
    intersection = all_intersections[0]
    orig_point = ray.p1
    parallel = plane.parallel_plane(orig_point)
    perpendicular = plane.perpendicular_line(intersection)
    meet_point = parallel.intersection(perpendicular)[0]
    x_diff = (meet_point.x - orig_point.x)
    y_diff = (meet_point.y - orig_point.y)
    new_point = Point(meet_point.x + x_diff, meet_point.y + y_diff)
    new_point = Point(orig_point.x,
                      intersection.y + (intersection.y - orig_point.y),
                      intersection.z + (intersection.z - orig_point.z))
    reflected_ray = Ray(intersection, new_point)
    return reflected_ray
Exemplo n.º 2
0
    return float(ag)


toArray = lambda x: np.array(x).astype(float)


def degreeOfVictor(p1, p2):
    p1, p2 = map(toArray, (p1, p2))
    dotProduct = (p1 * p2).sum()
    norm = lambda p: (p**2).sum()**0.5
    angle = dotProduct / (norm(p1) * norm(p2))
    arccosDegree = lambda x: np.degrees(np.arccos(x))
    degree = arccosDegree(angle)
    return degree


#%%
if __name__ == '__main__':
    po = Point3D(0, 0, 0)
    #    print fitPointsToPlane(points)
    a.distance(po)

    l = Line3D((0, 0, 0), (1, 0, 0))
    l2 = Line3D((0, 1, 0), (0, 1, 1))

    a = Plane(Point3D(1, 1, 1), normal_vector=(1, 1, 1))
    b = a.perpendicular_line(Point3D(0, 0, 0))
    points = (1, 0, 0), (0, 1, 0), (0, 0, 1), (0.1, 0.1, 0.1)

    a.distance(Point3D(0, 0, 0))
    pass