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 shorthand methods to get and query axis vectors #204

Closed franciscoadasme closed 1 year ago

franciscoadasme commented 1 year ago

It's quite common to use vector axes for transformation or querying if a vector is aligned to or in the same direction as an axis. So add class getters and question methods to Vec3 to get and query axis vectors, e.g., Vec3.z and Vec3#z?.

Could also use named vectors such as those in Unity and Unreal (e.g., up is Y, down is -Y, and so on).

Question methods could be implemented as

def upwards? : Bool
  dot(Vec3[0, 1, 0]) > 0
  # or using named vectors
  dot(self.class.up) > 0
end