Module: Motel
- Defined in:
- lib/motel/exceptions.rb,
lib/motel/common.rb,
lib/motel/runner.rb,
lib/motel/location.rb,
lib/motel/callbacks.rb,
lib/motel/simrpc_adapter.rb,
lib/motel/movement_strategy.rb,
lib/motel/movement_strategies/linear.rb,
lib/motel/movement_strategies/stopped.rb,
lib/motel/movement_strategies/elliptical.rb
Overview
Exceptions used in the MOTEL project
Copyright © 2010 Mohammed Morsi <[email protected]> Licensed under the AGPLv3+ www.gnu.org/licenses/agpl.txt
Defined Under Namespace
Modules: Callbacks, MovementStrategies Classes: Client, InvalidMovementStrategy, Location, Logger, MovementStrategy, Runner, Server
Instance Method Summary collapse
-
#gen_uuid ⇒ Object
generate a random id.
-
#normalize(x, y, z) ⇒ Object
normalize a vector if not normal already, eg divide each component x,y,z by the vector length and return them.
-
#orthogonal?(x1, y1, z1, x2, y2, z2) ⇒ Boolean
determine if two vectors are orthogonal.
Instance Method Details
#gen_uuid ⇒ Object
generate a random id
44 45 46 47 |
# File 'lib/motel/common.rb', line 44 def gen_uuid ["%02x"*4, "%02x"*2, "%02x"*2, "%02x"*2, "%02x"*6].join("-") % Array.new(16) {|x| rand(0xff) } end |
#normalize(x, y, z) ⇒ Object
normalize a vector if not normal already, eg divide each component x,y,z by the vector length and return them
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/motel/common.rb', line 52 def normalize(x,y,z) return x,y,z if x.nil? || y.nil? || z.nil? l = Math.sqrt(x**2 + y**2 + z**2) if l != 1 x /= l y /= l z /= l end return x,y,z end |
#orthogonal?(x1, y1, z1, x2, y2, z2) ⇒ Boolean
determine if two vectors are orthogonal
65 66 67 68 |
# File 'lib/motel/common.rb', line 65 def orthogonal?(x1,y1,z1, x2,y2,z2) return false if x1.nil? || y1.nil? || z1.nil? || x2.nil? || y2.nil? || z2.nil? return (x1 * x2 + y1 * y2 + z1 * z2).abs == 0 end |