Ejemplo n.º 1
0
"""
3D Vector-Line Projection
=========================

Project a vector onto a line.

"""
from skspatial.objects import Vector, Line
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),
)
Ejemplo n.º 2
0
"""
Vector-Plane Projection
=======================

Project a vector onto a plane.

"""
from skspatial.objects import Plane
from skspatial.objects import Vector
from skspatial.plotting import plot_3d

plane = Plane([0, 0, 0], [0, 0, 1])
vector = Vector([1, 1, 1])

vector_projected = plane.project_vector(vector)

_, ax = plot_3d(
    plane.plotter(lims_x=(-5, 5), lims_y=(-5, 5), alpha=0.3),
    vector.plotter(point=plane.point, color='k'),
    vector_projected.plotter(point=plane.point,
                             color='r',
                             linewidth=2,
                             zorder=3),
)

ax.set_zlim([-1, 1])
Ejemplo n.º 3
0
"""
2D Vector-Vector Projection
===========================

Project a vector onto another vector.

"""
from skspatial.objects import Vector
from skspatial.plotting import plot_2d

vector_a = Vector([1, 1])
vector_b = Vector([2, 0])

vector_projected = vector_b.project_vector(vector_a)

_, ax = plot_2d(
    vector_a.plotter(color='k', head_width=0.1),
    vector_b.plotter(color='k', head_width=0.1),
    vector_projected.plotter(color='r', head_width=0.1),
)

ax.axis([-0.5, 2.5, -0.5, 1.5])