1

I have following equations:

  center_y -y1 = m * ( center_x - x1 );

  start_y - y1 = m * ( start_x - x1 );

where values of center_y,center_x,start_y,start_x and m are known and i want to get values of x1 and y1...

Kindly provide an appropriate solution in java.../

Amritpal Singh
  • 984
  • 2
  • 14
  • 33
  • 6
    http://mattgemmell.com/2008/12/08/what-have-you-tried/ – Ankur Nov 16 '12 at 11:41
  • m is a method. What do you mean "it is known". Please show the method because as it is, this question cannot be answered since each equation has 2 unknown variables and an unknown function. – Simon Nov 16 '12 at 11:45
  • @Simon Those are mathematical equations, not java assignment statements. – Neilers Nov 16 '12 at 11:45
  • 1
    @simon m is a variable with a known value..or its like m*(center_x - x1).and similarly m*(start_x-x1)... Kindly tell me if it could be solved with apche maths library../ – Amritpal Singh Nov 16 '12 at 11:48

1 Answers1

2

Assuming these are equations (i.e. m is a scalar, not a method), you can first rearrange the equations to get to a usual 2 variables / 2 equations model:

m.x1 - y1 = m.center_x - center_y
m.x1 - y1 = m.start_x - start_y

Then solve the linear system using general techniques. And you will find out that because the 2 equations are colinear, there is either no solution or many solutions to that system...

assylias
  • 321,522
  • 82
  • 660
  • 783