Skip to content

Instantly share code, notes, and snippets.

@aschreyer
Created June 1, 2011 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aschreyer/1002603 to your computer and use it in GitHub Desktop.
Save aschreyer/1002603 to your computer and use it in GitHub Desktop.
Eigen Vector3D PostgreSQL extension
SELECT degrees('(3,0,0)'::vector3d @ '(5,5,0)'::vector3d) AS angle;
angle
-------
45
(1 row)
SELECT COUNT(*) FROM credo.atoms;
count
---------
3716692
(1 row)
SELECT vector3d_norm(coords)
FROM credo.atoms
ORDER BY 1
LIMIT 20;
vector3d_norm
-------------------
0.266732071100181
0.495048489244454
0.646344318702224
0.759123181442119
0.884029956900807
0.926277483712275
0.926432929988672
0.932031105419797
0.967361873862429
0.993470670604998
1.00786357380269
1.00977918256379
1.01654514083277
1.02094760913838
1.02251455300799
1.04313659046296
1.09904459767644
1.13930636319184
1.14757132309494
1.1507923657741
(20 rows)
Time: 1164.410 ms
SELECT '(1,2,3)'::vector3d -> '(2,2,3)'::vector3d AS distance;
distance
----------
1
(1 row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment