@daeinc/geom
Advanced tools
Comparing version 0.8.0 to 0.8.1
import { mix, reflect, roundF, TWO_PI } from "@daeinc/math"; | ||
import { interpolateArray as importedInterpolateArray } from "@daeinc/array"; | ||
import vec2 from "gl-vec2"; | ||
import { add, dot, fromValues, len, mul, normalize, sub } from "gl-vec2"; | ||
/** | ||
@@ -113,10 +113,7 @@ * generates an array of paths (excl. original 2 paths) | ||
const b = pts[i + 1]; | ||
const diff = vec2.sub([], b, a); | ||
const diffScaled1 = vec2.mul([], diff, [smoothFactor, smoothFactor]); | ||
const mid1 = vec2.add([], a, diffScaled1); | ||
const diffScaled2 = vec2.mul([], diff, [ | ||
1 - smoothFactor, | ||
1 - smoothFactor, | ||
]); | ||
const mid2 = vec2.add([], a, diffScaled2); | ||
const diff = sub([], b, a); | ||
const diffScaled1 = mul([], diff, [smoothFactor, smoothFactor]); | ||
const mid1 = add([], a, diffScaled1); | ||
const diffScaled2 = mul([], diff, [1 - smoothFactor, 1 - smoothFactor]); | ||
const mid2 = add([], a, diffScaled2); | ||
smoothPoints.push(mid1, mid2, b); | ||
@@ -273,10 +270,10 @@ } | ||
export const projectPointOnLine = (pt, line) => { | ||
const ptVec = vec2.fromValues(pt[0] - line[1][0], pt[1] - line[1][1]); | ||
const lineVec = vec2.fromValues(line[0][0] - line[1][0], line[0][1] - line[1][1]); | ||
const prod = vec2.dot(ptVec, lineVec); | ||
const proj = prod / vec2.len(lineVec); | ||
const projVec = vec2.fromValues(proj, proj); | ||
const result = vec2.normalize(lineVec, lineVec); | ||
vec2.mul(result, lineVec, projVec); | ||
vec2.add(result, result, line[1]); | ||
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 prod = dot(ptVec, lineVec); | ||
const proj = prod / len(lineVec); | ||
const projVec = fromValues(proj, proj); | ||
const result = normalize(lineVec, lineVec); | ||
mul(result, lineVec, projVec); | ||
add(result, result, line[1]); | ||
return result; | ||
@@ -292,5 +289,5 @@ }; | ||
if (axis[0].constructor === Array) { | ||
const projVec = vec2.fromValues(...projectPointOnLine(pt, axis)); | ||
const distVec = vec2.sub([], vec2.fromValues(pt[0], pt[1]), projVec); | ||
const reflVec = vec2.sub(projVec, projVec, distVec); | ||
const projVec = fromValues(...projectPointOnLine(pt, axis)); | ||
const distVec = sub([], fromValues(pt[0], pt[1]), projVec); | ||
const reflVec = sub(projVec, projVec, distVec); | ||
return reflVec; | ||
@@ -297,0 +294,0 @@ } |
{ | ||
"name": "@daeinc/geom", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"description": "Geometry utilities", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts", |
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
36872
562