Reputation: 41
I'm trying to solve the following equation programmatically:
(ax−x0)^2 + (ay−y0)^2 = r^2
(bx−x0)^2 + (by−y0)^2 = (r+330bs)^2
(cx−x0)^2 + (cy−y0)^2 = (r+330cs)^2
ax,bx,cx,ay,by,cy,bs
and cs
are parameters, all which i get at runtime.
I'm trying to find x0
and y0
, but when i feed this into algebra.js it errors out.
I'm a high-school student so i didn't study high-end math (I have found solutions revolving matrices, which I didn't learn yet)
Would love some help with this, thanks in advance.
EDIT:
The code i have used with algebra.js was:
/*
a = ax*
b = bx*
c = cx*
d = ay*
e = by*
f = cy*
g = x0
h = y0
i = r
j = bs*
k = cs*
*/
var eq = algebra.parse("(a−g)^2 + (d−h)^2 = i^2");
eq.solveFor("g");
I then wanted to put the answer in the second equation and solve that, but that didn't work.
EDIT2:
The source of this equation is this by the way.
Upvotes: 4
Views: 1498
Reputation: 5704
The problem is the minus sign itself. Try this with your minus sign i copied from here
console.log("−".charCodeAt());
you get 8722 http://www.codetable.net/decimal/8722 now with minus sign that i typed in on my keyboard
console.log("-".charCodeAt());
i get 45 http://www.codetable.net/decimal/45
and with charCode 45 your code works, well at least for me
That's all i know, i have no explanation to this sorry :)
Upvotes: 2