Drawing Module

This module contains functions for drawing 3D objects using matplotlib.

draw_cube(cube_min, cube_max[, color, alpha, ax])

Draws a cube in 3D space using matplotlib.

draw_face_of_cube(plane, cube_min, cube_max)

Draws a plane in 3D space using matplotlib.

draw_line_extension_to_plane(line, plane[, ax])

Draws a line in 3D space, and the intersection point of the line and the plane, but this does not draw the plane.

draw_plane_as_lines_open3d(A, B, C, D[, ...])

drawing.draw_cube(cube_min: ndarray, cube_max: ndarray, color: str = 'red', alpha: float = 0.5, ax=None)[source]

Draws a cube in 3D space using matplotlib.

Parameters:
  • cube_min (numpy.ndarray) – A 3x1 numpy array containing the minimum x, y, and z values of the cube.

  • cube_max (numpy.ndarray) – A 3x1 numpy array containing the maximum x, y, and z values of the cube.

  • color (str) – The color of the cube.

  • alpha (float) – The transparency of the cube.

Returns:

None

Return type:

None

Example:

>>> import rsaitehu.drawing as drawing
>>> import numpy as np
>>> cube_min = np.array([-2, -2, -1])
>>> cube_max = np.array([1, 2, 2])
>>> drawing.draw_cube(cube_min, cube_max, color="red", alpha=0.5)

drawing_draw_cube_example

drawing.draw_face_of_cube(plane: ndarray, cube_min: ndarray, cube_max: ndarray, color: str = 'red', alpha: float = 0.5, ax=None)[source]

Draws a plane in 3D space using matplotlib.

Parameters:
  • plane (numpy.ndarray) – A 4x1 numpy array containing the coefficients of the plane corresponding to the face.

  • cube_min (numpy.ndarray) – A 3x1 numpy array containing the minimum x, y, and z values of the cube.

  • cube_max (numpy.ndarray) – A 3x1 numpy array containing the maximum x, y, and z values of the cube.

  • color (str) – The color of the plane.

  • alpha (float) – The transparency of the plane.

  • ax (matplotlib.axes.Axes3D) – The matplotlib axis to draw on.

Returns:

None

Return type:

None

drawing.draw_line_extension_to_plane(line: ndarray, plane: ndarray, ax=None)[source]

Draws a line in 3D space, and the intersection point of the line and the plane, but this does not draw the plane.

Parameters:
  • line (numpy.ndarray) – A 2x3 numpy array containing the endpoints of the line.

  • plane (numpy.ndarray) – A 4x1 numpy array containing the coefficients of the plane.

Returns:

None

Return type:

None

Example:

>>> import rsaitehu.geometry as geom
>>> import numpy as np 
>>> import rsaitehu.drawing as drawing
>>> import matplotlib.pyplot as plt
>>> line = np.array([[0, 0, 0], [1, 1, 1]])
>>> plane = np.array([0, 0, 1, -3])
>>> intersection_point = geom.get_intersection_point_of_line_with_plane(line, plane)
>>> intersection_point
array([3., 3., 3.])
>>> fig = plt.figure()
>>> ax = fig.add_subplot(111, projection='3d')
>>> drawing.draw_line_extension_to_plane(line, plane, ax)
>>> 
>>> drawing.draw_line_extension_to_plane(line, plane)

drawing_draw_line_extension_to_plane_example