@ue-too/math 0.5.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/{.rollup.cache/home/runner/work/ue-too/ue-too/packages/math/dist/index.d.ts → index.d.ts} +15 -0
- package/{dist/index.js → index.js} +46 -1
- package/index.js.map +1 -0
- package/math.tsbuildinfo +1 -0
- package/package.json +8 -9
- package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/math/dist/index.js +0 -128
- package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/math/dist/index.js.map +0 -1
- package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/math/dist/math.tsbuildinfo +0 -1
- package/dist/index.d.ts +0 -34
- package/dist/index.js.map +0 -1
- package/dist/math.tsbuildinfo +0 -1
- package/dist/package.json +0 -27
- package/jest.config.js +0 -18
- package/project.json +0 -30
- package/rollup.config.js +0 -20
- package/scripts/move-package.mjs +0 -52
- package/src/index.ts +0 -147
- package/test/index.test.ts +0 -100
- package/tsconfig.json +0 -13
- package/tsconfig.spec.json +0 -12
package/test/index.test.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import * as Point2Point from "../src/index";
|
|
2
|
-
|
|
3
|
-
describe("Point to Point operations", () => {
|
|
4
|
-
|
|
5
|
-
test("Check if two points have the same values", ()=>{
|
|
6
|
-
expect(Point2Point.PointCal.isEqual({x: 1, y: 2}, {x: 1, y: 2})).toBe(true);
|
|
7
|
-
expect(Point2Point.PointCal.isEqual({x: 1, y: 2, z: 1}, {x: 1, y: 2})).toBe(false);
|
|
8
|
-
expect(Point2Point.PointCal.isEqual({x: 1, y: 2}, {x: 1, y: 3})).toBe(false);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test("Addition", () => {
|
|
12
|
-
expect(Point2Point.PointCal.addVector({x: 1, y: 2}, {x: 3, y: 4})).toEqual(expect.objectContaining({x: 4, y: 6}))
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test("Subtraction", () => {
|
|
16
|
-
expect(Point2Point.PointCal.subVector({x: 1, y: 2}, {x: 3, y: 4})).toEqual(expect.objectContaining({x: -2, y: -2}))
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test("Scalar Multiplication", () => {
|
|
20
|
-
expect(Point2Point.PointCal.multiplyVectorByScalar({x: 1, y: 2}, 3)).toEqual(expect.objectContaining({x: 3, y: 6}))
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("Scalar Division", () => {
|
|
24
|
-
expect(Point2Point.PointCal.divideVectorByScalar({x: 1, y: 2}, 3)).toEqual(expect.objectContaining({x: 0.3333333333333333, y: 0.6666666666666666}))
|
|
25
|
-
expect(Point2Point.PointCal.divideVectorByScalar({x: 1, y: 2}, 0)).toEqual(expect.objectContaining({x: 1, y: 2}))
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test("Magnitude of a point", () => {
|
|
29
|
-
expect(Point2Point.PointCal.magnitude({x: 1, y: 2})).toBe(Math.sqrt(5))
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("Unit Vector", () => {
|
|
33
|
-
expect(Point2Point.PointCal.unitVector({x: 1, y: 2})).toEqual(expect.objectContaining({x: 0.4472135954999579, y: 0.8944271909999159}))
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test("Unit Vector with 0 magnitude", () => {
|
|
37
|
-
expect(Point2Point.PointCal.unitVector({x: 0, y: 0})).toEqual(expect.objectContaining({x: 0, y: 0}));
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test("Dot Product", () => {
|
|
41
|
-
expect(Point2Point.PointCal.dotProduct({x: 1, y: 2}, {x: 3, y: 4})).toBe(11)
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test("Cross Product", () => {
|
|
45
|
-
expect(Point2Point.PointCal.crossProduct({x: 1, y: 2}, {x: 3, y: 4})).toEqual(expect.objectContaining({x: 0, y: 0, z: -2}))
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test("Angle From A to B", () => {
|
|
49
|
-
expect(Point2Point.PointCal.angleFromA2B({x: 1, y: 0}, {x: 0, y: 1})).toBe(Math.PI / 2)
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test("Unit Vector From A to B", () => {
|
|
53
|
-
expect(Point2Point.PointCal.unitVectorFromA2B({x: 1, y: 0}, {x: 0, y: 1})).toEqual(expect.objectContaining({x: -1/Math.sqrt(2), y: 1/Math.sqrt(2)}))
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
test("Transform Point Coordinate to another set of axis", ()=>{
|
|
58
|
-
expect(Point2Point.PointCal.transform2NewAxis({x: -2, y: 4}, 0.6435029).x).toBeCloseTo(4/5, 4);
|
|
59
|
-
expect(Point2Point.PointCal.transform2NewAxis({x: -2, y: 4}, 0.6435029).y).toBeCloseTo(22/5, 4);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe("Point Transformation", () => {
|
|
63
|
-
test("Rotate Point", () => {
|
|
64
|
-
let res = Point2Point.PointCal.rotatePoint({x: 1, y: 0}, Math.PI/ 2);
|
|
65
|
-
expect(res.x).toBeCloseTo(0, 5);
|
|
66
|
-
expect(res.y).toBeCloseTo(1, 5);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test("Rotate Point with respect to an Anchor Point", () => {
|
|
70
|
-
let res = Point2Point.PointCal.transformPointWRTAnchor({x: 1, y: 0}, {x: 0, y: 0}, Math.PI/ 2);
|
|
71
|
-
expect(res.x).toBeCloseTo(0, 5);
|
|
72
|
-
expect(res.y).toBeCloseTo(1, 5);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test("Distance Between Two Points", () => {
|
|
77
|
-
let res = Point2Point.PointCal.distanceBetweenPoints({x: 1, y: 0}, {x: 0, y: 1});
|
|
78
|
-
expect(res).toBeCloseTo(Math.sqrt(2), 5);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
describe("Miscellaneous", ()=>{
|
|
86
|
-
test("Flip Y Axis", ()=>{
|
|
87
|
-
let res = Point2Point.PointCal.flipYAxis({x: 1, y: 4});
|
|
88
|
-
res = Point2Point.PointCal.multiplyVectorByScalar(res, 10);
|
|
89
|
-
expect(res.y).toBe(-40);
|
|
90
|
-
expect(res.z).toBe(undefined);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
describe("Linear Interpolation between Points", ()=>{
|
|
96
|
-
test("Given two points {x: 0, y: 100}, and {x: 60, y: 40}, and a t val of 0.5", ()=>{
|
|
97
|
-
let res = Point2Point.PointCal.linearInterpolation({x: 0, y: 100}, {x: 60, y: 40}, 0.5);
|
|
98
|
-
expect(res).toEqual(expect.objectContaining({x: 30, y: 70}));
|
|
99
|
-
})
|
|
100
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "src",
|
|
5
|
-
"baseUrl": ".",
|
|
6
|
-
"outDir": "dist",
|
|
7
|
-
"tsBuildInfoFile": "dist/math.tsbuildinfo",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"module": "esnext",
|
|
11
|
-
},
|
|
12
|
-
"include": ["src/**/*"]
|
|
13
|
-
}
|
package/tsconfig.spec.json
DELETED