Home › Forums › GAMES102 几何建模与处理 › 计算\cos(\theta)时,出现绝对值大于1的数 Tagged: 数值误差 This topic has 0 replies, 1 voice, and was last updated 4 years ago by Q. C. Viewing 0 reply threads Author Posts 2020年10月29日 at 下午8:42 #7258 Score: 0 Q. CParticipant 我在使用a.dot(b)/(a.norm()*b.norm())计算向量a和b的夹角余弦值时,发现有出现余弦值绝对值大于1的情况。 经过调试发现是由于norm()函数产生误差,使得 a.norm()*a.norm()与<a,a>的内积不相等。 所以应该如何正确使用norm()计算模长呢? 如图片所示,调试变量中 sqrt(dist(i-1))*sqrt(dist(i-1))与dist(i-1)存在较大误差,大到1e-5 Attachments:You must be logged in to view attached files. Author Posts Viewing 0 reply threads You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In