@daeinc/geom
Advanced tools
Comparing version 0.8.1 to 0.9.0
@@ -1,4 +0,4 @@ | ||
export type Pt = number[]; | ||
export type Pts = number[][]; | ||
export type GenericObject = Record<string, any>; | ||
export declare type Pt = number[]; | ||
export declare type Pts = number[][]; | ||
export declare type GenericObject = Record<string, any>; | ||
/** | ||
@@ -62,3 +62,3 @@ * generates an array of paths (excl. original 2 paths) | ||
*/ | ||
export declare const generateSmoothPath: (pts: Pts, smoothFactor: number) => number[][]; | ||
export declare const generateSmoothPath: (pts: Pts, smoothFactor: number) => import("@thi.ng/vectors").Vec[]; | ||
/** | ||
@@ -65,0 +65,0 @@ * atan2() gives angle between [-PI, PI] |
import { mix, reflect, roundF, TWO_PI } from "@daeinc/math"; | ||
import { interpolateArray as importedInterpolateArray } from "@daeinc/array"; | ||
import { add, dot, fromValues, len, mul, normalize, sub } from "gl-vec2"; | ||
import { add2 as add, dot2 as dot, mag, mul2 as mul, sub2 as sub, vec2, normalize2 as normalize, } from "@thi.ng/vectors"; | ||
/** | ||
@@ -269,11 +269,11 @@ * generates an array of paths (excl. original 2 paths) | ||
export const projectPointOnLine = (pt, line) => { | ||
const ptVec = fromValues(pt[0] - line[1][0], pt[1] - line[1][1]); | ||
const lineVec = fromValues(line[0][0] - line[1][0], line[0][1] - line[1][1]); | ||
const ptVec = vec2(pt[0] - line[1][0], pt[1] - line[1][1]); | ||
const lineVec = vec2(line[0][0] - line[1][0], line[0][1] - line[1][1]); | ||
const prod = dot(ptVec, lineVec); | ||
const proj = prod / len(lineVec); | ||
const projVec = fromValues(proj, proj); | ||
const proj = prod / mag(lineVec); | ||
const projVec = vec2(proj, proj); | ||
const result = normalize(lineVec, lineVec); | ||
mul(result, lineVec, projVec); | ||
add(result, result, line[1]); | ||
return result; | ||
return [result[0], result[1]]; | ||
}; | ||
@@ -288,6 +288,6 @@ /** | ||
if (axis[0].constructor === Array) { | ||
const projVec = fromValues(...projectPointOnLine(pt, axis)); | ||
const distVec = sub([], fromValues(pt[0], pt[1]), projVec); | ||
const projVec = vec2(...projectPointOnLine(pt, axis)); | ||
const distVec = sub([], vec2(pt[0], pt[1]), projVec); | ||
const reflVec = sub(projVec, projVec, distVec); | ||
return reflVec; | ||
return [reflVec[0], reflVec[1]]; | ||
} | ||
@@ -294,0 +294,0 @@ else { |
{ | ||
"name": "@daeinc/geom", | ||
"version": "0.8.1", | ||
"version": "0.9.0", | ||
"description": "Geometry utilities", | ||
@@ -15,3 +15,3 @@ "types": "./dist/index.d.ts", | ||
"watch": "tsc --watch", | ||
"test": "jest --watch", | ||
"test": "vitest watch --config ./vitest.config.js", | ||
"demo": "parcel ./demo/index.html --dist-dir ./demo/build --no-source-maps --no-cache", | ||
@@ -25,3 +25,3 @@ "build": "tsc --build --clean && tsc --build" | ||
"@daeinc/math": "^0.5.0", | ||
"gl-vec2": "^1.3.0" | ||
"@thi.ng/vectors": "^7.5.31" | ||
}, | ||
@@ -31,6 +31,3 @@ "devDependencies": { | ||
"@daeinc/draw": "^0.2.1", | ||
"@types/gl-vec2": "^1.3.2", | ||
"jest": "^29.3.1", | ||
"jest-canvas-mock": "^2.4.0", | ||
"ts-jest": "^29.0.5" | ||
"vitest": "^0.27.2" | ||
}, | ||
@@ -37,0 +34,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37058
3
+ Added@thi.ng/vectors@^7.5.31
+ Added@thi.ng/api@8.11.13(transitive)
+ Added@thi.ng/arrays@2.10.6(transitive)
+ Added@thi.ng/binary@3.4.36(transitive)
+ Added@thi.ng/checks@3.6.15(transitive)
+ Added@thi.ng/compare@2.4.5(transitive)
+ Added@thi.ng/compose@3.0.16(transitive)
+ Added@thi.ng/equiv@2.1.69(transitive)
+ Added@thi.ng/errors@2.5.19(transitive)
+ Added@thi.ng/hex@2.3.57(transitive)
+ Added@thi.ng/math@5.11.13(transitive)
+ Added@thi.ng/memoize@4.0.3(transitive)
+ Added@thi.ng/random@4.1.4(transitive)
+ Added@thi.ng/strings@3.8.11(transitive)
+ Added@thi.ng/transducers@9.2.9(transitive)
+ Added@thi.ng/vectors@7.12.10(transitive)
+ Addedtslib@2.8.1(transitive)
- Removedgl-vec2@^1.3.0
- Removedgl-vec2@1.3.0(transitive)