gishur.x2.core
Class XParametricCurve

java.lang.Object
  |
  +--gishur.x2.core.XObject
        |
        +--gishur.x2.core.XIntersectableObject
              |
              +--gishur.x2.core.XParametricCurve
All Implemented Interfaces:
java.lang.Cloneable, Cloneable, Intersectable, Intersectable, java.io.Serializable
Direct Known Subclasses:
XQuadCurve, XSegment

public abstract class XParametricCurve
extends XIntersectableObject

An abstract class for parametric curves.

Version:
1.0
Author:
Thomas Wolf
See Also:
Serialized Form

Field Summary
static int DIRECTION_DOWN
          Direction constant "downwards".
static int DIRECTION_LEFT
          Direction constant "to the left".
static int DIRECTION_RIGHT
          Direction constant "to the right".
static int DIRECTION_UP
          Direction constant "upwards".
static short STATE_BOTH_END
          Curve ends at source and target points (parameters must lie between 0 and 1).
static short STATE_SOURCE_END
          Curve ends at the source point (parameters <0 are prohibited).
static short STATE_TARGET_END
          Curve ends at the target point (parameters >1 are prohibited).
 
Fields inherited from class gishur.x2.core.XObject
RESERVED_STATE_MAX_MASK, STATE_DIRTY, STATE_LOCKED, STATE_MUTABLE
 
Fields inherited from interface gishur.x2.core.Intersectable
FACES, POINT_INSIDE, POINT_ON_BORDER, POINT_OUTSIDE, POINTS, POINTS_CURVES
 
Fields inherited from interface gishur.core.geom.Intersectable
DEFAULT
 
Constructor Summary
XParametricCurve()
           
 
Method Summary
 boolean checkParam(double t)
          Checks the parameter for this curve.
 boolean finite()
          Returns true, if the curve fits in a finite rectangle.
 boolean hasNoEnd()
          Returns true, if the curve that neither end at the source nor at the target point.
static int inverseDirection(int direction)
          Returns the inverse direction to direction.
 boolean liesInterior(XPoint p)
          Returns true, if p lies in the interior of the curve.
 XPoint majorEndPoint()
          Returns the lexicographical bigger end point of the curve, e.g. that point of {source,target} with higher x-coordinate or - in the case of equality - with higher y-coordinate.
 XPoint minorEndPoint()
          Returns the lexicographical smaller end point of the curve, e.g. that point of {source,target} with lower x-coordinate or - in the case of equality - with lower y-coordinate.
 XSegment normal(double t)
          Returns the normal line to the curve at the point with parameter t.
 XSegment normal(XPoint p)
          Returns the normal line to the curve at the point p.
abstract  double param(XPoint p)
          Calculates the parameter for the curve of a given point.
abstract  XPoint point(double t)
          Calculates a point on the curve with parameter t.
abstract  void setSource(XPoint source)
          Sets the source point to source (if not null).
 void setSourceEnd(boolean sc)
          Determines if the curve ends at the source point.
abstract  void setTarget(XPoint target)
          Sets the target point to target (if not null).
 void setTargetEnd(boolean tc)
          Determines if the curve ends at the target point.
abstract  XPoint source()
          Return the source point of the curve.
 boolean sourceEnd()
          Returns true, if the curve ends at the source point.
 XSegment tangent(double t)
          Returns the tangent line to the curve at the point with parameter t.
 XSegment tangent(XPoint p)
          Returns the tangent line to the curve at the point p.
abstract  XPoint target()
          Return the target point of the curve.
 boolean targetEnd()
          Returns true, if the curve ends at the target point.
abstract  XPoint vector(double t, int dir, boolean normalize)
          Returns a (normalized) vector in the specified direction relative to this curve at a point on the curve with parameter t.
 
Methods inherited from class gishur.x2.core.XIntersectableObject
contains, contains, liesOn
 
Methods inherited from class gishur.x2.core.XObject
checkState, checkStateCleared, clearDirty, clearState, clone, copy, dirty, getMutable, getOldXObject, getXObjectMembers, inverseTransform, lock, locked, makeImmutable, makeMutable, modify, mutable, restoreMutability, rotate, scale, setState, state, state, toString_complete, toString_state, toString, transform, transform, translate, translate, unlock
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gishur.x2.core.Intersectable
locate
 
Methods inherited from interface gishur.core.geom.Intersectable
intersection, supportIntersection
 

Field Detail

DIRECTION_RIGHT

public static final int DIRECTION_RIGHT
Direction constant "to the right".

DIRECTION_LEFT

public static final int DIRECTION_LEFT
Direction constant "to the left".

DIRECTION_UP

public static final int DIRECTION_UP
Direction constant "upwards".

DIRECTION_DOWN

public static final int DIRECTION_DOWN
Direction constant "downwards".

STATE_SOURCE_END

public static final short STATE_SOURCE_END
Curve ends at the source point (parameters <0 are prohibited).

STATE_TARGET_END

public static final short STATE_TARGET_END
Curve ends at the target point (parameters >1 are prohibited).

STATE_BOTH_END

public static final short STATE_BOTH_END
Curve ends at source and target points (parameters must lie between 0 and 1).
Constructor Detail

XParametricCurve

public XParametricCurve()
Method Detail

source

public abstract XPoint source()
Return the source point of the curve.
Returns:
Source point.

target

public abstract XPoint target()
Return the target point of the curve.
Returns:
Target point.

setSource

public abstract void setSource(XPoint source)
Sets the source point to source (if not null). The object must be mutable.
Parameters:
source - source point
Throws:
GeomException - if object is immutable

setTarget

public abstract void setTarget(XPoint target)
Sets the target point to target (if not null). The object must be mutable.
Parameters:
target - target point
Throws:
GeomException - if object is immutable

point

public abstract XPoint point(double t)
Calculates a point on the curve with parameter t. If the curve is finite(), then holds 0≤t≤1.
Parameters:
t - parameter
Point - on the curve with parameter t or null if the parameter is not valid.

param

public abstract double param(XPoint p)
Calculates the parameter for the curve of a given point. The point must lie on the curve or an GeomException will be thrown.
Parameters:
p - point
Returns:
Parameter of p.
Throws:
GeomException - if p does not lie on the curve

vector

public abstract XPoint vector(double t,
                              int dir,
                              boolean normalize)
Returns a (normalized) vector in the specified direction relative to this curve at a point on the curve with parameter t. The value of dir specifies if the vector should point tangential along the curve (DIRECTION_UP), point tangential in the opposite direction (DIRECTION_DOWN), point normal to the curve to the right (DIRECTION_RIGHT) or point normal to the curve to the left (DIRECTION_LEFT).
Parameters:
t - parameter of the curve point where to calculate the vector
dir - direction constant
normalize - true, if result vector should be normalized
Returns:
Vector tangential or normal to the curve at the specified point.
Throws:
GeomException - if dir has an illegal value.

minorEndPoint

public XPoint minorEndPoint()
Returns the lexicographical smaller end point of the curve, e.g. that point of {source,target} with lower x-coordinate or - in the case of equality - with lower y-coordinate.
Returns:
Lexicographical smaller end point.

majorEndPoint

public XPoint majorEndPoint()
Returns the lexicographical bigger end point of the curve, e.g. that point of {source,target} with higher x-coordinate or - in the case of equality - with higher y-coordinate.
Returns:
Lexicographical bigger end point.

tangent

public XSegment tangent(double t)
Returns the tangent line to the curve at the point with parameter t. The resulting tangent points along the curve.
Parameters:
t - parameter for curve point
Returns:
Tangent line in point(t).

tangent

public XSegment tangent(XPoint p)
Returns the tangent line to the curve at the point p. The resulting tangent points along the curve. The given point must lie on the curve or the result will be useless.
Parameters:
p - curve point
Returns:
Tangent line in p.

normal

public XSegment normal(double t)
Returns the normal line to the curve at the point with parameter t. The resulting normal points to the left of the line.
Parameters:
t - parameter for curve point
Returns:
Normal line in point(t).

normal

public XSegment normal(XPoint p)
Returns the normal line to the curve at the point p. The resulting normal points to the left of the line. The given point must lie on the curve or the result will be useless.
Parameters:
p - curve point
Returns:
Normal line in p.

sourceEnd

public boolean sourceEnd()
Returns true, if the curve ends at the source point.
Returns:
True, if the curve ends at the source point.

targetEnd

public boolean targetEnd()
Returns true, if the curve ends at the target point.
Returns:
True, if the curve ends at the target point.

hasNoEnd

public boolean hasNoEnd()
Returns true, if the curve that neither end at the source nor at the target point.
Returns:
True, if curve has no end points.

finite

public boolean finite()
Returns true, if the curve fits in a finite rectangle.
Returns:
True, if finite curve.

liesInterior

public boolean liesInterior(XPoint p)
Returns true, if p lies in the interior of the curve.
Parameters:
p - test point
Returns:
True, if it lies in the interior of the segment.

setSourceEnd

public void setSourceEnd(boolean sc)
Determines if the curve ends at the source point. The object must be mutable.
Parameters:
sc - if true, curve will end at source
Throws:
GeomException - if object is immutable

setTargetEnd

public void setTargetEnd(boolean tc)
Determines if the curve ends at the target point. The object must be mutable.
Parameters:
tc - if true, curve will end at target
Throws:
GeomException - if object is immutable

checkParam

public boolean checkParam(double t)
Checks the parameter for this curve. If true is returned, the parameter is valid.
Parameters:
t - parameter to check
Returns:
True, if t is valid.

inverseDirection

public static final int inverseDirection(int direction)
Returns the inverse direction to direction.
Parameters:
direction -  
Returns:
inverse direction