Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

distance-to-line-segment

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

distance-to-line-segment

Calculate distance between a point and a finite line segment

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7K
decreased by-13.82%
Maintainers
1
Weekly downloads
 
Created
Source

distance-to-line-segment

Calculate closest distance between a point and a line segment

API

distance-to-line-segment

distanceToLineSegment(lx1, ly1, lx2, ly2, px, py) ⏏

Calculate the distance between a finite line segment and a point. Using distanceToLineSegment.squared can often be more efficient.

Kind: Exported function

ParamTypeDescription
lx1numberx-coordinate of line segment's first point
ly1numbery-coordinate of line segment's first point
lx2numberx-coordinate of the line segment's second point
ly2numbery-coordinate of the line segment's second point
pxnumberx coordinate of point
pynumbery coordinate of point

distanceToLineSegment.squaredWithPrecalc(lx1, ly1, ldx, ldy, lineLengthSquared, px, py)

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

ParamTypeDescription
lx1numberx-coordinate of line segment's first point
ly1numbery-coordinate of line segment's first point
ldxnumberx-coordinate of the line segment's second point minus lx1
ldynumbery-coordinate of the line segment's second point minus ly1
lineLengthSquarednumbermust be ldx*ldx + ldy*ldy. Remember, this precalculation is for efficiency when calling this multiple times for the same line segment.
pxnumberx coordinate of point
pynumbery coordinate of point

distanceToLineSegment.squared(lx1, ly1, lx2, ly2, px, py)

Calculate the square of the distance between a finite line segment and a point.

Kind: static method of distanceToLineSegment

ParamTypeDescription
lx1numberx-coordinate of line segment's first point
ly1numbery-coordinate of line segment's first point
lx2numberx-coordinate of the line segment's second point
ly2numbery-coordinate of the line segment's second point
pxnumberx coordinate of point
pynumbery coordinate of point

License

MIT

Keywords

FAQs

Package last updated on 30 Jan 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc