astex
Class Point3d

java.lang.Object
  extended by astex.Point3d
Direct Known Subclasses:
Atom

public class Point3d
extends java.lang.Object

A class for manipulating 3d points and vectors.


Field Summary
 double x
          The object space coordinates of the this point.
 double y
          The object space coordinates of the this point.
 double z
          The object space coordinates of the this point.
 
Constructor Summary
Point3d()
          Default constructor.
Point3d(double xx)
          Construct a 3D point with equal x, y and z coordinates.
Point3d(double xx, double yy)
          Construct a 2D point with specified x and y coordinates.
Point3d(double xx, double yy, double zz)
          Constructor which allows the x, y, and z coordinates to be specified.
Point3d(Point3d p)
          Construct a 3D point from the coordinates of another Point3d.
 
Method Summary
 void add(Point3d p)
          Add the x, y and z coordinates from another Point3d to the coordinates of this point.
static double angle(Point3d a, Point3d b, Point3d c)
          Calculate the angle between the 3 points.
static double angleDegrees(Point3d a, Point3d b, Point3d c)
          Calcluate the angle in degrees.
 java.lang.Object clone()
          Clone method
static void cross(double[] a, double[] b, double[] c)
          Generate cross product for double[] vectors.
 Point3d cross(Point3d c)
          Return cross product with c.
static void cross(Point3d a, Point3d b, Point3d c)
          Set a to cross product of b and c.
static void crossNoNormalise(Point3d a, Point3d b, Point3d c)
          Set a to cross product of b and c.
 double distance(Point3d p)
          Return the distance to the specified point.
static double distance(Point3d a, Point3d b)
          Static distance method.
 double distanceSq(Point3d p)
          Return the square of the distance to the specified point.
static double distanceSq(Point3d a, Point3d b)
          Static distance squared method.
 void divide(double s)
          Scale a vector by the amount specified for each coordinate.
 double dot(Point3d p)
          Return the dot product of this vector with another one.
 boolean equal(Point3d b)
          Are this point identically equal to the specified point.
 double get(int i)
          Set the specified component.
 double getX()
          Return the x coordinate.
 double getY()
          Return the y coordinate.
 double getZ()
          Return the z coordinate.
 void initialise()
          Initialise a point.
 boolean isNullVector()
          Are all the components of this vector 0.
 double length()
          Return the length of the vector.
static double length(double[] a)
          Return length of double[] vector.
 void max(Point3d p)
          Find the vector maximum of the x, y and z coordinates of this point and another Point3d.
static Point3d mid(Point3d pmin, Point3d pmax)
          Construct a point with the x, y and z coordinates equal to the midpoint of two other Point3ds.
static void mid(Point3d pmid, Point3d pmin, Point3d pmax)
          Construct a point with the x, y and z coordinates equal to the midpoint of two other Point3ds.
 void min(Point3d p)
          Find the vector minimum of the x, y and z coordinates of this point and another Point3d.
 void negate()
          Negate the x, y and z coordinates of this point.
 void normalise()
          Make the position vector of this point have unit length.
static Point3d normalToLine(double xb, double yb)
           
static Point3d normalToLine(double xa, double ya, double xb, double yb, double len)
          Generate a line perpendicular to the line described by the set of points xa,ya xb,yb.
static Point3d normalToLine(Point3d p)
          Construct a unit vector that is perpendicular to the vector.
static void normalToLine(Point3d p, Point3d n)
          Construct a unit vector that is perpendicular to the vector.
static double planeEquation(Point3d point, Point3d origin, Point3d normal)
          Evaluate the plane equation for the specified vectors.
static void print(java.lang.String s, double[] x)
           
 void scale(double len)
          Scale the point by the specified amount.
 void set(double xx)
          Set the x, y and z coordinates to the same value.
 void set(double xx, double yy, double zz)
          Set the x, y and z coordinates of this Point3d.
 void set(int i, double v)
          Set the specified component.
 void set(Point3d p)
          Set the x, y and z coordinates to the values from another Point3d.
 void setX(double xx)
          Set the x coordinate.
 void setY(double yy)
          Set the y coordinate.
 void setZ(double zz)
          Set the x coordinate.
 void subtract(Point3d p)
          Subtract the x, y and z coordinates from another Point3d from the coordinates of this point.
static double torsion(double p1x, double p1y, double p1z, double p2x, double p2y, double p2z, double p3x, double p3y, double p3z, double p4x, double p4y, double p4z)
           
static double torsion(Point3d p1, Point3d p2, Point3d p3, Point3d p4)
          Calculate the torsion angle between the 4 points.
static double torsionDegrees(double p1x, double p1y, double p1z, double p2x, double p2y, double p2z, double p3x, double p3y, double p3z, double p4x, double p4y, double p4z)
           
static double torsionDegrees(Point3d p1, Point3d p2, Point3d p3, Point3d p4)
          Calculate torsion in degrees.
 java.lang.String toString()
          Return a string representation of this point.
 void transform(Matrix m)
          Transform this atom to screen coordinates.
 Point3d transformByMatrix(Matrix m)
          Transform the point by the passed matrix.
 void translate(double xtrans, double ytrans)
          translates x and y coordinates the specified amounts
 void translate(double xtrans, double ytrans, double ztrans)
          translates x, y and z coordinates the specified amounts
static Point3d unitVector(double xa, double ya, double xb, double yb)
          Return a point that is a unit vector from the first to the second.
static Point3d unitVector(Point3d p1, Point3d p2)
          Return another point, which is at the mid point of two points.
static void unitVector(Point3d up12, Point3d p1, Point3d p2)
          Set first point to be unitVector from p1 to p2.
static Point3d vector(Point3d p1, Point3d p2)
          Generate a vector from the first point to the second.
static void vector(Point3d p12, Point3d p1, Point3d p2)
          Make vector from p1 to p2 in p12.
 void zero()
          Set the x, y and z coordinates to 0.0 Transformed and screen space coordinates are not affected.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x
The object space coordinates of the this point.


y

public double y
The object space coordinates of the this point.


z

public double z
The object space coordinates of the this point.

Constructor Detail

Point3d

public Point3d()
Default constructor. The x, y and z coordinates are set to 0.0


Point3d

public Point3d(double xx,
               double yy,
               double zz)
Constructor which allows the x, y, and z coordinates to be specified.


Point3d

public Point3d(double xx,
               double yy)
Construct a 2D point with specified x and y coordinates. The z coordinates is set to 0.0


Point3d

public Point3d(double xx)
Construct a 3D point with equal x, y and z coordinates. This is useful for initialising 3D bounding boxes and such like.


Point3d

public Point3d(Point3d p)
Construct a 3D point from the coordinates of another Point3d.

Method Detail

initialise

public void initialise()
Initialise a point.


clone

public java.lang.Object clone()
Clone method

Overrides:
clone in class java.lang.Object

set

public void set(double xx,
                double yy,
                double zz)
Set the x, y and z coordinates of this Point3d. Transformed and screen coordinates are not affected.


set

public void set(double xx)
Set the x, y and z coordinates to the same value. Transformed and screen coordinates are note affected.


set

public void set(Point3d p)
Set the x, y and z coordinates to the values from another Point3d.


get

public double get(int i)
Set the specified component.


set

public void set(int i,
                double v)
Set the specified component.


zero

public void zero()
Set the x, y and z coordinates to 0.0 Transformed and screen space coordinates are not affected.


getX

public double getX()
Return the x coordinate.


getY

public double getY()
Return the y coordinate.


getZ

public double getZ()
Return the z coordinate.


setX

public void setX(double xx)
Set the x coordinate.


setY

public void setY(double yy)
Set the y coordinate.


setZ

public void setZ(double zz)
Set the x coordinate.


add

public void add(Point3d p)
Add the x, y and z coordinates from another Point3d to the coordinates of this point.


subtract

public void subtract(Point3d p)
Subtract the x, y and z coordinates from another Point3d from the coordinates of this point.


translate

public void translate(double xtrans,
                      double ytrans)
translates x and y coordinates the specified amounts


translate

public void translate(double xtrans,
                      double ytrans,
                      double ztrans)
translates x, y and z coordinates the specified amounts


negate

public void negate()
Negate the x, y and z coordinates of this point.


min

public void min(Point3d p)
Find the vector minimum of the x, y and z coordinates of this point and another Point3d. This x coordinates is set to the minimum of our x coordinate and the x coordinate of the other Point3d. The same is applied to the y and z coordinates. This is useful for accumulating bounding box values.

See Also:
max(astex.Point3d)

max

public void max(Point3d p)
Find the vector maximum of the x, y and z coordinates of this point and another Point3d. This x coordinates is set to the maximum of our x coordinate and the x coordinate of the other Point3d. The same is applied to the y and z coordinates. This is useful for accumulating bounding box values.

See Also:
min(astex.Point3d)

mid

public static Point3d mid(Point3d pmin,
                          Point3d pmax)
Construct a point with the x, y and z coordinates equal to the midpoint of two other Point3ds.


mid

public static void mid(Point3d pmid,
                       Point3d pmin,
                       Point3d pmax)
Construct a point with the x, y and z coordinates equal to the midpoint of two other Point3ds.


normalise

public void normalise()
Make the position vector of this point have unit length. That is, divide x, y and z by Math.sqrt(x*x + y*y + z*z). If the divisor is zero no change is made.


dot

public double dot(Point3d p)
Return the dot product of this vector with another one.


length

public double length()
Return the length of the vector.


length

public static double length(double[] a)
Return length of double[] vector.


unitVector

public static Point3d unitVector(Point3d p1,
                                 Point3d p2)
Return another point, which is at the mid point of two points.


unitVector

public static void unitVector(Point3d up12,
                              Point3d p1,
                              Point3d p2)
Set first point to be unitVector from p1 to p2.


unitVector

public static Point3d unitVector(double xa,
                                 double ya,
                                 double xb,
                                 double yb)
Return a point that is a unit vector from the first to the second.


vector

public static Point3d vector(Point3d p1,
                             Point3d p2)
Generate a vector from the first point to the second. The vector does not have a length of 1.


vector

public static void vector(Point3d p12,
                          Point3d p1,
                          Point3d p2)
Make vector from p1 to p2 in p12.


normalToLine

public static Point3d normalToLine(Point3d p)
Construct a unit vector that is perpendicular to the vector. If p is the null vector then (1.,1.,.1) is returned.


normalToLine

public static void normalToLine(Point3d p,
                                Point3d n)
Construct a unit vector that is perpendicular to the vector.


normalToLine

public static Point3d normalToLine(double xa,
                                   double ya,
                                   double xb,
                                   double yb,
                                   double len)
Generate a line perpendicular to the line described by the set of points xa,ya xb,yb. The line is made to be of length len. The generated vector always points to the right as we look from above at the direction from a to b.


normalToLine

public static Point3d normalToLine(double xb,
                                   double yb)

planeEquation

public static double planeEquation(Point3d point,
                                   Point3d origin,
                                   Point3d normal)
Evaluate the plane equation for the specified vectors. The result is the distance above the plane defined by origin and normal. If normal is not a unit vector then the signed value simply indicates if the point is above or below the plane.


cross

public Point3d cross(Point3d c)
Return cross product with c.


cross

public static void cross(Point3d a,
                         Point3d b,
                         Point3d c)
Set a to cross product of b and c.


crossNoNormalise

public static void crossNoNormalise(Point3d a,
                                    Point3d b,
                                    Point3d c)
Set a to cross product of b and c.


cross

public static void cross(double[] a,
                         double[] b,
                         double[] c)
Generate cross product for double[] vectors.


equal

public boolean equal(Point3d b)
Are this point identically equal to the specified point.


scale

public void scale(double len)
Scale the point by the specified amount.


distance

public double distance(Point3d p)
Return the distance to the specified point.


distanceSq

public double distanceSq(Point3d p)
Return the square of the distance to the specified point.


divide

public void divide(double s)
Scale a vector by the amount specified for each coordinate.


isNullVector

public boolean isNullVector()
Are all the components of this vector 0.


transformByMatrix

public Point3d transformByMatrix(Matrix m)
Transform the point by the passed matrix.


distance

public static double distance(Point3d a,
                              Point3d b)
Static distance method.


distanceSq

public static double distanceSq(Point3d a,
                                Point3d b)
Static distance squared method.


angle

public static double angle(Point3d a,
                           Point3d b,
                           Point3d c)
Calculate the angle between the 3 points.


angleDegrees

public static double angleDegrees(Point3d a,
                                  Point3d b,
                                  Point3d c)
Calcluate the angle in degrees.


torsion

public static double torsion(double p1x,
                             double p1y,
                             double p1z,
                             double p2x,
                             double p2y,
                             double p2z,
                             double p3x,
                             double p3y,
                             double p3z,
                             double p4x,
                             double p4y,
                             double p4z)

torsionDegrees

public static double torsionDegrees(double p1x,
                                    double p1y,
                                    double p1z,
                                    double p2x,
                                    double p2y,
                                    double p2z,
                                    double p3x,
                                    double p3y,
                                    double p3z,
                                    double p4x,
                                    double p4y,
                                    double p4z)

torsion

public static double torsion(Point3d p1,
                             Point3d p2,
                             Point3d p3,
                             Point3d p4)
Calculate the torsion angle between the 4 points.


torsionDegrees

public static double torsionDegrees(Point3d p1,
                                    Point3d p2,
                                    Point3d p3,
                                    Point3d p4)
Calculate torsion in degrees.


transform

public void transform(Matrix m)
Transform this atom to screen coordinates.


print

public static void print(java.lang.String s,
                         double[] x)

toString

public java.lang.String toString()
Return a string representation of this point.

Overrides:
toString in class java.lang.Object