如何计算形成闭合/开放形状的两个方向矢量之间的角度?(How to calculate angle between two direction vectors that form a closed/o

编程入门 行业动态 更新时间:2024-10-12 05:52:20
如何计算形成闭合/开放形状的两个方向矢量之间的角度?(How to calculate angle between two direction vectors that form a closed/open shape?)

我想弄清楚正确的触发。 eq./function确定以下内容: 两个方向向量 (已确定) 之间角度变化(单位为DEGREES) ,表示两条线段。 这用于SHAPE RECOGTNITION(由用户在屏幕上手绘)的上下文中。

基本上,

a)如果用户绘制(粗糙)形状,例如圆形,椭圆形或矩形等,组成该形状的线条被细分为20点(xy对)。

b)我有这些线段的每一个的DirectionVector。

c)所以开始一个LINE SEGMENT(x0,y0),就是前一行的END点(以形成一个像矩形的闭合形状,比方说)。

那么,我的问题是,给定上下文(即确定多边形的类型), 如何找到两个DIRECTION VECTORS之间的角度变化(可用作x和y的两个浮点值)?

我见过很多不同的触发器。 方程式,我正在寻求澄清。

非常感谢大家!

I am trying to figure out the correct trig. eq./function to determine the following: The Angle-change (in DEGREES) between two DIRECTION VECTORS(already determined), that represent two line-segment. This is used in the context of SHAPE RECOGTNITION (hand drawn by user on screen).

SO basically,

a) if the user draws a (rough) shape, such as a circle, or oval, or rectangle etc - the lines that makes up that shape are broken down in to say.. 20 points(x-y pairs).

b) I have the DirectionVector for each of these LINE SEGMENTS.

c) So the BEGINNING of a LINE SEGMENT(x0,y0), will the END points of the previous line(so as to form a closed shape like a rectangle, let's say).

SO, my question is , given the context(i.e. determinign the type of a polygon), how does one find the angle-change between two DIRECTION VECTORS(available as two floating point values for x and y) ???

I have seen so many different trig. equations and I'm seeking clarity on this.

Thanks so much in advance folks!

最满意答案

如果(x1,y1)是第一个方向向量而(x2,y2)是第二个方向向量,则它成立:

cos(alpha)=(x1 * x2 + y1 * y2)/(sqrt(x1 * x1 + y1 * y1)* sqrt(x2 * x2 + y2 * y2))

sqrt表示平方根。

查看http://en.wikipedia.org/wiki/Dot_product

特别是“几何表示”一节。

If (x1,y1) is the first direction vector and (x2,y2) is the second one, it holds:

cos( alpha ) = (x1 * x2 + y1 * y2) / ( sqrt(x1*x1 + y1*y1) * sqrt(x2*x2 + y2*y2) )

sqrt means the square root.

Look up http://en.wikipedia.org/wiki/Dot_product

Especially the section "Geometric Representation".

更多推荐

本文发布于:2023-08-05 17:12:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1437215.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:矢量   形状   角度   方向   两个

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!