如何计算叉积? [英] How to compute the cross-product?

查看:135
本文介绍了如何计算叉积?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下一段伪C/Java/C#代码:

I have the following piece of pseudo-C/Java/C# code:

int a[]= { 30, 20 };
int b[] = { 40, 50 };
int c[] = {12, 12};

如何计算叉积ABxAC?

How do I compute the cross-product ABxAC?

推荐答案

上一个问题中给您的解决方案基本上为所有点添加了Z = 0.在如此扩展的向量上,您可以计算出叉积.在几何上,叉积产生的向量与用于计算的两个向量正交,因为这两个向量都位于XY平面中,因此结果将仅包含Z分量. z分量的符号表示矢量在XY平面上向上还是向下查找.该符号取决于AB彼此以顺时针或逆时针顺序排列.反过来,这意味着z分量的符号会向您显示您所看的点是位于AB上线的左侧还是右侧.

The solution that was given to you in your last question basically adds a Z=0 for all your points. Over the so extended vectors you calculate your cross product. Geometrically the cross product produces a vector that is orthogonal to the two vectors used for the calculation, as both of your vectors lie in the XY plane the result will only have a Z component. The Sign of that z component denotes wether that vector is looking up or down on the XY plane. That sign is dependend on AB being in clockwise or counter clockwise order from each other. That in turn means that the sign of z component shows you if the point you are looking at lies to the left or the right of the line that is on AB.

所以两个向量A和B的叉积是 vector

So with the crossproduct of two vectors A and B being the vector

AxB = (AyBz − AzBy, AzBx − AxBz, AxBy − AyBx)

Az和Bz为零,则剩下该向量的第三部分

with Az and Bz being zero you are left with the third component of that vector

AxBy - AyBx

其中A是从点a到b的向量,而B是从点a到c的向量意味着

With A being the vector from point a to b, and B being the vector from point a to c means

Ax = (b[x]-a[x])
Ay = (b[y]-a[y])
Bx = (c[x]-a[x])
By = (c[y]-a[y])

给予

AxBy - AyBx = (b[x]-a[x])*(c[y]-a[y])-(b[y]-a[y])*(c[x]-a[x])

这是一个标量,该标量的符号会告诉您c点位于矢量ab的左侧还是右侧

which is a scalar, the sign of that scalar will tell you wether point c lies to the left or right of vector ab

或者,您可以查看堆栈溢出 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆