Subject: | Issue with find_in_ball Routine |
Date: | Mon, 23 Jun 2014 22:39:29 +0000 |
To: | "bug-Math-Vector-Real-kdTree [...] rt.cpan.org" <bug-Math-Vector-Real-kdTree [...] rt.cpan.org> |
From: | Chad Iverson <chad.iverson [...] quest-global.com> |
Hello,
I just recently installed the kdTree module and I am having some trouble getting find_in_ball() to report correctly. I created a simple test-case which hopefully repeats the problem. It is currently returning the 4-6 cases with the largest distance instead of all the ones within the sphere. It correctly filters them out if I bring the $d below the 4 or 6 values that it returns, but it is not properly reporting all vectors within the specified radius ($d), unless I'm fundamentally misunderstanding what this method is supposed to do. Here is the code for my test case:
#! /usr/bin/perl
use strict;
use warnings;
use Math::Vector::Real::kdTree;
use Math::Vector::Real;
my $dist = 2000;
my $chkpt = V(0.25, 0.25, 0.25);
my @v = ();
my $line = "";
foreach (0..1000) {
push @v, V($_, $_, $_);
}
my $tree = Math::Vector::Real::kdTree->new(@v);
my @indices = $tree->find_in_ball($chkpt, $dist);
foreach $line (@indices) {
my $distpt = $v[$line]->dist($chkpt);
print "Found one in ball of radius [$dist]: $line, $v[$line], $distpt\n";
}
I also noticed that when I specified an argument for $but, I get an error stating:
"Can't use string ("999") as a HASH ref while "strict refs" in use at C:/installationlocation/lib/Math/Vector/Real/dkTree.pm line 441."
I modified line 441 as seen below and it fixed the issue and correctly omitted that index:
return ($but ? grep $but != $_, @r : @r);
Environment:
Strawberry Perl 64-bit
->Perl 5, version 18, subversion 2 (v5.18.2) built for MSWin32-x64-multi-thread
Win7 Pro 64-bit SP1
kdTree module version is 0.11
Please let me know if I can provide any additional information.
Thanks and regards,
Chad
Chad Iverson
Aero-Thermal Technical Lead - Cincinnati Engineering Center
QuEST Global
11499 Chester Rd. Suite 600
Cincinnati, OH 45246 USA
T: +1 (513) 648-4938 X: 4938 F: +1 (513) 563-8865
E: chad.iverson@quest-global.com<mailto:chad.iverson@quest-global.com> Follow us on: [Description: cid:image001.png@01CD132D.32D2BC20] <http://www.facebook.com/QuESTGlobal> [Description: cid:image002.png@01CD132D.32D2BC20] <http://www.linkedin.com/company/quest_2> [Description: cid:image003.png@01CD132D.32D2BC20] <http://twitter.com/#!/QuEST_Global>
W: http://engineering.quest-global.com<http://engineering.quest-global.com/>
---Disclaimer------------------------------ This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Opinions, conclusions and other information in this transmission that do not relate to the official business of QuEST Global and/or its subsidiaries, shall be understood as neither given nor endorsed by it. Any statements made herein that are tantamount to contractual obligations, promises, claims or commitments shall not be binding on the Company unless followed by written confirmation by an authorized signatory of the Company. -----------------------------------------------------------------------------------