Sha256: 0f4f72fdbf78045ce939c754440f0d298661f05bb3a3fb3325e2b0acf3c4a1df

Contents?: true

Size: 387 Bytes

Versions: 1

Compression:

Stored size: 387 Bytes

Contents

#! /usr/bin/ruby

require "matrix"

class Vector
	#include Math
	class ZeroOperation < Exception; end
	class SizeError < Exception; end

	# Get a unit vector.
	def unit_vector
		len = self.r
		raise Vector::ZeroOperation if (len == 0)
		self * (1/len)
		# Vector3D.new(@x*(1.0/len), @y*(1.0/len), @z*(1.0/len))
	end

	def floor
		self.class[* self.map {|val| val.floor}.to_a]
	end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mageo-0.0.0 lib/mageo/vector.rb