3D Vector-Line ProjectionΒΆ

Project a vector onto a line.

plot vector line

Out:

(<Figure size 640x480 with 1 Axes>, <Axes3DSubplot:>)

from skspatial.objects import Line, Vector
from skspatial.plotting import plot_3d


line = Line([0, 0, 0], [1, 1, 2])
vector = Vector([1, 1, 0.1])

vector_projected = line.project_vector(vector)


plot_3d(
    line.plotter(t_1=-1, c='k', linestyle='--'),
    vector.plotter(point=line.point, color='k'),
    vector_projected.plotter(point=line.point, color='r', linewidth=2, zorder=3),
)

Total running time of the script: ( 0 minutes 0.149 seconds)

Gallery generated by Sphinx-Gallery