Git Product home page Git Product logo

distance-to-line-segment's Introduction

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

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

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

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

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

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

License

MIT

distance-to-line-segment's People

Contributors

scottglz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.