Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/local/bin/ruby
d1=[83,51]
d2=[85,31]
d3=[18,137]
A = d2[0] - d1[0];
B = d2[1] - d1[1];
C = d3[0] - d1[0];
D = d3[1] - d1[1];
E = A * (d1[0] + d2[0]) + B * (d1[1] + d2[1]);
F = C * (d1[0] + d3[0]) + D * (d1[1] + d3[1]);
G = 2.0 * (A * (d3[1] - d2[1]) - B * (d3[0] - d2[0]));
raise if G.eql?(0)
Px = (D * E - B * F) / G;
Py = (A * F - C * E) / G;
puts "x: #{Px}, y:#{Py}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment