c++ - 共线点

标签 c++ c vector

如果我有 a、b、c 点和 x、y 的 vector 形式,那么我如何找到共线点..

fabs((b.x_-a.x_)*(c.y_-a.y_)-(c.x_-a.x_)*(b.y_-a.y_) 像这样使用..怎么会这样?

最佳答案

差异为您提供了从 a 到 b 和 a 到 c 的内部 vector 。

然后乘法表示这两个 vector 之间的叉积。 叉积与这两个 vector 之间夹角的正弦成正比。 当点共线时,这两个 vector 之间的正弦为零。

您的特定公式是更传统的 3d 叉积的 2d 收缩。 请参阅:http://en.wikipedia.org/wiki/Cross_product

关于c++ - 共线点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4083807/

相关文章:

c++ - 是 "long long"= "long long int"= "long int long"= "int long long"吗?

OpenGL 模型 View 矩阵 4x4 的紧凑表示

可以在标准 C 中处理中断吗?

c++ - 如何从其他结构访问 protected 结构变量

c - Realloc:结构动态 vector 中的下一个大小无效

c++ - 在 const ref 类型参数上使用临时对象时,编译器是否应该警告不安全行为?

c++ - 如何从我正在阅读的文件中删除所有标点符号?

c++ - 如何从文件中读取 unsigned short?

使用 stdprn 时出现 C 编译错误

c++ - vector::erase with pointer 成员