Package com.actelion.research.chem
Class Coordinates
- java.lang.Object
-
- com.actelion.research.chem.Coordinates
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Coordinates>
public final class Coordinates extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<Coordinates>
Class to encapsulate 3D coordinates- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Coordinates()
Coordinates(double x, double y, double z)
Coordinates(Coordinates c)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(double dx, double dy, double dz)
Coordinates
add(Coordinates c)
Coordinates
addC(Coordinates c)
Coordinates
between(Coordinates c1, Coordinates c2, double f)
Updates this to contain a point on the straight line through c1 and c2.Coordinates
center(Coordinates c)
Calculates the center point between this and c and sets this to the center point.void
center(Coordinates c1, Coordinates c2)
Updates this to contains the center between c1 and c2.int
compareTo(Coordinates o)
double
cosAngle(Coordinates c)
static Coordinates
createBarycenter(Coordinates... coords)
Coordinates
cross(Coordinates c)
double
dist()
double
distance(Coordinates c)
double
distanceSquared(Coordinates c)
double
distSq()
double
distSquareTo(Coordinates c)
double
dot(Coordinates c)
boolean
equals(java.lang.Object o)
double
getAngle(Coordinates c)
Gets the angle formed between the 2 vectors ([0,PI])double
getAngleXY(Coordinates c)
Calculates the angle of the line from this location to c projected into the x/y plane.double
getDihedral(Coordinates c2, Coordinates c3, Coordinates c4)
static double
getDihedral(Coordinates c1, Coordinates c2, Coordinates c3, Coordinates c4)
Calculates a signed torsion as an exterior spherical angle from a valid sequence of 4 points in space.double
getLength()
static Coordinates
getMirror(Coordinates p, Coordinates c1, Coordinates c2, Coordinates c3)
Get the mirror image of p through the plane defined by c1, c2, c3static double
getRmsd(Coordinates[] c1, Coordinates[] c2)
static double
getRmsd(Coordinates[] c1, Coordinates[] c2, int l)
boolean
insideBounds(Coordinates[] bounds)
boolean
isNaN()
Coordinates
max(Coordinates c)
static Coordinates
max(Coordinates[] c)
Coordinates
min(Coordinates c)
static Coordinates
min(Coordinates[] c)
void
negate()
static Coordinates
random()
Coordinates
rotate(double[][] m)
Coordinates
rotate(Coordinates normal, double theta)
Coordinates
rotateC(double[][] m)
Coordinates
scale(double scale)
Coordinates
scaleC(double scale)
void
set(double x, double y, double z)
Coordinates
set(Coordinates c)
Copies x,y,z from c to thisCoordinates
sub(Coordinates c)
Coordinates
subC(Coordinates c)
java.lang.String
toString()
java.lang.String
toStringSpaceDelimited()
Coordinates
unit()
Coordinates
unitC()
-
-
-
Constructor Detail
-
Coordinates
public Coordinates()
-
Coordinates
public Coordinates(Coordinates c)
-
Coordinates
public Coordinates(double x, double y, double z)
-
-
Method Detail
-
set
public Coordinates set(Coordinates c)
Copies x,y,z from c to this- Parameters:
c
-- Returns:
- this after copying c
-
set
public void set(double x, double y, double z)
-
getLength
public double getLength()
-
dist
public final double dist()
-
distSq
public final double distSq()
-
distanceSquared
public final double distanceSquared(Coordinates c)
-
distSquareTo
public final double distSquareTo(Coordinates c)
-
distance
public final double distance(Coordinates c)
-
dot
public final double dot(Coordinates c)
-
cross
public final Coordinates cross(Coordinates c)
-
getAngle
public final double getAngle(Coordinates c)
Gets the angle formed between the 2 vectors ([0,PI])- Parameters:
c
-- Returns:
- angle in radian
-
getAngleXY
public double getAngleXY(Coordinates c)
Calculates the angle of the line from this location to c projected into the x/y plane. With Y facing upwards and X right, if the line points in Y direction, ten angle is 0.0 increasing in clockwise direction.- Parameters:
c
-- Returns:
- -PI < angle < PI
-
getDihedral
public final double getDihedral(Coordinates c2, Coordinates c3, Coordinates c4)
-
subC
public final Coordinates subC(Coordinates c)
-
addC
public final Coordinates addC(Coordinates c)
-
scaleC
public final Coordinates scaleC(double scale)
-
sub
public final Coordinates sub(Coordinates c)
- Parameters:
c
-- Returns:
- this after subtracting c
-
add
public final Coordinates add(Coordinates c)
- Parameters:
c
-- Returns:
- this after subtracting c
-
add
public void add(double dx, double dy, double dz)
-
scale
public final Coordinates scale(double scale)
- Parameters:
scale
-- Returns:
- this after scaling this
-
negate
public final void negate()
-
rotate
public Coordinates rotate(double[][] m)
- Parameters:
m
-- Returns:
- this after rotating it with rotation matrix m
-
rotateC
public Coordinates rotateC(double[][] m)
- Parameters:
m
-- Returns:
- new Coordinates created from this point rotated by rotation matrix m
-
rotate
public final Coordinates rotate(Coordinates normal, double theta)
-
unitC
public final Coordinates unitC()
- Returns:
- new Coordinates with a copy of this scaled to length=1.0
-
unit
public final Coordinates unit()
- Returns:
- this after scaling it to length=1.0
-
center
public Coordinates center(Coordinates c)
Calculates the center point between this and c and sets this to the center point.- Parameters:
c
-- Returns:
- this after updating it to the center position
-
center
public void center(Coordinates c1, Coordinates c2)
Updates this to contains the center between c1 and c2.- Parameters:
c1
-c2
-
-
between
public Coordinates between(Coordinates c1, Coordinates c2, double f)
Updates this to contain a point on the straight line through c1 and c2.- Parameters:
c1
-c2
-f
- location on line 0.0 -> c1, 1.0 -> c2- Returns:
- this after updating to be a point on the line
-
insideBounds
public final boolean insideBounds(Coordinates[] bounds)
-
toString
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toStringSpaceDelimited
public final java.lang.String toStringSpaceDelimited()
-
equals
public final boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
isNaN
public final boolean isNaN()
-
min
public final Coordinates min(Coordinates c)
-
max
public final Coordinates max(Coordinates c)
-
cosAngle
public double cosAngle(Coordinates c)
-
min
public static final Coordinates min(Coordinates[] c)
-
max
public static final Coordinates max(Coordinates[] c)
-
createBarycenter
public static final Coordinates createBarycenter(Coordinates... coords)
-
getMirror
public static final Coordinates getMirror(Coordinates p, Coordinates c1, Coordinates c2, Coordinates c3)
Get the mirror image of p through the plane defined by c1, c2, c3- Parameters:
p
-c1
-c2
-c3
-- Returns:
-
getDihedral
public static final double getDihedral(Coordinates c1, Coordinates c2, Coordinates c3, Coordinates c4)
Calculates a signed torsion as an exterior spherical angle from a valid sequence of 4 points in space. Looking along the line from c2 to c3, the torsion angle is 0.0, if the projection of c2->c1 and c3->c4 point in the same direction. If the projection of vector c2-c1 is rotated in clockwise direction, the angle increases, i.e. has a positive value. http://en.wikipedia.org/wiki/Dihedral_angle- Parameters:
c1
-c2
-c3
-c4
-- Returns:
- torsion in the range: -pi <= torsion <= pi
-
compareTo
public int compareTo(Coordinates o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Coordinates>
-
random
public static final Coordinates random()
-
getRmsd
public static double getRmsd(Coordinates[] c1, Coordinates[] c2)
-
getRmsd
public static double getRmsd(Coordinates[] c1, Coordinates[] c2, int l)
-
-