Last active
December 17, 2015 05:39
-
-
Save ikekou/5559092 to your computer and use it in GitHub Desktop.
[Math][JavaScript][CoffeeScript]各々2点を通る直線2本の交点を求める(参考:http://mf-atelier.sakura.ne.jp/mf-atelier/modules/tips/index.php/program/algorithm/a1.html)
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
cross=(x1,y1,x2,y2,x3,y3,x4,y4)-> | |
ksi = (y4 - y3) * (x4 - x1) - (x4 - x3) * (y4 - y1) | |
delta = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3) | |
ramda = ksi / delta | |
x = x1 + ramda * (x2 - x1) | |
y = y1 + ramda * (y2 - y1) | |
return [x,y] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment