class Numeric

Public Instance Methods

complex?() click to toggle source

Returns true.

# File lib/quaternion_c2/classification.rb, line 22
def complex?
        true
end
j() click to toggle source

Returns the corresponding imaginary number. Not available for quaternions.

@return [Quaternion] +self * Quaternion::J+ @raise [NoMethodError] if self is not a complex.

@example

3.j             #=> (0+0i+3j+0k)
Complex(3, 4).j #=> (0+0i+3j+4k)
# File lib/quaternion_c2/units.rb, line 33
def j
        Quaternion.send(:new, 0, self)
end
k() click to toggle source

Returns the corresponding imaginary number. Not available for complex numbers.

@return [Quaternion] +self * Quaternion::K+ @raise [NoMethodError] if self is not a real.

@example

4.k #=> (0+0i+0j+4k)
# File lib/quaternion_c2/units.rb, line 47
def k
        Quaternion.send(:new, 0, self.i)
end
to_q() click to toggle source

Returns the value as a quaternion.

@return [Quaternion]

# File lib/quaternion_c2/to_type.rb, line 188
def to_q
        Quaternion.send(:new, self, 0)
end