Skip to content

Commit

Permalink
put inverse calculation outside the for loop; test for #44
Browse files Browse the repository at this point in the history
0.2-sec speedup
  • Loading branch information
RodenLuo committed Dec 18, 2024
1 parent 58856ef commit a2e237a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/fit_res_clustering_#44/fit_res_clustering_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ def any_close_transform(b, tf):
'''Check the center bin first for a close transform to improve speed when most queries have a close transform.'''
bc = tuple(int(x / bs) for x, bs in zip(b.bin_point(tf), b.bins.bin_size))
if bc in b.bins.bins:
itf = tf.inverse()
for c,btf in b.bins.bins[bc]:
dx, dy, dz = btf.translation() - ptf.translation()

if (dx * dx + dy * dy + dz * dz <= b.d2max and
(tf.inverse()*btf).rotation_angle() < b.angle):
(itf*btf).rotation_angle() < b.angle):
return btf

# numpy takes 2-sec longer
Expand Down

0 comments on commit a2e237a

Please sign in to comment.