利用python计算两点构成的方向向量

calVectorFrom2Points

功能

利用空间两点坐标计算该直线的方向向量 s ( m , n , p ) s(m,n,p) s(m,n,p)

原理

如图所示,空间任意两点 P o i n t 1 ( x 1 , y 1 , z 1 ) Point_{1}(x_1,y_1,z_1) Point1(x1,y1,z1) P o i n t 2 ( x 2 , y 2 , z 2 ) Point_{2}(x_2,y_2,z_2) Point2(x2,y2,z2)

https://gitee.com/zhaoqiushan/pic/raw/master/422b4a043c61013b3f03b5c4b20539a.png

根据上图可知空间直线的方向向量 s s s可由空间两点做差值获得:
s ⃗ = P o i n t 1 − P o i n t 2 = ( x 1 − x 2 , y 1 − y 2 , z 1 − z 2 ) \vec{s}=Point_{1}-Point_{2}=(x_1-x_2,y_1-y_2,z_1-z_2) s =Point1Point2=(x1x2,y1y2,z1z2)

使用

输入

空间任意两点坐标 P o i n t 1 ( x 1 , y 1 , z 1 ) Point_{1}(x_1,y_1,z_1) Point1(x1,y1,z1) P o i n t 2 ( x 2 , y 2 , z 2 ) Point_{2}(x_2,y_2,z_2) Point2(x2,y2,z2)

输出

上述两点所在直线的方向向量 s ( m , n , p ) s(m,n,p) s(m,n,p)

DEMO

import geomeas as gm
import numpy as npPoint_1 = np.array([227.15, 174.45, 0])
Point_2 = np.array([-108.45, 251.72, 0])print(gm.Vector().calVectorFrom2Points(Point_1, Point_2))

代码链接


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部