public class Complexf extends Object implements Imaginaryf, Comparable<Complexf>, Serializable, Cloneable
x + yi. The x and y components are stored as floats. This class is immutable.| Modifier and Type | Field and Description |
|---|---|
static Complexf |
IDENTITY
An immutable identity (1, 0) complex.
|
static Complexf |
ZERO
An immutable identity (0, 0) complex.
|
| Constructor and Description |
|---|
Complexf()
Constructs a new complex.
|
Complexf(Complexf c)
Copy constructor.
|
Complexf(double x,
double y)
Constructs a new complex from the double components.
|
Complexf(float x,
float y)
Constructs a new complex from the float components.
|
| Modifier and Type | Method and Description |
|---|---|
Complexf |
add(Complexf c)
Adds another complex to this one.
|
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 |
clone() |
int |
compareTo(Complexf c) |
Complexf |
conjugate()
Returns the conjugate of this complex.
|
Complexf |
div(Complexf c)
Divides this complex by another one.
|
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.
|
float |
dot(Complexf c)
Returns the dot product of this complex with 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.
|
boolean |
equals(Object o) |
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.
|
float |
getAngleDeg()
Returns the angle in degrees formed by the direction vector of this complex on the complex plane.
|
float |
getAngleRad()
Returns the angle in radians formed by the direction vector of this complex on the complex plane.
|
Vector2f |
getDirection()
Returns a unit vector pointing in the same direction as this complex on the complex plane.
|
float |
getX()
Gets the x (real) component of this complex.
|
float |
getY()
Gets the y (imaginary) component of this complex.
|
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(Complexf c)
Multiplies another complex with this one.
|
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 |
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(Complexf c)
Subtracts another complex from this one.
|
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.
|
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() |
public static final Complexf ZERO
public static final Complexf IDENTITY
public Complexf()
public Complexf(double x,
double y)
x - The x (real) componenty - The y (imaginary) componentpublic Complexf(float x,
float y)
x - The x (real) componenty - The y (imaginary) componentpublic Complexf(Complexf c)
c - The complex to copypublic float getX()
public float getY()
public Complexf add(Complexf c)
c - The complex to addpublic Complexf add(double x, double y)
x - The x (real) component of the complex to addy - The y (imaginary) component of the complex to addpublic Complexf add(float x, float y)
x - The x (real) component of the complex to addy - The y (imaginary) component of the complex to addpublic Complexf sub(Complexf c)
c - The complex to subtractpublic Complexf sub(double x, double y)
x - The x (real) component of the complex to subtracty - The y (imaginary) component of the complex to subtractpublic Complexf sub(float x, float y)
x - The x (real) component of the complex to subtracty - The y (imaginary) component of the complex to subtractpublic Complexf mul(double a)
a - The multiplication scalarpublic Complexf mul(float a)
mul in interface Imaginaryfa - The multiplication scalarpublic Complexf mul(Complexf c)
c - The complex to multiply withpublic Complexf mul(double x, double y)
x - The x (real) component of the complex to multiply withy - The y (imaginary) component of the complex to multiply withpublic Complexf mul(float x, float y)
x - The x (real) component of the complex to multiply withy - The y (imaginary) component of the complex to multiply withpublic Complexf div(double a)
a - The division scalarpublic Complexf div(float a)
div in interface Imaginaryfa - The division scalarpublic Complexf div(Complexf c)
c - The complex to divide withpublic Complexf div(double x, double y)
x - The x (real) component of the complex to divide withy - The y (imaginary) component of the complex to divide withpublic Complexf div(float x, float y)
x - The x (real) component of the complex to divide withy - The y (imaginary) component of the complex to divide withpublic float dot(Complexf c)
c - The complex to calculate the dot product withpublic float dot(double x,
double y)
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 withpublic float dot(float x,
float y)
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 withpublic Vector2f rotate(Vector2f v)
v - The vector to rotatepublic Vector2f rotate(double x, double y)
x - The x component of the vectory - The y component of the vectorpublic Vector2f rotate(float x, float y)
x - The x component of the vectory - The y component of the vectorpublic Vector2f getDirection()
public float getAngleRad()
public float getAngleDeg()
public Complexf conjugate()
a is an operation returning complex a' such that a' * a = a * a' = |a|2 where
|a|2 is squared length of a.conjugate in interface Imaginaryfpublic Complexf invert()
a returns complex a-1 = a' / |a|2 where a' is conjugation of a, and |a|2 is squared length of a. a, b, c, such that a * b = c equations
a-1 * c = b and c * b-1 = a are true.invert in interface Imaginaryfpublic float lengthSquared()
lengthSquared in interface Imaginaryfpublic float length()
length in interface Imaginaryfpublic Complexf normalize()
normalize in interface Imaginaryfpublic Quaternionf toQuaternion()
public Quaternionf toQuaternion(Vector3f axis)
axis - The rotation axispublic Quaternionf toQuaternion(double x, double y, double z)
x - The x component of the axis vectory - The y component of the axis vectorz - The z component of the axis vectorpublic Quaternionf toQuaternion(float x, float y, float z)
x - The x component of the axis vectory - The y component of the axis vectorz - The z component of the axis vectorpublic Complexf toFloat()
toFloat in interface Imaginaryfpublic Complexd toDouble()
toDouble in interface Imaginaryfpublic int compareTo(Complexf c)
compareTo in interface Comparable<Complexf>public static Complexf fromReal(float x)
The ZERO constant is re-used when x is 0.
x - The x (real) componentpublic static Complexf fromImaginary(float y)
The ZERO constant is re-used when y is 0.
y - The y (imaginary) componentpublic static Complexf from(float x, float y)
The ZERO constant is re-used when both x and z are 0.
x - The x (real) componenty - The y (imaginary) componentpublic static Complexf fromRotationTo(Vector2f from, Vector2f to)
from - The first vectorto - The second vectorpublic static Complexf fromRotationTo(Vector3f from, Vector3f to)
from - The first vectorto - The second vectorpublic static Complexf fromAngleDeg(double angle)
angle - The angle in degreespublic static Complexf fromAngleRad(double angle)
angle - The angle in radianspublic static Complexf fromAngleDeg(float angle)
angle - The angle in radianspublic static Complexf fromAngleRad(float angle)
angle - The angle in radiansCopyright © 2013–2016 Flow Powered. All rights reserved.