Divides this complex number by another. @param z The divisor. @return The quotient.
(Complex z)
| 145 | * @return The quotient. |
| 146 | */ |
| 147 | public Complex divide(Complex z) { |
| 148 | Complex temp = new Complex(); |
| 149 | double d = z.abs() * z.abs(); |
| 150 | d = (double) Math.round(d * 1000000000d) / 1000000000d; |
| 151 | temp.real = (this.real * z.real + this.img * z.img) / (d); |
| 152 | temp.img = (this.img * z.real - this.real * z.img) / (d); |
| 153 | return temp; |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Divides this complex number by a scalar. |