ProGAL.geom3d
Class Line

java.lang.Object
  extended by ProGAL.geom3d.Line

public class Line
extends java.lang.Object

A line represented by a point and a direction. Several methods work with a parameter that can be used to specify a point on the line. For instance

 Line3d l = new Line3d( new Point3d(0,0,0), new Vector3d(2,0,0) );
 System.out.println( l.getPoint( 0.0 ) );
 System.out.println( l.getPoint( 1.0 ) );
 
will print the points (0,0,0) and (2,0,0). Similarly, the lines
 l.orthogonalProjection(new Point3d(1,1,0));
 l.orthogonalProjectionParameter(new Point3d(1,1,0));
 
will return the point (1,0,0) and the parameter 0.5 respectively.


Constructor Summary
Line(LineSegment s)
          Constructs a line through the segment s.
Line(Point p1, Point p2)
          Constructs a line through the two specified points.
Line(Point p, Vector d)
          Constructs a line through p with direction d.
Line(Vector d)
          Constructs a line through origo with direction d.
 
Method Summary
 Vector getDir()
          Returns the direction vector defining this line.
 double getDistance(Point q)
          Gets the orthogonal distance to a point.
 double getDistanceSquared(Point q)
          Gets the squared orthogonal distance to a point.
 Point getIntersection(Line l)
          Gets the intersection-point of this line with l.
 double getMaxDistance(PointList points)
          Gets the largest distance from the points to the line.
 double getMaxDistanceSquared(PointList points)
          Gets the largest squared distance from the points to the line.
 Point getP()
          Returns the point defining this line.
 Point getPoint(double t)
          Gets the point on the line defined by the specified parameter.
 double getSquaredDistance(Line l)
          Gets the minimum squared distance to another line.
 double optimalRotation(Point[] moving, Point[] target)
          Return the optimal right-hand rotation around the line that brings the m-points as close to the f-points as possible.
 Point orthogonalProjection(Point q)
          Returns the othogonal projection of the point q onto this line.
 LineSegment orthogonalProjection(PointList points)
          Returns the smallest segment that contains all orthogonol projections of a point set onto this line.
 double orthogonalProjectionParameter(Point q)
          Returns the line-parameter of the othogonal projection of the point q onto this line.
 double[] orthogonalProjectionParameters(PointList points)
          Returns the line-parameters of the end-points of the smallest segment that contains all orthogonol projections of a point set onto this line.
 Point rotate(Point p, double angle)
          Return a rotation of p around this line.
 Point rotateIn(Point point, double angle)
          Rotate point around this line, store the result in point and return the results.
 void toScene(J3DScene scene, double rad, java.awt.Color clr)
           
 java.lang.String toString()
          Returns a string-representation of this line.
 java.lang.String toString(int dec)
          Returns a string-representation of this line with dec decimals precision.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Line

public Line(Vector d)
Constructs a line through origo with direction d.


Line

public Line(Point p,
            Vector d)
Constructs a line through p with direction d.


Line

public Line(LineSegment s)
Constructs a line through the segment s. The point will be s.getA() and the direction will be s.getAToB(). Subsequent changes to the line segment should not change this line.


Line

public Line(Point p1,
            Point p2)
Constructs a line through the two specified points.

Method Detail

getP

public Point getP()
Returns the point defining this line.


getDir

public Vector getDir()
Returns the direction vector defining this line.


getPoint

public Point getPoint(double t)
Gets the point on the line defined by the specified parameter. If the parameter is zero this method will not return a reference to the defining point (but the returned point will equal it).


orthogonalProjection

public Point orthogonalProjection(Point q)
Returns the othogonal projection of the point q onto this line.


orthogonalProjectionParameter

public double orthogonalProjectionParameter(Point q)
Returns the line-parameter of the othogonal projection of the point q onto this line.


orthogonalProjection

public LineSegment orthogonalProjection(PointList points)
Returns the smallest segment that contains all orthogonol projections of a point set onto this line.


orthogonalProjectionParameters

public double[] orthogonalProjectionParameters(PointList points)
Returns the line-parameters of the end-points of the smallest segment that contains all orthogonol projections of a point set onto this line.

Returns:
a double-array with two entries containing the smallest and largest orthogonal projection line-parameter of the point-set.

getDistanceSquared

public double getDistanceSquared(Point q)
Gets the squared orthogonal distance to a point.


getDistance

public double getDistance(Point q)
Gets the orthogonal distance to a point.


getSquaredDistance

public double getSquaredDistance(Line l)
Gets the minimum squared distance to another line.

See Also:
05, p. 147]

getIntersection

public Point getIntersection(Line l)
Gets the intersection-point of this line with l. If the lines do not intersect then null is returned.


getMaxDistanceSquared

public double getMaxDistanceSquared(PointList points)
Gets the largest squared distance from the points to the line.


getMaxDistance

public double getMaxDistance(PointList points)
Gets the largest distance from the points to the line.


rotate

public Point rotate(Point p,
                    double angle)
Return a rotation of p around this line. The rotation is a right-handed one (thumb in the direction of dir)


rotateIn

public Point rotateIn(Point point,
                      double angle)
Rotate point around this line, store the result in point and return the results. The rotation is a right-handed one (thumb in the direction of dir)


optimalRotation

public double optimalRotation(Point[] moving,
                              Point[] target)
Return the optimal right-hand rotation around the line that brings the m-points as close to the f-points as possible. Formally the rotation angle that minimizes double S = m[0].distanceSquared(f[0]) + ... + m[m.length-1].distanceSquared(f[m.length-1]); This method follows the description by Canutescu and Dunbrack 2003.

Parameters:
moving - Array of effector points
target - Array of target points
Returns:
an angle which the effector points should be rotated so they come close to the target points.

toString

public java.lang.String toString()
Returns a string-representation of this line.

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(int dec)
Returns a string-representation of this line with dec decimals precision.


toScene

public void toScene(J3DScene scene,
                    double rad,
                    java.awt.Color clr)