Class: GLViewer::Frame
- Inherits:
-
Object
- Object
- GLViewer::Frame
- Defined in:
- lib/rglviewer/frame.rb
Class Method Summary collapse
Instance Method Summary collapse
- #direct_transform(vec) ⇒ Object
-
#initialize(args = {}) ⇒ Frame
constructor
A new instance of Frame.
- #reverse_transform(vec) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Frame
Returns a new instance of Frame.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rglviewer/frame.rb', line 7 def initialize args = {} translation = args[:translation] || Vector.new(3,true) rotation = args[:rotation] || Matrix.new(3,3) @direct = Matrix.new(4,4,false).identity @indirect = @direct.clone #@direct.view(0,3,3,1) = translation #@direct.view(0,0,3,3) = rotation #t_rotation = rotation.transpose #@indirect.view(0,0,3,3) = t_rotation #@indirect.view(0,3,3,1) = - t_rotation * translation end |
Class Method Details
.rotate_x(a) ⇒ Object
28 29 30 31 32 |
# File 'lib/rglviewer/frame.rb', line 28 def self.rotate_x a Matrix.from_array [1.0 , 0.0 , 0.0 , 0.0 , Math.cos(a), - Math.sin(a), 0.0 , Math.sin(a), Math.cos(a)] end |
.rotate_y(a) ⇒ Object
34 35 36 37 38 |
# File 'lib/rglviewer/frame.rb', line 34 def self.rotate_y a Matrix.from_array [ Math.cos(a) , 0.0 , Math.sin(a), 0.0 , 1.0 , 0.0 , -Math.sin(a) , 0.0 , Math.cos(a)] end |
.rotate_z(a) ⇒ Object
40 41 42 43 44 |
# File 'lib/rglviewer/frame.rb', line 40 def self.rotate_z a Matrix.from_array [Math.cos(a) , - Math.sin(a) , 0.0 , Math.sin(a) , Math.cos(a) , 0.0 , 0.0 , 0.0 , 1.0 ] end |
Instance Method Details
#direct_transform(vec) ⇒ Object
20 21 22 |
# File 'lib/rglviewer/frame.rb', line 20 def direct_transform vec @direct * vec end |
#reverse_transform(vec) ⇒ Object
24 25 26 |
# File 'lib/rglviewer/frame.rb', line 24 def reverse_transform vec @indirect * vec end |