Skip to content

Instantly share code, notes, and snippets.

@tsbits
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsbits/a5648a1b0b3c837f02a8 to your computer and use it in GitHub Desktop.
Save tsbits/a5648a1b0b3c837f02a8 to your computer and use it in GitHub Desktop.
Find a random point on a line
var r = Math.random();
var randomPoint = {
'x': (1-r)*this.v1.x + r*this.v2.x,
'y' : (1-r)*this.v1.y + r*this.v2.y
}
//Where v1 & v2 are the two points defining the line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment