mrdja.geometry.get_best_plane_from_points_from_two_segments

mrdja.geometry.get_best_plane_from_points_from_two_segments(segment_1: ndarray, segment_2: ndarray) Tuple[ndarray, float][source]

Computes the best fitting plane to the four points of two segments.

Parameters:
  • segment_1 (np.ndarray) – The first segment.

  • segment_2 (np.ndarray) – The second segment.

Returns:

The best fitting plane and the sum of squared errors.

Return type:

Tuple[np.ndarray, float]

Example:

>>> import mrdja.geometry as geom
>>> import numpy as np
>>> segment_1 = np.array([[0, 0, 0], [1, 0, 0]])
>>> segment_2 = np.array([[0, 1, 0], [1, 1, 0]])
>>> geom.get_best_plane_from_points_from_two_segments(segment_1, segment_2)
(array([ 0.,  0.,  1., -0.]), 0.0)
>>> # another example
>>> segment_1 = np.array([[1, 2, 3], [4, 5, 6]])
>>> segment_2 = np.array([[7, 8, 9], [10, 11, 12]])
>>> geom.get_best_plane_from_points_from_two_segments(segment_1, segment_2)
(array([ 0.81649658, -0.40824829, -0.40824829,  1.22474487]),
1.0107280348144214e-29)
>>> # another example 
>>> segment_1 = np.array([[0, 0, 0], [1, 0, 0]])
>>> segment_2 = np.array([[0, 1, 0], [1, 1, 1]])
>>> geom.get_best_plane_from_points_from_two_segments(segment_1, segment_2)
(array([-0.45440135, -0.45440135,  0.76618459,  0.2628552 ]),
0.15692966918274637)