Hey, this looks cool! I may use it in the future. The problem has already
been solved, though, and I don't think changing it is necessary. I'd also
like to keep the dependencies (even packaged ones) to a minimum.
___
Numpy-discussion mailing list
Numpy
If you want the distance functionality without the rest of SciPy, you
can download the scipy-cluster package
(http://scipy-cluster.googlecode.com), which I still maintain. It does
not depend on any other libraries except NumPy and is very easy to
build. I understand if that's not an option for you.
Thanks, but I don't want to make SciPy a dependency. NumPy is ok though.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Hi Ian,
Sorry for responding so late. I've been traveling and I'm just
catching up on my e-mail now. This is easily accomplished with the
cdist function, which computes the pairwise distances between two sets
of vectors. In your case, one of the sets contains only a single
vector.
In [6]: scipy.s
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
___
On Sat, Apr 25, 2009 at 4:38 PM, Ian Mallett wrote:
> Oops, one more thing. In reference to:
> vec = array([[0,0,0],[0,1,0],[0,0,3]])
> pos = array([0,4,0])
> sqrt(((vec - pos)**2).sum(1)) -> array([ 4., 3., 5.])
>
> Can I make "vec" an array of class instances? I tried:
> class c:
> def _
Oops, one more thing. In reference to:
vec = array([[0,0,0],[0,1,0],[0,0,3]])
pos = array([0,4,0])
sqrt(((vec - pos)**2).sum(1)) -> array([ 4., 3., 5.])
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(),
On Sat, Apr 25, 2009 at 12:57 PM, Charles R Harris <
charlesr.har...@gmail.com> wrote:
> In [3]: vec = array([[0,0,0],[0,1,0],[0,0,3]])
>
> In [4]: pos = array([0,4,0])
>
> In [5]: sqrt(((vec - pos)**2).sum(1))
> Out[5]: array([ 4., 3., 5.])
>
> Chuck
>
On Sat, Apr 25, 2009 at 1:00 PM, wrote:
On Sat, Apr 25, 2009 at 3:57 PM, Charles R Harris
wrote:
>
>
> On Sat, Apr 25, 2009 at 12:50 PM, Ian Mallett wrote:
>>
>> Hi,
>>
>> I have an array sized n*3. Each three-component is a 3D position. Given
>> another 3D position, how is the distance between it and every
>> three-component in the
On Sat, Apr 25, 2009 at 12:50 PM, Ian Mallett wrote:
> Hi,
>
> I have an array sized n*3. Each three-component is a 3D position. Given
> another 3D position, how is the distance between it and every
> three-component in the array found with NumPy?
>
> So, for example, if the array is:
> [[0,0,0
Hi,
I have an array sized n*3. Each three-component is a 3D position. Given
another 3D position, how is the distance between it and every
three-component in the array found with NumPy?
So, for example, if the array is:
[[0,0,0],[0,1,0],[0,0,3]]
And the position is:
[0,4,0]
I need this array out
23 matches
Mail list logo