Last active
August 29, 2015 14:07
-
-
Save tsbits/a5648a1b0b3c837f02a8 to your computer and use it in GitHub Desktop.
Find a random point on a line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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