views:

103

answers:

3

anyone knows how to write:

( x - 2 )
( y - 3 )
( z - 5 )

in python? Given Point P = (x, y, z) and Point OQ = (2, 3, 5) I tried defining Point P with a variable and subtract it with Point OQ.But the problem seem to lie with the x, y, z. The error i keep getting is that x is not defined etc.

Anyone got any idea?

+1  A: 

You can't tell Python to subtract two vectors if you don't know the value of one of them. Either rearrange your equations so that all the unknowns lie on one side, or use a different programming language that can handle unknowns (something like MatLab or Prolog might be suitable, though I haven't tried either).

Mark Byers
+2  A: 

I'll just take a wild stab at what you are trying to do (I can't quite understand what you are trying to achieve):

>>> from numpy import array

>>> P = array([5,6,5])
>>> Q = array([2,3,5])
>>> R = P - Q
>>> print R.tolist()
[3, 3, 0]
shylent
A: 

Hmm, a 3-D plane. Wait - wouldn't that be called a "volume" ? [ which of course then makes us ask, what do you call a 4-D 'region'? :-). I suspect soem Mathemeticians have solved that terminology issue already)

humpy
heh, well the path to enlightenment can be a twisted one, but any day you learn something new is a good day. I just learned what the terminology "3 D Plane" is used for in graphical computations. Now it makes perfect sense.
humpy