Skip to content

Commit 37dfbb2

Browse files
authored
Merge pull request #6 from Mexicoco/fix/cross-product-formula
fix: correct 2D cross product formula
2 parents 48f15d1 + ebeb914 commit 37dfbb2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/utils/MathUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const lerp = mix;
5656
* @param p2y 第二个向量的y分量
5757
* @returns 叉积结果 (标量)
5858
* @example
59-
* cross(1, 0, 0, 1) // 返回 0
59+
* cross(1, 0, 0, 1) // 返回 1
6060
*/
6161
export function cross(
6262
p1x: number,
@@ -68,7 +68,7 @@ export function cross(
6868
if (!isNumber(p1x) || !isNumber(p1y) || !isNumber(p2x) || !isNumber(p2y)) {
6969
throw new Error("Invalid parameters for cross function");
7070
}
71-
return p1x * p2x - p1y * p2y;
71+
return p1x * p2y - p1y * p2x;
7272
} catch (error) {
7373
console.error("Error in cross function:", error);
7474
return 0;

0 commit comments

Comments
 (0)