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
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
andVec3#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