
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@daeinc/geom
Advanced tools
A collection of gemetry-related functions. Breaking changes expected in the future.
npm i @daeinc/geom
then,
import { blendPath, ... } from "@daeinc/geom";
type Pt = number[];
type Pts = number[][];
type GenericObject = Record<string, any>;
Three custom types are used.
const blendPath: (
path1: Pts,
path2: Pts,
numBlends: number,
guidePath?: Pts
) => number[][][];
Interpolates two paths to create in-between paths. numBlends does not count the two original paths. In other words, the two original paths are not included in the return array. guidePath parameter is not yet implemented.
const createShapeFunc: (
pts: Pts,
anchor?: Pt
) => (x: number, y: number, w: number, h: number) => Pts;
const dist: (pt1: Pt, pt2: Pt) => number;
Returns a distance between two points.
const distSq: (pt1: Pt, pt2: Pt) => number;
Returns a squared distance between two points. There's another version in @daeinc/math that takes number arguments.
const extrudePath: (
path: Pts,
numPointsToExtrude: number,
offset: Pt,
mode?: "start" | "end" | "both",
shapeFunc?: () => Pts
) => number[][];
Extrudes a path in 2d space.
const generateSmoothPath: (pts: Pts, smoothFactor: number) => number[][];
Generates extra points for smooth corners of path. Use with drawSmoothPath() from another package, @daeinc/canvas
const getAngleBetween: (pt1: Pt, pt2: Pt) => number;
Get angle between two points using Math.atan2(). Return value is between -pi and pi. pt2 - pt1 is the order of subtraction.
const getPathLength: (path: Pts) => number;
Returns the total length of path
const getPositiveAngleBetween: (pt1: Pt, pt2: Pt) => number;
Return value is between 0 and 2pi.
const getSegmentLengths: (pts: Pts) => number[];
Returns an array with each segment length (distance between points).
const interpolateArray: (
arrStart: number[],
arrTarget: number[],
t: number
) => number[];
const interpolatePath: (
pathStart: Pts,
pathTarget: Pts,
t: number
) => number[][];
Interpolates between two number arrays. Usually used for path data of [x, y].
const interpolateObject: (
objStart: GenericObject,
objTarget: GenericObject,
t: number
) => GenericObject;
Interpolates between two objects formatted { string: number }. For example, { x: 10, y: 20 }.
const interpolate: <T>(
start: T,
target: T,
t: number
) => number | GenericObject | T;
Interpolates number, number[], number[][] or generic object.
const projectPointOnLine: (pt: Pt, line: Pts) => Pt;
Projects a point on a line.
const reflectPoint: (pt: Pt, axis: Pt | Pts) => Pt;
Reflects a point on another point or a line.
const reflectPath: (pts: Pts, axis: Pt | Pts) => Pts;
Reflects a path either on a point or a line.
const scalePoint: (pt: Pt, size: Pt) => Pt;
Scales a single point.
const scalePath: (path: Pts, size: Pt) => Pts;
Takes in normalized path data and returns [ x, y ] that is scaled to size, [ width, height ].
Float32Array(gl-vec2) and regular arrayMIT
FAQs
Geometry utilities
We found that @daeinc/geom demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.