/** * Author: Josiah Yoder et al. * User: yoder * Class: SE1011-011 * Date: 10/17/13 8:29 AM * Lesson: Week 6, Day 1 */ public class Complex051_7_1 { // The complex number is // real + imaginary * i // where i is sqrt(-1) private double real; private double imaginary; public Complex051_7_1(double real, double imaginary) { this.real = real; this.imaginary = imaginary; } // // Treat complex number as a vector // and return the magnitude. // // That is, we want to find the length // of the vector from the origin // to the complex number // when plotted on a graph. public double magnitude() { // sqrt(x^2 + y^2) // sqrt(real^2 + imaginary^2) return Math.sqrt(real*real+imaginary*imaginary); } }