Solving for X and Y with a = in the FUNCTION???

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If you have a triangle with the following points
A (-6,-4)
B (-1,8)
C (13,-2)

Find the point perpendicular to AC.
y-y1=m(x-x1)

For this equation, it is solved
y+4=2/19(x+6)
y=2/19x-64/19

y-8=-19/2(x+1)
y=-19/2x-3/2
Therefore:
2/19x-64/19=-19/2x-3/2
365x=71
x=.195

..195 is substituted back into the orginal formula to find for y.

I know to use the x and y variable to have the function call out a cell with
either the x or y in that cell, what I believe is screwing up the function is
the = sign in the middle of it. Any suggestions?
 
Thanks for the advice, this isn't quite what I was looking for, it didn't
work in my case, and I am still stuck. I think it is possibly the = sign in
the equation that excel isn't reading. Or maybe it is the variables.
 
I'm not sure if this is totally correct, but see if this would work. I've
done this using x,y pairs, with the perpendicular point given last (ie B
(-1,8)). There may be a more efficient equation.

Sub Testit()
Dim v
v = PerpPoint(-6, -4, 13, -2, -1, 8)

Range("A1:B1") = v
'or
Debug.Print "x: "; v(0)
Debug.Print "y: "; v(1)
End Sub

Function PerpPoint(a, b, c, d, e, f) As Variant
Dim x As Double
Dim y As Double
Dim t As Double

x = (b^2*c+a^2*e+a*b*(f-d)-b*c*(d+f)+a*(d^2-2*c*e-d*f)+c*(c*e+d*f))
y = ((a-c)*(d*(a-e)+b*(e-c))+(b-d)^2*f)
t = (a-c)^2+(b-d)^2

PerpPoint = Array(x / t, y / t)
End Function

Returns:

x: 0.194520547945205
y: -3.34794520547945

HTH :>)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top