计算两个向量的夹角

有方向:

E:\graduate_two\zy_evaluation_8gray\01Algorithm\cornerity

function [ output_args ] = theta_direction( input_args )
calculate_theta(0,0,1,-1,-1,-1)

function [theta] = calculate_theta(x1,y1,x2,y2,x3,y3)
xf=x2-x1;
yf=y2-y1;

xb=x3-x1;
yb=y3-y1;

A=[xf,yf];
B=[xb,yb];

D=dot(A,B);
N=norm(A)norm(B);
rho=xf
yb-xbyf; %%%%%根据正负判断方向 12 —>13 逆时针
ptheta=acos(D/N)/pi
180;

if rho<0
theta= 180+ptheta;
else
theta=ptheta;
end

无方向:

https://www.cnblogs.com/lovebay/p/11411512.html
%计算夹角:计算以x1为顶点的两个向量的夹角
function [theta] = calculate_theta(x1,y1,x2,y2,x3,y3)
vector1 = [x2,y2,0] - [x1,y1,0];
vector2 = [x3,y3,0] - [x1,y1,0];
theta = atan2d(norm(cross(vector1, vector2)), dot(vector1, vector2));

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值