Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
distance-to-line-segment
Advanced tools
Calculate distance between a point and a finite line segment
Calculate closest distance between a point and a line segment
Calculate the distance between a finite line segment and a point. Using distanceToLineSegment.squared can often be more efficient.
Kind: Exported function
Param | Type | Description |
---|---|---|
lx1 | number | x-coordinate of line segment's first point |
ly1 | number | y-coordinate of line segment's first point |
lx2 | number | x-coordinate of the line segment's second point |
ly2 | number | y-coordinate of the line segment's second point |
px | number | x coordinate of point |
py | number | y coordinate of point |
Calculate the square of the distance between a finite line segment and a point. This version takes somewhat less convenient parameters than distanceToLineSegment.squared, but is more efficient if you are calling it multiple times for the same line segment, since you pass in some easily pre-calculated values for the segment.
Kind: static method of distanceToLineSegment
Param | Type | Description |
---|---|---|
lx1 | number | x-coordinate of line segment's first point |
ly1 | number | y-coordinate of line segment's first point |
ldx | number | x-coordinate of the line segment's second point minus lx1 |
ldy | number | y-coordinate of the line segment's second point minus ly1 |
lineLengthSquared | number | must be ldx*ldx + ldy*ldy. Remember, this precalculation is for efficiency when calling this multiple times for the same line segment. |
px | number | x coordinate of point |
py | number | y coordinate of point |
Calculate the square of the distance between a finite line segment and a point.
Kind: static method of distanceToLineSegment
Param | Type | Description |
---|---|---|
lx1 | number | x-coordinate of line segment's first point |
ly1 | number | y-coordinate of line segment's first point |
lx2 | number | x-coordinate of the line segment's second point |
ly2 | number | y-coordinate of the line segment's second point |
px | number | x coordinate of point |
py | number | y coordinate of point |
MIT
FAQs
Calculate distance between a point and a finite line segment
The npm package distance-to-line-segment receives a total of 1,640 weekly downloads. As such, distance-to-line-segment popularity was classified as popular.
We found that distance-to-line-segment 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.