题目
给定一个数组 points ,其中 points[i] = [xi, yi] 表示 X-Y 平面上的一个点,如果这些点构成一个 回旋镖 则返回 true 。
回旋镖 定义为一组三个点,这些点 各不相同 且 不在一条直线上 。
来源:力扣(LeetCode)
链接:https://leetcode.cn/problems/valid-boomerang
向量叉乘

代码
class Solution {
public boolean isBoomerang(int[][] points) {
// 向量叉乘
return (points[0][0] - points[1][0]) * (points[1][1] - points[2][1]) - (points[0][1] - points[1][1]) * (points[1][0] - points[2][0]) != 0;
}
}
本文介绍了一种通过向量叉乘来判断三点是否构成回旋镖的有效算法。回旋镖由三个不同点组成,这些点不在同一直线上。通过简单的数学运算实现,适用于计算机图形学与算法竞赛等领域。
365

被折叠的 条评论
为什么被折叠?



