public class Complexd extends Object implements Imaginaryd, Comparable<Complexd>, Serializable, Cloneable
x + yi. The x and y components are stored as doubles. This class is immutable.| Modifier and Type | Field and Description |
|---|---|
static Complexd |
IDENTITY
An immutable identity (1, 0) complex.
|
static Complexd |
ZERO
An immutable identity (0, 0) complex.
|
| Constructor and Description |
|---|
Complexd()
Constructs a new complex.
|
Complexd(Complexd c)
Copy constructor.
|
Complexd(double x,
double y)
Constructs a new complex from the double components.
|
Complexd(float x,
float y)
Constructs a new complex from the float components.
|
| Modifier and Type | Method and Description |
|---|---|
Complexd |
add(Complexd c)
Adds another complex to this one.
|
Complexd |
add(double x,
double y)
Adds the double components of another complex to this one.
|
Complexd |
add(float x,
float y)
Adds the float components of another complex to this one.
|
Complexd |
clone() |
int |
compareTo(Complexd c) |
Complexd |
conjugate()
Returns the conjugate of this complex.
|
Complexd |
div(Complexd c)
Divides this complex by another one.
|
Complexd |
div(double a)
Divides the components of this complex by a double scalar.
|
Complexd |
div(double x,
double y)
Divides this complex by the double components of another one.
|
Complexd |
div(float a)
Divides the components of this complex by a float scalar.
|
Complexd |
div(float x,
float y)
Divides this complex by the float components of another one.
|
double |
dot(Complexd c)
Returns the dot product of this complex with another one.
|
double |
dot(double x,
double y)
Returns the dot product of this complex with the double components of another one.
|
double |
dot(float x,
float y)
Returns the dot product of this complex with the float components of another one.
|
boolean |
equals(Object o) |
static Complexd |
from(double x,
double y)
Creates a new complex from the double components.
|
static Complexd |
fromAngleDeg(double angle)
Creates a new complex from the double angle in radians.
|
static Complexd |
fromAngleDeg(float angle)
Creates a new complex from the float angle in degrees.
|
static Complexd |
fromAngleRad(double angle)
Creates a new complex from the double angle in radians.
|
static Complexd |
fromAngleRad(float angle)
Creates a new complex from the float angle in radians.
|
static Complexd |
fromImaginary(double y)
Creates a new complex from the double imaginary components.
|
static Complexd |
fromReal(double x)
Creates a new complex from the double real component.
|
static Complexd |
fromRotationTo(Vector2d from,
Vector2d to)
Creates a new complex from the angle defined from the first to the second vector.
|
static Complexd |
fromRotationTo(Vector3d from,
Vector3d to)
Creates a new complex from the angle defined from the first to the second vector.
|
double |
getAngleDeg()
Returns the angle in degrees formed by the direction vector of this complex on the complex plane.
|
double |
getAngleRad()
Returns the angle in radians formed by the direction vector of this complex on the complex plane.
|
Vector2d |
getDirection()
Returns a unit vector pointing in the same direction as this complex on the complex plane.
|
double |
getX()
Gets the x (real) component of this complex.
|
double |
getY()
Gets the y (imaginary) component of this complex.
|
int |
hashCode() |
Complexd |
invert()
Returns the inverse of this complex.
|
double |
length()
Returns the length of this complex.
|
double |
lengthSquared()
Returns the square of the length of this complex.
|
Complexd |
mul(Complexd c)
Multiplies another complex with this one.
|
Complexd |
mul(double a)
Multiplies the components of this complex by a double scalar.
|
Complexd |
mul(double x,
double y)
Multiplies the double components of another complex with this one.
|
Complexd |
mul(float a)
Multiplies the components of this complex by a float scalar.
|
Complexd |
mul(float x,
float y)
Multiplies the float components of another complex with this one.
|
Complexd |
normalize()
Normalizes this complex.
|
Vector2d |
rotate(double x,
double y)
Rotates the double components of a vector by this complex.
|
Vector2d |
rotate(float x,
float y)
Rotates the float components of a vector by this complex.
|
Vector2d |
rotate(Vector2d v)
Rotates a vector by this complex.
|
Complexd |
sub(Complexd c)
Subtracts another complex from this one.
|
Complexd |
sub(double x,
double y)
Subtracts the double components of another complex from this one.
|
Complexd |
sub(float x,
float y)
Subtracts the float components of another complex from this one.
|
Complexd |
toDouble() |
Complexf |
toFloat() |
Quaterniond |
toQuaternion()
Converts this complex to a quaternion by
using (0, 0, 1) as a rotation axis.
|
Quaterniond |
toQuaternion(double x,
double y,
double z)
Converts this complex to a quaternion by
using the provided double components vector
as a rotation axis.
|
Quaterniond |
toQuaternion(float x,
float y,
float z)
Converts this complex to a quaternion by
using the provided float components vector
as a rotation axis.
|
Quaterniond |
toQuaternion(Vector3d axis)
Converts this complex to a quaternion by
using the provided vector as a rotation axis.
|
String |
toString() |
public static final Complexd ZERO
public static final Complexd IDENTITY
public Complexd()
public Complexd(float x,
float y)
x - The x (real) componenty - The y (imaginary) componentpublic Complexd(double x,
double y)
x - The x (real) componenty - The y (imaginary) componentpublic Complexd(Complexd c)
c - The complex to copypublic double getX()
public double getY()
public Complexd add(Complexd c)
c - The complex to addpublic Complexd add(float x, float y)
x - The x (real) component of the complex to addy - The y (imaginary) component of the complex to addpublic Complexd add(double x, double y)
x - The x (real) component of the complex to addy - The y (imaginary) component of the complex to addpublic Complexd sub(Complexd c)
c - The complex to subtractpublic Complexd sub(float x, float y)
x - The x (real) component of the complex to subtracty - The y (imaginary) component of the complex to subtractpublic Complexd sub(double x, double y)
x - The x (real) component of the complex to subtracty - The y (imaginary) component of the complex to subtractpublic Complexd mul(float a)
a - The multiplication scalarpublic Complexd mul(double a)
mul in interface Imaginaryda - The multiplication scalarpublic Complexd mul(Complexd c)
c - The complex to multiply withpublic Complexd 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 Complexd 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 Complexd div(float a)
a - The division scalarpublic Complexd div(double a)
div in interface Imaginaryda - The division scalarpublic Complexd div(Complexd c)
c - The complex to divide withpublic Complexd 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 Complexd 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 double dot(Complexd c)
c - The complex to calculate the dot product withpublic double 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 double 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 Vector2d rotate(Vector2d v)
v - The vector to rotatepublic Vector2d rotate(float x, float y)
x - The x component of the vectory - The y component of the vectorpublic Vector2d rotate(double x, double y)
x - The x component of the vectory - The y component of the vectorpublic Vector2d getDirection()
public double getAngleRad()
public double getAngleDeg()
public Complexd 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 Imaginarydpublic Complexd 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 Imaginarydpublic double lengthSquared()
lengthSquared in interface Imaginarydpublic double length()
length in interface Imaginarydpublic Complexd normalize()
normalize in interface Imaginarydpublic Quaterniond toQuaternion()
public Quaterniond toQuaternion(Vector3d axis)
axis - The rotation axispublic Quaterniond 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 Quaterniond 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 Complexf toFloat()
toFloat in interface Imaginarydpublic Complexd toDouble()
toDouble in interface Imaginarydpublic int compareTo(Complexd c)
compareTo in interface Comparable<Complexd>public static Complexd fromReal(double x)
The ZERO constant is re-used when x is 0.
x - The x (real) componentpublic static Complexd fromImaginary(double y)
The ZERO constant is re-used when y is 0.
y - The y (imaginary) componentpublic static Complexd from(double x, double y)
The ZERO constant is re-used when both x and z are 0.
x - The x (real) componenty - The y (imaginary) componentpublic static Complexd fromRotationTo(Vector2d from, Vector2d to)
from - The first vectorto - The second vectorpublic static Complexd fromRotationTo(Vector3d from, Vector3d to)
from - The first vectorto - The second vectorpublic static Complexd fromAngleDeg(float angle)
angle - The angle in degreespublic static Complexd fromAngleRad(float angle)
angle - The angle in radianspublic static Complexd fromAngleDeg(double angle)
angle - The angle in radianspublic static Complexd fromAngleRad(double angle)
angle - The angle in radiansCopyright © 2013–2016 Flow Powered. All rights reserved.