Using http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html, I
came up with:
x0 = numpy.array(#point to collide with)
x1 = #objects' positions
x2 = #objects' previous positions
numerator = numpy.sqrt((numpy.cross((x0-x1),(x0-x2))**2).sum(1))
denominator = numpy.sqrt(((x2-x1)**2).sum(1))
It was in an error code somewhere. I fixed the problem by messing around
with it. I tried the following:
a = numpy.array([1, 2, 3])
print a
and it gave:
[1, 2, 3]
instead of:
array([1, 2, 3])
Then there were errors about it being a sequence instead of an array
somewhere else.
Ian
Ian Mallett wrote:
> Yeah, I ended up finding the [0] bit at the end through trial and
> error. I actually do need the indices, though.
If you are not already doing so, I strongly recommend using ipython. It
is enormously useful in accessing docstrings (type a function name
followed by a qu
On Sun, Apr 26, 2009 at 3:32 PM, Ian Mallett wrote:
> Yes, this is pretty much what I'm doing. Right now, I'm having weird
> troubles with the objects themselves; the objects should and do terminate
> after a certain time, yet for some reason they're still being drawn. User
> error, I'm sure.
>
On Sat, Apr 25, 2009 at 1:26 PM, Ian Mallett wrote:
> I'm going to guess SciPy might be faster (?), but unfortunately it's not
> going to be available. Thanks, though.
>
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org
The problem is that the object moves too much between frames. A reasonable
bounding sphere is 1 for this purpose, but the objects move at least 3. So,
given the two arrays, one holding the objects' positions and the other their
previous positions, how can I find if, at some point between, the obj
Yes, this is pretty much what I'm doing. Right now, I'm having weird
troubles with the objects themselves; the objects should and do terminate
after a certain time, yet for some reason they're still being drawn. User
error, I'm sure.
Thanks,
Ian
___
Num
Hello Ian!
On Saturday 25 April 2009, Ian Mallett wrote:
> Can I make "vec" an array of class instances? I tried:
> class c:
> def __init__(self):
> self.position = [0,0,0]
> vec = array([c(),c(),c()])
> pos = array([0,4,0])
> sqrt(((vec.position - pos)**2).sum(1))
>
> Which doesn't w
Hmmm, I played around with some other code, and it's working right now--not
sure what I did...
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Yeah, I ended up finding the [0] bit at the end through trial and error. I
actually do need the indices, though.
I'm having a strange new problem though.
numpy.array([1,2,3])
is returning a sequence??? I'm really confused.
Ian
___
Numpy-discussion mai
Ian Mallett wrote:
> It would be:
> numpy.where(array right?
Almost. where(cond) is equivalent to nonzero(cond), and both return
tuples. Assuming your array is 1-D, you can use:
numpy.where(arrayhttp://mail.scipy.org/mailman/listinfo/numpy-discussion
It would be:
numpy.where(array___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Well, if it will kill performance, I'm afraid I can't do that. Thanks
though.
I think it's working now. Now that I have the 1D array of distances, I need
the indices of those distances that are less than a number "d". what should
I do to do that?
Thanks,
Ian
___
13 matches
Mail list logo