 java.lang.Object

 org.spongepowered.math.imaginary.Complexf

 All Implemented Interfaces:
Serializable
,Comparable<Complexf>
,Imaginaryf
@Immutable public final class Complexf extends Object implements Imaginaryf, Comparable<Complexf>, Serializable
Represent a complex number of the formx + yi
. The x and y components are stored asfloat
s. This class is immutable. See Also:
 Serialized Form


Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Complexf
add(double x, double y)
Adds the double components of another complex to this one.Complexf
add(float x, float y)
Adds the float components of another complex to this one.Complexf
add(Complexf c)
Adds another complex to this one.float
angleDeg()
Returns the angle in degrees formed by the direction vector of this complex on the complex plane.float
angleRad()
Returns the angle in radians formed by the direction vector of this complex on the complex plane.int
compareTo(Complexf that)
Complexf
conjugate()
Returns the conjugate of this complex.Vector2f
direction()
Returns a unit vector pointing in the same direction as this complex on the complex plane.Complexf
div(double a)
Divides the components of this complex by a double scalar.Complexf
div(double x, double y)
Divides this complex by the double components of another one.Complexf
div(float a)
Divides the components of this complex by a float scalar.Complexf
div(float x, float y)
Divides this complex by the float components of another one.Complexf
div(Complexf c)
Divides this complex by another one.float
dot(double x, double y)
Returns the dot product of this complex with the double components of another one.float
dot(float x, float y)
Returns the dot product of this complex with the float components of another one.float
dot(Complexf c)
Returns the dot product of this complex with another one.boolean
equals(Object other)
static Complexf
from(float x, float y)
Creates a new complex from the float components.static Complexf
fromAngleDeg(double angle)
Creates a new complex from the double angle in degrees.static Complexf
fromAngleDeg(float angle)
Creates a new complex from the float angle in radians.static Complexf
fromAngleRad(double angle)
Creates a new complex from the double angle in radians.static Complexf
fromAngleRad(float angle)
Creates a new complex from the float angle in radians.static Complexf
fromImaginary(float y)
Creates a new complex from the float imaginary components.static Complexf
fromReal(float x)
Creates a new complex from the float real component.static Complexf
fromRotationTo(Vector2f from, Vector2f to)
Creates a new complex from the angle defined from the first to the second vector.static Complexf
fromRotationTo(Vector3f from, Vector3f to)
Creates a new complex from the angle defined from the first to the second vector.int
hashCode()
Complexf
invert()
Returns the inverse of this complex.float
length()
Returns the length of this complex.float
lengthSquared()
Returns the square of the length of this complex.Complexf
mul(double a)
Multiplies the components of this complex by a double scalar.Complexf
mul(double x, double y)
Multiplies the double components of another complex with this one.Complexf
mul(float a)
Multiplies the components of this complex by a float scalar.Complexf
mul(float x, float y)
Multiplies the float components of another complex with this one.Complexf
mul(Complexf c)
Multiplies another complex with this one.Complexf
normalize()
Normalizes this complex.Vector2f
rotate(double x, double y)
Rotates the double components of a vector by this complex.Vector2f
rotate(float x, float y)
Rotates the float components of a vector by this complex.Vector2f
rotate(Vector2f v)
Rotates a vector by this complex.Complexf
sub(double x, double y)
Subtracts the double components of another complex from this one.Complexf
sub(float x, float y)
Subtracts the float components of another complex from this one.Complexf
sub(Complexf c)
Subtracts another complex from this one.Complexd
toDouble()
Complexf
toFloat()
Quaternionf
toQuaternion()
Converts this complex to a quaternion by using (0, 0, 1) as a rotation axis.Quaternionf
toQuaternion(double x, double y, double z)
Converts this complex to a quaternion by using the provided double components vector as a rotation axis.Quaternionf
toQuaternion(float x, float y, float z)
Converts this complex to a quaternion by using the provided float components vector as a rotation axis.Quaternionf
toQuaternion(Vector3f axis)
Converts this complex to a quaternion by using the provided vector as a rotation axis.String
toString()
float
x()
Gets the x (real) component of this complex.float
y()
Gets the y (imaginary) component of this complex.



Constructor Detail

Complexf
public Complexf(double x, double y)
Constructs a new complex from the double components. Parameters:
x
 The x (real) componenty
 The y (imaginary) component

Complexf
public Complexf(float x, float y)
Constructs a new complex from the float components. Parameters:
x
 The x (real) componenty
 The y (imaginary) component


Method Detail

x
public float x()
Gets the x (real) component of this complex. Returns:
 The x (real) component

y
public float y()
Gets the y (imaginary) component of this complex. Returns:
 The y (imaginary) component

add
public Complexf add(Complexf c)
Adds another complex to this one. Parameters:
c
 The complex to add Returns:
 A new complex, which is the sum of both

add
public Complexf add(double x, double y)
Adds the double components of another complex to this one. Parameters:
x
 The x (real) component of the complex to addy
 The y (imaginary) component of the complex to add Returns:
 A new complex, which is the sum of both

add
public Complexf add(float x, float y)
Adds the float components of another complex to this one. Parameters:
x
 The x (real) component of the complex to addy
 The y (imaginary) component of the complex to add Returns:
 A new complex, which is the sum of both

sub
public Complexf sub(Complexf c)
Subtracts another complex from this one. Parameters:
c
 The complex to subtract Returns:
 A new complex, which is the difference of both

sub
public Complexf sub(double x, double y)
Subtracts the double components of another complex from this one. Parameters:
x
 The x (real) component of the complex to subtracty
 The y (imaginary) component of the complex to subtract Returns:
 A new complex, which is the difference of both

sub
public Complexf sub(float x, float y)
Subtracts the float components of another complex from this one. Parameters:
x
 The x (real) component of the complex to subtracty
 The y (imaginary) component of the complex to subtract Returns:
 A new complex, which is the difference of both

mul
public Complexf mul(double a)
Multiplies the components of this complex by a double scalar. Parameters:
a
 The multiplication scalar Returns:
 A new complex, which has each component multiplied by the scalar

mul
public Complexf mul(float a)
Multiplies the components of this complex by a float scalar. Specified by:
mul
in interfaceImaginaryf
 Parameters:
a
 The multiplication scalar Returns:
 A new complex, which has each component multiplied by the scalar

mul
public Complexf mul(Complexf c)
Multiplies another complex with this one. Parameters:
c
 The complex to multiply with Returns:
 A new complex, which is the product of both

mul
public Complexf mul(double x, double y)
Multiplies the double components of another complex with this one. Parameters:
x
 The x (real) component of the complex to multiply withy
 The y (imaginary) component of the complex to multiply with Returns:
 A new complex, which is the product of both

mul
public Complexf mul(float x, float y)
Multiplies the float components of another complex with this one. Parameters:
x
 The x (real) component of the complex to multiply withy
 The y (imaginary) component of the complex to multiply with Returns:
 A new complex, which is the product of both

div
public Complexf div(double a)
Divides the components of this complex by a double scalar. Parameters:
a
 The division scalar Returns:
 A new complex, which has each component divided by the scalar

div
public Complexf div(float a)
Divides the components of this complex by a float scalar. Specified by:
div
in interfaceImaginaryf
 Parameters:
a
 The division scalar Returns:
 A new complex, which has each component divided by the scalar

div
public Complexf div(Complexf c)
Divides this complex by another one. Parameters:
c
 The complex to divide with Returns:
 The quotient of the two complexes

div
public Complexf div(double x, double y)
Divides this complex by the double components of another one. Parameters:
x
 The x (real) component of the complex to divide withy
 The y (imaginary) component of the complex to divide with Returns:
 The quotient of the two complexes

div
public Complexf div(float x, float y)
Divides this complex by the float components of another one. Parameters:
x
 The x (real) component of the complex to divide withy
 The y (imaginary) component of the complex to divide with Returns:
 The quotient of the two complexes

dot
public float dot(Complexf c)
Returns the dot product of this complex with another one. Parameters:
c
 The complex to calculate the dot product with Returns:
 The dot product of the two complexes

dot
public float dot(double x, double y)
Returns the dot product of this complex with the double components of another one. Parameters:
x
 The x (real) component of the complex to calculate the dot product withy
 The y (imaginary) component of the complex to calculate the dot product with Returns:
 The dot product of the two complexes

dot
public float dot(float x, float y)
Returns the dot product of this complex with the float components of another one. Parameters:
x
 The x (real) component of the complex to calculate the dot product withy
 The y (imaginary) component of the complex to calculate the dot product with Returns:
 The dot product of the two complexes

rotate
public Vector2f rotate(Vector2f v)
Rotates a vector by this complex. Parameters:
v
 The vector to rotate Returns:
 The rotated vector

rotate
public Vector2f rotate(double x, double y)
Rotates the double components of a vector by this complex. Parameters:
x
 The x component of the vectory
 The y component of the vector Returns:
 The rotated vector

rotate
public Vector2f rotate(float x, float y)
Rotates the float components of a vector by this complex. Parameters:
x
 The x component of the vectory
 The y component of the vector Returns:
 The rotated vector

direction
public Vector2f direction()
Returns a unit vector pointing in the same direction as this complex on the complex plane. Returns:
 The vector representing the direction this complex is pointing to

angleRad
public float angleRad()
Returns the angle in radians formed by the direction vector of this complex on the complex plane. Returns:
 The angle in radians of the direction vector of this complex

angleDeg
public float angleDeg()
Returns the angle in degrees formed by the direction vector of this complex on the complex plane. Returns:
 The angle in degrees of the direction vector of this complex

conjugate
public Complexf conjugate()
Returns the conjugate of this complex.
Conjugation of a complexa
is an operation returning complexa'
such thata' * a = a * a' = a^{2}
wherea^{2}
is squared length ofa
. Specified by:
conjugate
in interfaceImaginaryf
 Returns:
 A new complex, which is the conjugate of this one

invert
public Complexf invert()
Returns the inverse of this complex.
Inversion of a complexa
returns complexa^{1} = a' / a^{2}
wherea'
isconjugation
ofa
, anda^{2}
is squared length ofa
.
For any complexesa, b, c
, such thata * b = c
equationsa^{1} * c = b
andc * b^{1} = a
are true. Specified by:
invert
in interfaceImaginaryf
 Returns:
 A new complex, which is the inverse of this one

lengthSquared
public float lengthSquared()
Returns the square of the length of this complex. Specified by:
lengthSquared
in interfaceImaginaryf
 Returns:
 The square of the length

length
public float length()
Returns the length of this complex. Specified by:
length
in interfaceImaginaryf
 Returns:
 The length

normalize
public Complexf normalize()
Normalizes this complex. Specified by:
normalize
in interfaceImaginaryf
 Returns:
 A new complex of unit length

toQuaternion
public Quaternionf toQuaternion()
Converts this complex to a quaternion by using (0, 0, 1) as a rotation axis. Returns:
 A quaternion of this rotation around the unit z

toQuaternion
public Quaternionf toQuaternion(Vector3f axis)
Converts this complex to a quaternion by using the provided vector as a rotation axis. Parameters:
axis
 The rotation axis Returns:
 A quaternion of this rotation around the given axis

toQuaternion
public Quaternionf toQuaternion(double x, double y, double z)
Converts this complex to a quaternion by using the provided double components vector as a rotation axis. Parameters:
x
 The x component of the axis vectory
 The y component of the axis vectorz
 The z component of the axis vector Returns:
 A quaternion of this rotation around the given axis

toQuaternion
public Quaternionf toQuaternion(float x, float y, float z)
Converts this complex to a quaternion by using the provided float components vector as a rotation axis. Parameters:
x
 The x component of the axis vectory
 The y component of the axis vectorz
 The z component of the axis vector Returns:
 A quaternion of this rotation around the given axis

toFloat
public Complexf toFloat()
 Specified by:
toFloat
in interfaceImaginaryf

toDouble
public Complexd toDouble()
 Specified by:
toDouble
in interfaceImaginaryf

compareTo
public int compareTo(Complexf that)
 Specified by:
compareTo
in interfaceComparable<Complexf>

fromReal
public static Complexf fromReal(float x)
Creates a new complex from the float real component.The
ZERO
constant is reused whenx
is 0. Parameters:
x
 The x (real) component Returns:
 The complex created from the float real component

fromImaginary
public static Complexf fromImaginary(float y)
Creates a new complex from the float imaginary components.The
ZERO
constant is reused wheny
is 0. Parameters:
y
 The y (imaginary) component Returns:
 The complex created from the float imaginary component

from
public static Complexf from(float x, float y)
Creates a new complex from the float components.The
ZERO
constant is reused when bothx
andz
are 0. Parameters:
x
 The x (real) componenty
 The y (imaginary) component Returns:
 The complex created from the float components

fromRotationTo
public static Complexf fromRotationTo(Vector2f from, Vector2f to)
Creates a new complex from the angle defined from the first to the second vector. Parameters:
from
 The first vectorto
 The second vector Returns:
 The complex defined by the angle between the vectors

fromRotationTo
public static Complexf fromRotationTo(Vector3f from, Vector3f to)
Creates a new complex from the angle defined from the first to the second vector. Parameters:
from
 The first vectorto
 The second vector Returns:
 The complex defined by the angle between the vectors

fromAngleDeg
public static Complexf fromAngleDeg(double angle)
Creates a new complex from the double angle in degrees. Parameters:
angle
 The angle in degrees Returns:
 The complex defined by the angle

fromAngleRad
public static Complexf fromAngleRad(double angle)
Creates a new complex from the double angle in radians. Parameters:
angle
 The angle in radians Returns:
 The complex defined by the angle

fromAngleDeg
public static Complexf fromAngleDeg(float angle)
Creates a new complex from the float angle in radians. Parameters:
angle
 The angle in radians Returns:
 The complex defined by the angle

fromAngleRad
public static Complexf fromAngleRad(float angle)
Creates a new complex from the float angle in radians. Parameters:
angle
 The angle in radians Returns:
 The complex defined by the angle

