franciscoadasme / chem.cr

Library for dealing with computational chemistry files
https://franciscoadasme.github.io/chem.cr/
MIT License
23 stars 1 forks source link

Add measurement methods to Vec3 to allow method chaining #198

Open franciscoadasme opened 1 year ago

franciscoadasme commented 1 year ago

One must use the functions in the Spatial module to compute the distance, angle, dihedral, etc. Even though it provides a generic API accepting several argument combinations, it may hurt discoverability (functionality is spread across multiple modules) and so it may be more convenient to have them as methods on Vec3, e.g.,

Chem::Spatial.distance v1, v2
Chem::Spatial.angle v1, v2
# vs
v1.distance_to(v2)
v1.angle_to(v2)

However, function overloads that require more than 2 arguments may prove difficult to translate:

Chem::Spatial.dihedral v1, v2, v3, v4
# vs
v1.dihedral v2, v3, v4 # or some alternative