Method: Geometry::Rotation#matrix
- Defined in:
- lib/aurora-geometry/rotation.rb
#matrix ⇒ Matrix (readonly)
Returns the transformation Matrix representing the Geometry::Rotation.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/aurora-geometry/rotation.rb', line 80 def matrix return nil unless [@x, @y, @z].compact.size >= 2 # Force all axes to be Vectors x,y,z = [@x, @y, @z].map {|a| a.is_a?(Array) ? Vector[*a] : a} # Force all axes to exist if x and y z = x ** y elsif x and z y = x ** z elsif y and z x = y ** z end rows = [] [x, y, z].each_with_index {|a, i| rows.push(a.to_a) if i < @dimensions } raise ArgumentError, "Number of axes must match the dimensions of each axis" unless @dimensions == rows.size Matrix[*rows] end |