You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/__test__/Geometry/angleTo.test.ts

48 lines
1.3 KiB

import { angleTo } from '../../src/Geometry/GeUtils';
import { Vector3 } from "three";
test('俯视图', () =>
{
//逆时针
let v = angleTo(new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1)); //?
expect(v).toEqual(Math.PI * 0.5);
//顺时针
let v2 = angleTo(new Vector3(0, 1, 0), new Vector3(1, 0, 0), new Vector3(0, 0, 1)); //?
expect(v2).toEqual(Math.PI * -0.5);
});
test('仰视', () =>
{
//顺时针
let v = angleTo(new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, -1)); //?
expect(v).toEqual(Math.PI * -0.5);
});
test('右视图', () =>
{
let v = angleTo(new Vector3(0, 0, 1), new Vector3(0, 1, 0), new Vector3(1, 0, 0)); //?
expect(v).toEqual(Math.PI * -0.5);
v = angleTo(new Vector3(0, 1, 0), new Vector3(0, 0, 1), new Vector3(1, 0, 0)); //?
expect(v).toEqual(Math.PI * 0.5);
});
test('0向量', () =>
{
let v = angleTo(new Vector3(1, 0, 0), new Vector3(0, 0, 1), new Vector3(1, 0, 0)); //?
expect(v).toEqual(0);
});
test('变量补全', () =>
{
let v = angleTo(new Vector3(1, 0, 0), new Vector3(0, 0, 1)); //?
expect(v).toEqual(Math.PI * 0.5);
});
test('几乎平行的2向量', () =>
{
let v1 = new Vector3(1);
let v2 = new Vector3(-1, 1.2246467991473532e-16, 5.041544910049491e-16);
let v = angleTo(v1, v2); //?
expect(v).toEqual(0);
});