Class: GlimR::AngleAxis
- Inherits:
-
Array
show all
- Defined in:
- lib/glimr/renderer/transform.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Array
#-@, #add, #cross_product, #delete_first, #dot, #sub
Class Method Details
.[](a, x, y, z) ⇒ Object
293
294
295
296
297
|
# File 'lib/glimr/renderer/transform.rb', line 293
def self.[](a,x,y,z)
aa = new
aa.push(a,*normalize(Vector[x,y,z]))
aa
end
|
.normalize(v) ⇒ Object
314
315
316
317
|
# File 'lib/glimr/renderer/transform.rb', line 314
def self.normalize(v)
v = (v * (1.0 / v.r)).to_a if (v.r - 1) > 0.001
v.to_a
end
|
Instance Method Details
#normalize ⇒ Object
310
311
312
|
# File 'lib/glimr/renderer/transform.rb', line 310
def normalize
self.class[*self]
end
|
306
307
308
|
# File 'lib/glimr/renderer/transform.rb', line 306
def to_aa
self
end
|
299
300
301
302
303
304
|
# File 'lib/glimr/renderer/transform.rb', line 299
def to_quat
a,x,y,z = normalize
s = Math.sin(a*Math::PI/90)
c = Math.cos(a*Math::PI/90)
Quaternion[c, x*s, y*s, z*s]
end
|