Michael Thomas Flanagan's Java Scientific Library

Phasor Class:      Phasor Arithmetic and Phasor Functions

     

Last update: 5 December 2011
Main Page of Michael Thomas Flanagan Java Scientific Library

This class defines an object that represents a Phasor,
      .
The symbol, j, is used on this page to represent the square root of minus one. This class includes an extensive range of the methods needed in Phasor arithmetic, including Phasor matrices are handled in a separate class - PhasorMatrix.

import directive: import flanagan.circuits.Phasor; Related classes

SUMMARY OF CONSTRUCTORS AND METHODS

Constructors public Phasor()
public Phasor(double magnitude, double phaseInDegrees)
public Phasor(double magnitude)
Set Values public void setMagnitude(double magnitude)
public void setPhaseInDegrees(double phaseInDegrees)
public void setPhaseInRadians(double phaseInradians)
public void reset(double magnitude, double phaseInDegrees)
public static void setFrequency(double frequency)
public static void setRadialFrequency(double omega)
Get Values public double getMagnitude()
public double getPhaseInDegrees()
public double getPhaseInRadians()
public double getReal()
public double getImag()
public int hashCode()
public static double getFrequency()
public static double getRadialFrequency()
Input and Output public static Phasor readPhasor(String prompt, Phasor default)
public static Phasor readPhasor(String prompt, String default)
public static Phasor readPhasor(String prompt)
public static Phasor readPhasor()
public void print(String message)
public void print()
public void println(String message)
public void println()
public static void println(String message, Phasor ph[])
public static void println(Phasor ph[])
public static void print(String message, Phasor ph[])
public static void print(Phasor ph[])
Truncate mantissae to n places public Phasor truncate(int n)
public static Phasor truncate(Phasor x, int n)
Conversions public static Phasor toPhasor(Complex cc)
public Complex toRectangular()
public Complex toComplex()
public static Complex toRectangular(Phasor ph)
public static Complex toComplex(Phasor ph)
public VectorMaths toVectorMaths()
public static VectorMaths toVectorMaths(Phasor ph)
public String toString()
public static String toString(Phasor aa)
public static Phasor parsePhasor(String ss)
public static Phasor valueOf(String ss)
public int hashCode()
Modulus public double abs()
Argument public double argInDegrees()
public double argInRadians()
Conjugate public Phasor conjugate()
Addition public Phasor plus(Phasor a)
public Phasor plus(Complex a)
public void plusEquals(Phasor a )
public void plusEquals(Complex a )
Subtraction public Phasor minus(Phasor a)
public Phasor minus(Complex a)
public void minusEquals(Phasor a )
public void minusEquals(Complex a )
Multiplication public Phasor times(Phasor a)
public Phasor times(Complex a)
public Phasor timesExpOmegaTime(double omega, double time)
public Phasor timesExpTwoPiFreqTime(double frequency, double time)
public void timesEquals(Phasor a )
public void timesEquals(Complex a )
public void timesEqualsExpOmegaTime(double omega, double time)
public void timesEqualsExpTwoPiFreqTime(double frequency, double time)
Division public Phasor over(Phasor a)
public Phasor over(Complex a)
public void overEquals(Phasor a )
public void overEquals(Complex a )
Reciprocal public Phasor inverse()
Negation public Phasor negate()
Exponential public static Phasor exp(Phasor aa)
Logarithm public static Phasor log(Phasor aa )
Root public static Phasor sqrt(Phasor aa )
public static Phasor nthRoot(Phasor aa, int n )
Power public static Phasor square(Phasor aa)
public static Phasor pow(Phasor a, int b)
public static Phasor pow(Phasor a, double b)
public static Phasor pow(Phasor a, Complex b)
public static Phasor pow(Phasor a, Phasor b)
Trigonometric
Functions
public static Phasor sin(Phasor aa )
public static Phasor asin(Phasor aa )
public static Phasor cos(Phasor aa )
public static Phasor acos(Phasor aa )
public static Phasor tan(Phasor aa )
public static Phasor atan(Phasor aa )
public static Phasor cot(Phasor aa )
public static Phasor acot(Phasor aa )
public static Phasor sec(Phasor aa )
public static Phasor asec(Phasor aa )
public static Phasor csc(Phasor aa )
public static Phasor acsc(Phasor aa )
public static Phasor exsec(Phasor aa )
public static Phasor aexsec(Phasor aa )
public static Phasor vers(Phasor aa )
public static Phasor avers(Phasor aa )
public static Phasor covers(Phasor aa )
public static Phasor acovers(Phasor aa )
public static Phasor hav(Phasor aa )
public static Phasor ahav(Phasor aa )
public static Phasor sinh(Phasor aa )
public static Phasor asinh(Phasor aa )
public static Phasor cosh(Phasor aa )
public static Phasor acosh(Phasor aa )
public static Phasor tanh(Phasor aa )
public static Phasor atanh(Phasor aa )
public static Phasor coth(Phasor aa )
  public static Phasor acoth(Phasor aa )
public static Phasor sech(Phasor aa )
public static Phasor asech(Phasor aa )
public static Phasor csch(Phasor aa )
public static Phasor acsch(Phasor aa )
Logical Tests public boolean equals(Phasor x)
public boolean equalsWithinLimits(Phasor x, double fract)
public boolean isZero()
public boolean isReal()
public boolean isPlusInfinity()
public boolean isMinusInfinity()
public boolean isNaN()
Arrays

see Input and Output
for printing Phasor arrays
public static Phasor[] oneDarray(int n)
public static Phasor[] oneDarray(int n, double a, double b)
public static Phasor[] oneDarray(int n, Phasor xx)
public static Phasor[][] twoDarray(int n, int m)
public static Phasor[][] twoDarray(int n, int m, double a, double b)
public static Phasor[][] twoDarray(int n, int m, Phasor xx)
public static Phasor[][][] threeDarray(int n, int m, int k)
public static Phasor[][][] threeDarray(int n, int m, int k, double a, double b)
public static Phasor[][][] threeDarray(int n, int m, int k, Phasor xx)
Deep Copy public Phasor copy()
public static Phasor copy(Phasor a)
public Object clone()
public static Phasor[] copy(Phasor[] a)
public static Phasor[][] copy(Phasor[][] a)
public static Phasor[][][] copy(Phasor[][][] a)
Some Useful Numbers public static Phasor zero()
public static Phasor plusOne()
public static Phasor minusOne()
public static Phasor magnitudeZeroPhase(double magnitude)
public static Phasor plusInfinity()
public static Phasor minusInfinity()
Circuit components public static Phasor resistancePhasor(double resistance)
public static Phasor inductancePhasor(double inductance, double frequency)
public static Phasor capacitancePhasor(double capacitance, double frequency)
public static Phasor infiniteWarburgPhasor(double sigma, double frequency)
public static Phasor finiteWarburgPhasor(double sigma, double delta, double frequency)
public static Phasor constantPhaseElementPhasor(double sigma, double alpha, double frequency)



CONSTRUCTORS

public Phasor()
Usage:                      Phasor aa = new Phasor();
This creates a new instance of Phasor(), aa, and initialises both the magnitude and the phase to zero

public Phasor(double magnitude, double PhaseInDegrees)
Usage:                      Phasor aa = new Phasor(mag, phaseDeg);
This creates a new instance of Phasor(), aa, and initialises the magnitude to mag and the phase to phaseDeg, entered in degrees

public Phasor(double magnitude)
Usage:                      Phasor aa = new Phasor(mag);
This creates a new instance of Phasor(), aa, and initialises the magnitude to mag and the phase to zero.



METHODS

SET VALUES
public void setMagnitude(double mag)
Usage:                      aa.setMagnitude(mag);
Sets the magnitude of the existing Phasor aa to mag

public void setPhaseInDegrees(double phaseDeg)
Usage:                      aa.setPhaseInDegrees(phaseDeg);
Sets the phase of the existing Phasor aa to phaseDeg, entered in degrees

public void setPhaseInRadians(double phaseRad)
Usage:                      aa.setPhaseInRadians(phaseRad);
Sets the phase of the existing Phasor aa to phaseRad, entered in radians

public void reset(double mag, double phaseDeg)
Usage:                      aa.reset(mag, phaseDeg);
Sets the magnitude of the existing Phasor aa to mag and the phase to phaseDeg, entered in degrees.

public static void setFrequency(double frequency)
Usage:                      Phasor.setFrequency(frequency);
Sets the frequency required if the phasors are used to represent electrical circuit parameters, e.g. the impedance of capacitor. The units of the argument frequency are Hz. The frequency is represented by a static variable thus preventing the inappropriate combination of phasors representing such parameters. If an attempt is made to reset the frequency or radial frequency once either has been set an exception will be thrown. The frequency may, alternatively, be entered as a radial frequency (see immediately below).

public static void setRadialFrequency(double omega)
Usage:                      Phasor.setRadialFrequency(omega);
Sets the radial frequency required if the phasors are used to represent electrical circuit parameters, e.g. the impedance of capacitor. The units of the argument omega are radians per second. The radial frequency is represented by a static variable thus preventing the inappropriate combination of phasors representing such parameters. If an attempt is made to reset the radial frequency or frequency once either has been set an exception will be thrown. The radial frequency may, alternatively, be entered as a frequency in Hz (see immediately above).



GET VALUES
public double getMagnitude()
Usage:                      mag = aa.getMagnitude();
The value of the magnitude of the Phasor represented by aa is returned to mag.

public double getPhaseInDegrees()
Usage:                      phase = aa.getPhaseInDegrees();
The value of the phase of the Phasor represented by aa is returned to phase in degrees.

public double getPhaseInRadians()
Usage:                      phase = aa.getPhaseInRadians();
The value of the phase of the Phasor represented by aa is returned to phase in radians.

public double getReal()
Usage:                      real = aa.getReal();
Returns the real part of the Phasor, aa, i.e. magnitude.cos(phase).

public double getImag()
Usage:                      imag = aa.getImag();
Returns the imaginary part of the Phasor, aa, i.e. magnitude.sin(phase).

public int hashCode()
Usage:                      hc = aa.hashCode();
The hashcode for aa is returned to hc.
Overrides java.lang.Object.hashCode()

public static double getFrequency()
Usage:                      freq = Phasor.getFrequency();
Returns the frequency, in Hz, set for the class. Double.NaN is returned if no frequency or radial frequency has been set.

public static double getRadialFrequency()
Usage:                      rad = Phasor.getRadialFrequency();
Returns the radial frequency, in radians per second, set for the class. Double.NaN is returned if no frequency or radial frequency has been set.



INPUT AND OUTPUT

NOTE: The standard Java output methods, e.g. System.out.println, System.out.print, drawString, will output instances of this class, Phasor, as this Phasor class contains a method that overrides the Java method, toString.

See Db for input and output of Phasors using a dialog Box, FileInput for reading Phasors from a text file and FileOutput for writing Phasors to a text file.

The angle symbol, ∠, may be represented by the less than symbol, <, or the upper case el, L, in input and will be represented by the less than symbol, <, in output.

READ IN A PHASOR FROM THE KEYBOARD
public static Phasor readPhasor(String prompt)
public static Phasor readPhasor(String prompt, Phasor default)
public static Phasor readPhasor(String prompt, String default)
public static Phasor readPhasor()
Example of Usage:                     aa=Phasor.readPhasor("Input a Phasor ");
Writes the String prompt to the screen. The user may then enter a Phasor, via the keyboard, in one of the following formats:
x<y    xLy    x<ydeg    xLydeg    x<yrad    xLyrad        e.g. 3.0e2<22.78deg
where x is the magnitude and y is the phase. The first four formats accept the phase in degrees, the latter two formats accept the phase in radians.
Phasor.read then creates and returns a new Phasor() with magnitude initialised to x and PhaseInDegrees initialised to y
Example of Usage:                     aa=Phasor.readPhasor("Input a Phasor ", 3.0e2<22.78deg);
As above, but if the return (enter) key alone is depresed, the default value (3.0e2<22.78deg in the above example) is returned, to aa in the above example. The default value may be passed as a Phasor variable or as a String using one of the above formats.
Usage:                     aa=Phasor.readPhasor();
As above but with no prompt message before entering the Phasor.

WRITE A PHASOR TO THE SCREEN
NOTE: The standard Java output methods, e.g. System.out.println, System.out.print, drawString, will output instances of this class, Phasor, as this Phasor class contains a method that overrides the Java method, toString. In addition the following methods are provided:

public void print(String message)
public void print()
Example of Usage:                     aa.print("The value of the Phasor aa is");
Writes to the screen, e.g. the workstation terminal window, the MS command prompt window, the message followed by the value of the Phasor (in aa in the above example) in the form x<ydeg  e.g. 3.0e2<22.78deg.
Usage:                     aa.print();
Writes to the screen, e.g. the workstation terminal window, the MS command prompt window, the value of a Phasor (in aa in the above example) in the form x<ydeg  e.g. 3.0e2<22.78deg.

public void println(String message)
public void println()
Example of Usage:                     aa.println("The value of the Phasor aa is");
Writes to the screen, e.g. the workstation terminal window, the MSDOS window, the message followed by the value of the Phasor (in aa in the above example) in the form x<ydeg   e.g. 3.0e2<22.78deg, followed by a line return.
Usage:                     aa.println();
Writes to the screen, e.g. the workstation terminal window, the MSDOS window, the value of a Phasor (in aa in the above example) in the form x<ydeg  e.g. 3.0e2<22.78deg, followed by a line return.

See also Type Conversions

WRITE AN ARRAY OF PHASORS TO THE SCREEN
public static void print(String message, Phasor ph[])
public static void print(Phasor ph[])
Example of Usage:                     Phasor.print("The array of Phasors, ph, is", ph);
Writes to the screen, e.g. the workstation terminal window, the MS command prompt window, the message followed by the values of the Phasors in the array argument (ph in the above example) in the form x<ydeg  e.g. 3.0e2<22.78deg. Each value is followed by a space and the last number is followed by a line return.
Usage:                     Phasor.print(Phasor ph[]);
Writes to the screen, e.g. the workstation terminal window, the MS command prompt window, the values of the Phasors in the array argument (ph in the above example) in the form x<ydeg  e.g. 3.0e2<22.78deg. Each value is followed by a space and the last number is followed by a line return.

public static void println(String message, Phasor ph[])
public static void println(Phasor ph[])
Example of Usage:                     Phasor.println("The value of the Phasor ph is", ph);
Writes to the screen, e.g. the workstation terminal window, the MS command prompt window, the message followed by the values of the Phasors in the array argument (ph in the above example) in the form x<ydeg  e.g. 3.0e2<22.78deg. Each value is followed by a line return.
Usage:                     Phasor.println(ph);
Writes to the screen, e.g. the workstation terminal window, the MS command prompt window, the Phasors in the array argument (ph in the above example) in the form x<ydeg  e.g. 3.0e2<22.78deg. Each value is followed by a line return.





TRUNCATE MANTISSAE TO N PLACES
Instance method
public Phasor truncate(int n)
Usage:                      xt=aa.truncate(n);
Returns the value of x with the mantissae of both the magnitude and the phase rounded to n decimal places. If the argument indicating the number of places before truncation, i.e. n in the above example, is any negative integer, the variable to be truncated, i.e. x in the above example, is returned without truncation. This method can be useful in outputting data.

Static method
public static Phasor truncate(Phasor x, int n)
Usage:                      xt = Phasor.truncate(x, n);
Returns the value of x with the mantissae of both the magnitude and phase rounded to n decimal places. If the argument indicating the number of places before truncation, i.e. n in the above example, is any negative integer, the variable to be truncated, i.e. x in the above example, is returned without truncation. This method can be useful in outputting data.



ADDITION
public Phasor plus(Phasor a)
public Phasor plus(Complex a)
Usage:                      z = aa.plus(y);
Performs the operation z = x + y where z and x are Phasor and y may be either Phasor or Complex.

Equivalence of the += operator
public void plusEquals(Phasor a )
public void plusEquals(Complex a )
Usage:                      aa.plusEquals(y);
Performs the operation x = x + y where x is Phasor and y may be either Phasor or Complex.



SUBTRACTION
public Phasor minus(Phasor a)
public Phasor minus(Complex a)
Usage:                      z = aa.minus(y);
Performs the operation z = x - y where z and x are Phasor and y may be either Phasor or Complex.

Equivalence of the -= operator
public void minusEquals(Phasor a )
public void minusEquals(Complex a )
Usage:                      aa.minusEquals(y);
Performs the operation x = x - y where x is Phasor and y may be either Phasor or Complex.



MULTIPLICATION
public Phasor times(Phasor a)
public Phasor times(Complex a)
Usage:                      z = aa.times(y);
Performs the operation z = x*y where z and x are Phasor and y may be either Phasor or Complex.

public Phasor timesExpOmegaTime(double omega, double time)
Usage:                      z = aa.timesExpOmegaTime(omega, time);
Performs the operation z = x*exp(omega.time) where z and x are Phasor, omega is a radial frequency and time is a time in seconds

public Phasor timesExpTwoPiFreqTime(double freq, double time)
Usage:                      z = aa.timesExpTwoPiFreqTime(freq, time);
Performs the operation z = x*exp(2.π.freq.time) where z and x are Phasor, freq is a frequency (Hz) and time is a time in seconds

Equivalence of the *= operator
public void timesEquals(Phasor a )
public void timesEquals(Complex a )
Usage:                      aa.timesEquals(y);
Performs the operation x = x*y where x is Phasor and y may be either Phasor or Complex.

public void timesEqualsExpOmegaTime(double omega, double time)
Usage:                      aa.timesEqualsExpOmegaTime(omega, time);
Performs the operation x = x*exp(omega.time) x is a Phasor, omega is a radial frequency and time is a time in seconds

public void timesEqualsExpTwoPiFreqTime(double freq, double time)
Usage:                      aa.timesEqualsExpTwoPiFreqTime(freq, time);
Performs the operation x = x*exp(2.π.freq.time) where x is a Phasor, freq is a frequency (Hz) and time is a time in seconds



DIVISION
public Phasor over(Phasor a)
public Phasor over(Complex a)
Usage:                      z = aa.over(y);
Performs the operation z = x/y where z and x are Phasor and y may be either Phasor or Complex.

Equivalence of the /= operator
public void overEquals(Phasor a )
public void overEquals(Complex a )
Usage:                      aa.overEquals(y);
Performs the operation x = x/y where x is Phasor and y may be either Phasor or Complex.



RECIPROCAL
Invert a Phasor
public Phasor inverse()
Usage:                      x = y.inverse();
Performs the operation x = 1.0/y.



NEGATION
Negate a Phasor
public Phasor negate()
Usage:                      x = y.negate();
Performs the operation x = -y.



CONJUGATE
Complex conjugate of a Phasor
public Phasor conjugate()
Usage:                      x = y.conjugate();
Returns the complex conjugate of y, i.e. if y = magnitude∠phase returns x = magnitude∠-phase.



EXPONENTIALS
Exponential of a Phasor
public static Phasor exp(Phasor aa)
Usage:                      x = Phasor.exp(y);
where x and y are Phasors.



LOGARITHM OF A PHASOR
Natural log of an Phasor
public static Phasor log(Phasor aa )
Usage:                      x = Phasor.log(y);



ROOT OF A PHASOR
Square root of a Phasor
public static Phasor sqrt(Phasor aa )
Usage:                      x = Phasor.sqrt(y);

The nth root of a Phasor (n = integer > 0)
public static Phasor nthRoot(Phasor aa, int n )
Usage:                      x = Phasor.nthRoot(y, n);
Performs the operation x = the nth root of y where y is Phasor and n is an integer (type int) greater than zero.



POWER OF A PHASOR
Square of a Phasor
public static Phasor square(Phasor aa)
Usage:                      x = Phasor.square(y);

Phasor raised to a power
public static Phasor pow(Phasor a, int b)
public static Phasor pow(Phasor a, double b)
public static Phasor pow(Phasor a, Complex b)
public static Phasor pow(Phasor a, Phasor b)
Usage:                      z = Phasor.pow(x, y);
A phasor x is raised to the power y and returned, as a Phasor, to z where y may be int, double, Complex or Phasor.



MODULUS
Absolute value (modulus) of a Phasor
public double abs()
Usage:                      x = y.abs();
Returns the magnitude of the Phasor y. Performs the same function as the method, getMagnitude().



ARGUMENT
Argument of a Phasor returned as radians
public double argInRadians()
Usage:                      x = y.argInRadians();
Returns the phase of the Phasor y in radians. Performs the same function as getPhaseInRadians().

Argument of a Phasor returned as degrees
public double argIndegrees()
Usage:                      x = y.argIndegrees();
Returns the phase of the Phasor y in degrees. Performs the same function as getPhaseInDegrees().



TRIGONOMETRIC FUNCTIONS
General Usage:                     x = Phasor.funct(y);
where funct is the trigonometric function, e.g. sin.

Sine of an Phasor
public static Phasor sin(Phasor aa )
Cosine of an Phasor
public static Phasor cos(Phasor aa )
Tangent of an Phasor
public static Phasor tan(Phasor aa )
Cotangent of an Phasor
public static Phasor cot(Phasor aa )
Secant of an Phasor
public static Phasor sec(Phasor aa )
Cosecant of an Phasor
public static Phasor csc(Phasor aa )
Exsecant of an Phasor
public static Phasor exsec(Phasor aa )
Versine of an Phasor
public static Phasor vers(Phasor aa )
Coversine of an Phasor
public static Phasor covers(Phasor aa )
Haversine of an Phasor
public static Phasor hav(Phasor aa )

Hyperbolic sine of a Phasor
public static Phasor sinh(Phasor a )
Hyperbolic cosine of a Phasor
public static Phasor cosh(Phasor a )
Hyperbolic tangent of a Phasor
public static Phasor tanh(Phasor a )
Hyperbolic cotangent of a Phasor
public static Phasor coth(Phasor a )
Hyperbolic secant of a Phasor
public static Phasor sech(Phasor a )
Hyperbolic cosecant of a Phasor
public static Phasor csch(Phasor a )

Inverse sine of a Phasor
public static Phasor asin(Phasor a )
Inverse cosine of a Phasor
public static Phasor acos(Phasor a )
Inverse tangent of a Phasor
public static Phasor atan(Phasor a )
Inverse cotangent of an Phasor
public static Phasor acot(Phasor aa )
Inverse secant of an Phasor
public static Phasor asec(Phasor aa )
Inverse cosecant of an Phasor
public static Phasor acsc(Phasor aa )
Inverse exsecant of an Phasor
public static Phasor aexsec(Phasor aa )
Inverse versine of an Phasor
public static Phasor avers(Phasor aa )
Inverse coversine of an Phasor
public static Phasor acovers(Phasor aa )
Inverse haversine of an Phasor
public static Phasor ahav(Phasor aa )

Inverse hyperbolic sine of a Phasor
public static Phasor asinh(Phasor a )
Inverse hyperbolic cosine of a Phasor
public static Phasor acosh(Phasor a )
Inverse hyperbolic tangent of a Phasor
public static Phasor atanh(Phasor a )
Inverse hyperbolic cotangent of a Phasor
public static Phasor acoth(Phasor a )
Inverse hyperbolic secant of a Phasor
public static Phasor asech(Phasor a )
Inverse hyperbolic cosecant of a Phasor
public static Phasor acsch(Phasor a )



LOGICAL FUNCTIONS
public boolean equals(Phasor x)
Returns true if the magnitudes and phases of the Phasors represented by the two Phasor instances are identical; returns false if they are not.
Follows the Sun Java convention of treating two NaNs as equal which does not satisfy the IEEE 754 specification but does let hashtables operate properly.
Example of Usage:                    if (aa.equals(b)){   . . .
where a and b are Phasor
REMEMBER: if(a==b) does not test for equality of the contents of instances of objects, a and b, it only tests the referencing.

public boolean equalsWithinLimits(Phasor x, double limit)
Returns true if the differences between the magnitudes and phases of two Phasors are less the argument limit times the larger of the magnitudes and of the phases; returns false if they are not.
Example of Usage:                    if (aa.equalsWithinLimits(b, limit)){    . . .
where a and b are Phasors and limit is a double.

public boolean isReal()
Returns true if the Phasor has a zero phase; returns false if it does not.
Example of Usage:                     if(aa.isReal()){   . . .
where a is Phasor.

public boolean isZero()
Returns true if the magnitude of the Phasor is zero or if the phase of the Phasor is minus infinity; otherwise returns false.
Example of Usage:                     if (aa.isZero()){   . . .
where a is Phasor.

public boolean isPlusInfinity()
Returns true if either the magnitude and/or the phase of the Phasor is equal to plus infinity; returns false if they are not.
Example of Usage:                     if (aa.isPlusInfinity()){   . . .
where a is Phasor.

public boolean isMinusInfinity()
Returns true if the magnitude of the Phasor is equal to minus infinity; returns false if it is not.
Example of Usage:                     if (aa.isMinusInfinity()){   . . .
where a is Phasor

public boolean isNaN()
Returns true if either the magnitude and/or the phase of the Phasor is NaN (not-a-number)
i.e. is the result of an uninterpretable mathematical operation; returns false if they are not.
Example of Usage:                     if (aa.isNaN()){   . . .
where a is Phasor



TYPE CONVERSIONS
Complex to Phasor
public static Phasor toPhasor(Complex cc)
Usage:                      aa = Phasor.toPhasor(cc);
Converts a Complex, i.e. a rectangular complex number, cc = x + jy, to a Phasor aa, i.e. to the corresponding phasor representation of a complex number.

Phasor to Complex
public Complex toComplex()
public Complex toRectangular()
public static Complex toComplex(Phasor ph)
public static Complex toRectangular(Phasor ph)
Usage:                      Complex cc = aa.toComplex();
Usage:                      Complex cc = aa.toRectangular();
Usage:                      Complex cc = aa.toComplex();
Usage:                      Complex cc = aa.toRectangular();
Converts a phasor aa to a Complex, i.e. to a rectangular complex representation cc = x + jy.

Phasor to VectorMaths
public VectorMaths toVectorMaths()
public static VectorMaths toVectorMaths(Phasor ph)
Usage:                      vec = aa.toVectorMaths();
                                  vec = Phasor.toVectorMaths(ph);

The instance method converts the phasor, aa, to a vector as an instance of VectorMaths, vec. The static method converts the phasor, ph, to a vector as an instance of VectorMaths, vec.

String to Phasor
public static Phasor parsePhasor(String ss)
Usage:                      aa = Phasor.parsePhasor(ss);
If the String, ss, is the String representation of a Phasor, i.e. x<y    xLy    x<ydeg    xLydeg    x<yrad  or  xLyrad        e.g. 3.0e2<22.78deg
the Phasor is returned, as a Phasor, to aa

public static Phasor valueOf(String ss)
Usage:                      aa = Phasor.valueOf(ss);
Method as for parsePhasor above. Phasor.valueOf overides java.lang.Object.valueOf

Phasor to String
public String toString()
public static String toString(Phasor aa)
Usage:                      ss = aa.toString();
Usage:                      ss = Phasor.toString(aa);
Converts the Phasor in aa to a string (referenced by ss in the above example) of the form x<ydeg.
This method overides java.lang.String.toString(). Consequently you may add a Phasor to the string in the standard output methods, e.g. System.out.print(), System.out.println(), g.drawString, and it will automatically be converted to the x<ydeg format on output.

Phasor to hashcode
public int hashCode()
Usage:                      hc = aa.hashCode();
The hashcode for aa is returned to hc.
Overides java.lang.Object.hashCode()



ARRAYS
See Input and output above for printing arrays

Single dimension
public static Phasor[] oneDarray(int n)
public static Phasor[] oneDarray(int n, double a, double b)
public static Phasor[] oneDarray(int n, Phasor xx)

Create a one dimensional array of Phasor objects of length n with all magnitudes = unity and all phases = zero.
Usage:                      Phasor[] aa = Phasor.oneDarray(n);

Create a one dimensional array of Phasor objects of length n with all magnitudes = x and phases = y
Usage:                      Phasor[] aa = Phasor.oneDarray(n, x, y);

Create a one dimensional array of Phasor objects of length n with all array objects = the Phasor zz
Usage:                      Phasor[] aa = Phasor.oneDarray(n, zz);

Two dimensions
public static Phasor[][] twoDarray(int n, int m)
public static Phasor[][] twoDarray(int n, int m, double a, double b)
public static Phasor[][] twoDarray(int n, int m, Phasor xx)

Create a two dimensional array (matrix) of Phasor objects of dimensions n and m with all magnitude = unity and all phases = zero
Usage:                      Phasor[][] aa = Phasor.twoDarray(n, m);

Create a two dimensional array of Phasor objects of dimensions n and m with all magnitude = a and all phases = b
Usage:                      Phasor[][] aa = Phasor.twoDarray(n, m, x, y);

Create a two dimensional array of Phasor objects of dimensions n and m with all Phasor objects in the matrix = the Phasor zz
Usage:                      Phasor[][] aa = Phasor.twoDarray(n, m, zz);

Three dimensions
public static Phasor[][][] threeDarray(int n, int m, int k)
public static Phasor[][][] threeDarray(int n, int m, int k, double a, double b)
public static Phasor[][][] threeDarray(int n, int m, int k, Phasor xx)

Create a three dimensional array of Phasor objects of dimensions n, m and k with all magnitude = unity and all phases = zero
Usage:                      Phasor[][][] aa = Phasor.threeDarray(n, m, k);

Create a three dimensional array of Phasor objects of dimensions n, m and k with all magnitude = a and all PhaseInDegrees = b
Usage:                      Phasor[][][] aa = Phasor.threeDarray(n, m, k, x, y);

Create a three dimensional array of Phasor objects of dimensions n, m and k with all Phasor objects in the matrix = the Phasor zz
Usage:                      Phasor[][][] aa = Phasor.threeDarray(n, m, k, zz);



COPY
REMEMBER: aa = bb; does not copy bb into aa when aa and bb are objects, instead aa becomes a reference (pointer) to bb.
public Phasor copy()
public Object clone()
public static Phasor copy(Phasor a)
public static Phasor[] copy(Phasor[] a)
public static Phasor[][] copy(Phasor[][] a)
public static Phasor[][][] copy(Phasor[][][] a)

Copy a single Phasor
Usage:                      aa = bb.copy();
Usage:                      aa = Phasor.copy(bb);
The Phasor, bb, is copied and returned to aa.

Clone a single Phasor
Usage:                      aa = (Phasor) bb.clone();
The Phasor, bb, is copied and returned to aa. This method overrides java.lang.Object.clone().

Copy a 1D array of Phasors (deep copy)
Usage:                      aa = Phasor.copy(bb);
The Phasor 1D array, bb, is copied and returned to aa.

Copy a 2D array of Phasors (deep copy)
Usage:                      aa = Phasor.copy(bb);
The Phasor 2D array, bb, is copied and returned to aa.

Copy a 3D array of Phasors (deep copy)
Usage:                      aa = Phasor.copy(bb);
The Phasor 3D array, bb, is copied and returned to aa.



SOME USEFUL NUMBERS
Return the number zero (0) as a Phasor
public static Phasor zero()
Usage:                      x = Phasor.zero();
Returns 0.0∠0.0 to x

Return the number one (+1) as a Phasor
public static Phasor plusOne()
Usage:                      x = Phasor.plusOne();
Returns 1.0∠0.0 to x

Return the number minus one (-1) as a Phasor
public static Phasor minusOne()
Usage:                      x = Phasor.minusOne();
Returns -1.0∠0.0 to x

Return a Phasor with given magnitude and zero phase
public static Phasor magnitudeZeroPhase(pdouble magnitude)
Usage:                      x = Phasor.magnitudeZeroPhase(magnitude);
Returns magnitude∠0.0 to x

Return positive infinity
public static Phasor plusInfinity()
Usage:                      x = Phasor.plusInfinity();
Returns Double.POSITIVE_INFINITY∠0.0 to x

Return negative infinity
public static Phasor minusInfinity()
Usage:                      x = Phasor.minusInfinity();
Returns Double.NEGATIVE_INFINITY∠0.0 to x



CIRCUIT COMPONENTS
Resistance as a Phasor
public static Phasor resistancePhasor(double Resistance)
Usage:                      x = Phasor.resistancePhasor(resistance);
Returns the impedance of a resistor, passed as resistance in ohms, as a Phasor x.

Capacitance as a Phasor
public static Phasor capacitancePhasor(double capacitance, double frequency)
Usage:                      x = Phasor.capacitancePhasor(capacitance, frequency);
Returns the impedance of a capacitor, passed as capacitance in farads, at a frequency, frequency in Hz, as a Phasor x. This class does not allow the value of the frequency to be altered once a value has been entered.

Inductance as a Phasor
public static Phasor inductancePhasor(double inductance, double frequency)
Usage:                      x = Phasor.inductancePhasor(inductance, frequency);
Returns the impedance of an inductor, passed as inductance in henrys, at a frequency, frequency in Hz, as a Phasor x. This class does not allow the value of the frequency to be altered once a value has been entered.

Infinite diffusion layer Warburg impedance as a Phasor
public static Phasor infiniteWarburgPhasor(double sigma, double frequency)
Usage:                      x = Phasor.infiniteWarburgPhasor(sigma, frequency);
Returns an infinite diffusion layer Warburg impedance, of σ parameter sigma, at a frequency, frequency in Hz, as a Phasor x. This class does not allow the value of the frequency to be altered once a value has been entered. See Impedance for details of Warburg impedances.

Finite diffusion layer Warburg impedance as a Phasor
public static Phasor finiteWarburgPhasor(double sigma, double delta,double frequency)
Usage:                      x = Phasor.finiteWarburgPhasor(sigma, delta, frequency);
Returns an finite diffusion layer Warburg impedance, of σ and δ parameters sigma and delta, at a frequency, frequency in Hz, as a Phasor x. This class does not allow the value of the frequency to be altered once a value has been entered. See Impedance for details of Warburg impedances.

Constant phase element as a Phasor
public static Phasor constantPhaseElementPhasor(double sigma, double alpha,double frequency)
Usage:                      x = Phasor.constantPhaseElementPhasor(sigma, alpha, frequency);
Returns an constant phase element impedance, of σ and α parameters sigma and alpha, at a frequency, frequency in Hz, as a Phasor x. This class does not allow the value of the frequency to be altered once a value has been entered. See Impedance for details of Constant phase element impedances.



OTHER CLASSES USED BY THIS CLASS

This class uses the following classes in this library:



This page was prepared by Dr Michael Thomas Flanagan