2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
|
id: 594810f028c0303b75339ad2
|
2020-12-16 00:37:30 -07:00
|
|
|
|
title: 矢量交叉产品
|
2018-10-10 18:03:03 -04:00
|
|
|
|
challengeType: 5
|
|
|
|
|
|
videoUrl: ''
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --description--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
矢量被定义为具有三个维度,由三个数字的有序集合表示:(X,Y,Z)。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
任务:
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
```
|
|
|
|
|
|
Write a function that takes two vectors (arrays) as input and computes their cross product.
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```
|
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
您的函数应在无效输入(即不同长度的向量)上返回`null` 。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --hints--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
dotProduct必须是一个函数
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
|
```js
|
2020-12-16 00:37:30 -07:00
|
|
|
|
assert.equal(typeof crossProduct, 'function');
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```
|
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
dotProduct()必须返回null
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
|
```js
|
2020-12-16 00:37:30 -07:00
|
|
|
|
assert.equal(crossProduct(), null);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```
|
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
crossProduct([1,2,3],[4,5,6])必须返回[-3,6,-3]。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
|
```js
|
2020-12-16 00:37:30 -07:00
|
|
|
|
assert.deepEqual(res12, exp12);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --solutions--
|
|
|
|
|
|
|