Topic: I don't understand what's wrong.. any help please :)
class Complex
attr_accessor :real, :imaginary, :angle, :radius
def initialization (real, imaginary)
@real = real
@imaginary = imaginary
@radius = Math.sqrt(real**2 + imaginary**2)
@angle = Math.atan((float)imaginary/real)
end
def +c
return Complex.new(c.real + real, c.imaginary + imaginary)
end
def -c
return Complex.new(real - c.real, imaginary - c.imaginary)
end
def *c
return complex.new(real * c.real - imaginary * c.imaginary, real * c.imaginary + imaginary * c.real)
end
def conjugate
temp = @real - @imaginary # try without @ to use accessor later
return Self * temp
end
def polar_to_rectangular (angle, radius)
@angle = angle
@radius = radius
@real = radius * Math.cos(@angle)
@imaginary = raduius * Math.sin(@angle)
def /c
temp = Complex.new(0,0)
temp.polar_to_rectangular(radius / c.radius, angle - c.angle)
return temp
end
end