Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- module NormalVector
- refine Array do
- def normal(o)
- require 'matrix'
- Vector.elements(self.map &:to_f)
- .cross(Vector.elements(o))
- .normalize.to_a
- end
- end
- end
- using NormalVector
- puts "#{[1, 2, 3].normal [4, 5, 6]}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement