|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gishur.x2.core.XObject | +--gishur.x2.core.XIntersectableObject | +--gishur.x2.core.XParametricCurve | +--gishur.x2.core.XSegment
Fields inherited from class gishur.x2.core.XParametricCurve |
DIRECTION_DOWN, DIRECTION_LEFT, DIRECTION_RIGHT, DIRECTION_UP, STATE_BOTH_END, STATE_SOURCE_END, STATE_TARGET_END |
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 | |
XSegment(double x,
double y,
boolean src,
double slope,
int dir,
boolean sc,
boolean tc)
Creates a segment with endpoints to (x,y) and an unknown
point in direction dir using slope slope .
|
|
XSegment(double x1,
double y1,
double x2,
double y2)
Creates a segment with source point (x1,y1) and target point
(x2,y2) . |
|
XSegment(double x1,
double y1,
double x2,
double y2,
boolean sc,
boolean tc)
Creates a segment with source point (x1,y1) and target point
(x2,y2) . |
|
XSegment(XPoint source,
XPoint target)
Creates a segment with source point source and target point
target . |
|
XSegment(XPoint source,
XPoint target,
boolean sc,
boolean tc)
Creates a segment with source point source and target point
target . |
Method Summary | |
XPoint |
calculatePoint(double x)
Returns a point on the segment with x-coordinate x or
null if no such point exists. |
XPoint |
calculatePointOnBorder(double x,
boolean src)
Calculates a point on the segment that has signed distance x
from the source point (src==true ) resp. from the target point
(src==false ). |
java.lang.Object |
clone()
Creates a new object of the same class as this object. |
XPoint |
closestPoint(XPoint p)
Returns a point on the segment that is closest to p .
|
static XSegment |
createDualLine(XPoint p)
Returns the dual point to this line. |
static XSegment |
createLine(double x1,
double y1,
double x2,
double y2)
Creates a line going through (x1,y1) and (x2,y2) . |
static XSegment |
createLine(XPoint source,
XPoint target)
Creates a line going through source and target . |
static XSegment |
createRay(double x1,
double y1,
double x2,
double y2)
Creates a ray from (x1,y1) through (x2,y2) . |
static XSegment |
createRay(int dir,
double slope,
XPoint target)
Creates a ray ending at target that points in direction
dir (from target) and has slope slope . |
static XSegment |
createRay(XPoint source,
double slope,
int dir)
Creates a ray from source that points in direction
dir and has slope slope . |
static XSegment |
createRay(XPoint source,
XPoint target)
Creates a ray from source through target . |
static XSegment |
createSegment(double x1,
double y1,
double x2,
double y2)
Creates a segment with source point (x1,y1) and target point
(x2,y2) . |
static XSegment |
createSegment(XPoint source,
XPoint target)
Creates a segment with source point source and target point
target . |
int |
direction()
Returns the direction this directed segment points to. |
XPoint |
dualPoint()
Returns the dual point to this line. |
boolean |
equals(java.lang.Object o)
Determines whether two objects ( this and o )
are equal. |
boolean |
equals(XSegment s)
Determines whether two segments are equal. |
XSegment |
flip()
Flips source and target points. |
java.lang.Object |
getOldXObject()
Returns corresponding old gishur.x-object. |
protected XObject[] |
getXObjectMembers()
This method should return all XObject members that contain geometric information. |
boolean |
horizontal()
Returns true if the segment is horizontal. |
java.lang.Object |
intersection(int mode,
java.lang.Object o)
Calculates the intersection between this object and the given object o. |
boolean |
isLine()
Returns true , if this XSegment is a straight line. |
boolean |
isRay()
Returns true , if this XSegment is a ray. |
boolean |
isSegment()
Returns true , if this XSegment is a (real) segment. |
double |
length()
Returns the length of this segment, e.g. the distance between
source and target (no matter if source or target are open). |
int |
locate(XPoint p)
Locates the specified point. |
void |
makeImmutable()
Makes this object immutable. |
void |
makeMutable()
Makes this object mutable. |
int |
orientation(XPoint p)
Return an indicator of where the point p lies with
respect to the directed line this . |
boolean |
parallel(XSegment s)
Returns true, if the given Segment is parallel to this segment. |
double |
param(XPoint p)
Calculates the parameter for the curve of a given point. |
XPoint |
plumb(XPoint p)
Returns a point on this segment through a plumb by
p to the segment. |
XPoint |
plumbTo(XPoint p,
XSegment l)
Returns the intersection point by the orthogonal line to this
and throught p with the given segment l . |
XPoint |
point(double t)
Calculates a point on the curve with parameter t .
|
void |
set(double x1,
double y1,
double x2,
double y2)
Sets this segment to (x1,y1)-(x2,y2) .
|
void |
set(double x1,
double y1,
double x2,
double y2,
boolean sc,
boolean tc)
Sets this segment to (x1,y1)-(x2,y2) with source / target
closed according to sc / tc .
The object must be mutable. |
void |
set(XPoint source,
XPoint target)
Sets this segment to source-target .
If either (or both) point is null , the point won't be overwritten.
|
void |
set(XPoint source,
XPoint target,
boolean sc,
boolean tc)
Sets this segment to source-target with source / target
closed according to sc / tc .
If either (or both) point is null, the point won't be overwritten.
|
void |
setRay(double x,
double y,
double slope,
int dir)
Sets this segment endpoints to (x,y) and an unknown
point in direction dir using slope slope .
The object must be mutable. |
void |
setRay(XPoint source,
double slope,
int dir)
Sets this segment endpoints to source and an unknown
point in direction dir using slope slope .
If the point is null , the point won't be overwritten.
|
void |
setSource(XPoint source)
Sets the source point to source (if not null ).
|
void |
setTarget(XPoint target)
Sets the target point to target (if not null ).
|
double |
slope()
Returns the slope of this segment. |
XPoint |
source()
Return the source point of the segment. |
boolean |
supportIntersection(int mode,
java.lang.Object o)
Returns true, if this class (or object) provides intersection with the given object o. |
XSegment |
swapPoints()
Swaps source and target points and preserves the open sides, e.g. a ray points to the same direction after swapping points. |
XPoint |
target()
Return the target point of the segment. |
XSegment |
toLine()
Returns a line from this object. |
XSegment |
toRay()
Returns a ray from this object (which is at the target point open).
|
XSegment |
toSegment()
Returns a segment from this object. |
java.lang.String |
toString()
Returns a string representation of the segment. |
XObject |
transform(double m00,
double m01,
double m02,
double m10,
double m11,
double m12)
Transforms this XObject by the given affine
transformation matrix. |
XPoint |
vector(double t,
int dir,
boolean normalize)
Returns a (normalized) vector in the specified direction relative to this segment at a point on the segment with parameter
t . |
XPoint |
vector(int dir,
boolean normalize)
Returns a (normalized) vector in the specified direction relative to this segment. |
boolean |
vertical()
Returns true if the segment is vertical. |
double |
y_abs()
Returns the y-value of the intersection of the line through source and target with the y-axis. |
Methods inherited from class gishur.x2.core.XParametricCurve |
checkParam, finite, hasNoEnd, inverseDirection, liesInterior, majorEndPoint, minorEndPoint, normal, normal, setSourceEnd, setTargetEnd, sourceEnd, tangent, tangent, targetEnd |
Methods inherited from class gishur.x2.core.XIntersectableObject |
contains, contains, liesOn |
Methods inherited from class gishur.x2.core.XObject |
checkState, checkStateCleared, clearDirty, clearState, copy, dirty, getMutable, inverseTransform, lock, locked, modify, mutable, restoreMutability, rotate, scale, setState, state, state, toString_complete, toString_state, transform, translate, translate, unlock |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public XSegment(double x1, double y1, double x2, double y2, boolean sc, boolean tc)
(x1,y1)
and target point
(x2,y2)
. The boolean values sc
and tc
determine if the segment is open at the source/target point(s), e.g. if the
object is a real segment (both true), a ray (exactly one true) or a line (both
false).x1,y1
- source pointx2,y2
- target pointsc
- line ends at source pointtc
- line ends at target pointpublic XSegment(XPoint source, XPoint target, boolean sc, boolean tc)
source
and target point
target
. The boolean values sc
and tc
determine if the segment is open at the source/target point(s), e.g. if the
object is a real segment (both true), a ray (exactly one true) or a line (both
false).source
- source pointtarget
- target pointsc
- line ends at source pointtc
- line ends at target pointGeomException
- if source or target point is null
public XSegment(double x, double y, boolean src, double slope, int dir, boolean sc, boolean tc)
(x,y)
and an unknown
point in direction dir
using slope slope
.
The value of src
specifies if (x,y)
will
be source (true) or target (false).
The values of sc
and tc
determine this object
to be a segment, line or ray. Is sc
false then the segment
will be elongated beyond the source point otherwise it will be an
endpoint - same applies to tc
and the target point.x,y
- source/target pointsrc
- if true then (x,y)
is source, else it is targetslope
- slope of segmentdir
- the direction used (any constant of {XParametricCurve.DIRECTION_UP
,
XParametricCurve.DIRECTION_DOWN
,XParametricCurve.DIRECTION_LEFT
,XParametricCurve.DIRECTION_RIGHT
})sc
- if true, segment will be closed at the source point (ray or segment)tc
- if true, segment will be closed at the target point (ray or segment)GeomException
- if invalid direction constantpublic XSegment(double x1, double y1, double x2, double y2)
(x1,y1)
and target point
(x2,y2)
.x1,y1
- source pointx2,y2
- target pointpublic XSegment(XPoint source, XPoint target)
source
and target point
target
.source
- source pointtarget
- target pointGeomException
- if source or target point is null
Method Detail |
public static XSegment createSegment(double x1, double y1, double x2, double y2)
(x1,y1)
and target point
(x2,y2)
.x1,y1
- source pointx2,y2
- target point(x1,y1)-(x2,y2)
.public static XSegment createSegment(XPoint source, XPoint target)
source
and target point
target
.source
- source pointtarget
- target pointsource-target
.GeomException
- if source or target point is null
public static XSegment createRay(double x1, double y1, double x2, double y2)
(x1,y1)
through (x2,y2)
.x1,y1
- source pointx2,y2
- target point(x1,y1)->(x2,y2)
.public static XSegment createRay(XPoint source, XPoint target)
source
through target
.source
- source pointtarget
- target pointsource->target
.GeomException
- if source or target point is null
public static XSegment createRay(XPoint source, double slope, int dir)
source
that points in direction
dir
and has slope slope
.source
- source pointslope
- the rays slopedir
- direction (a constant of {XParametricCurve.DIRECTION_RIGHT
,
XParametricCurve.DIRECTION_LEFT
,XParametricCurve.DIRECTION_UP
,XParametricCurve.DIRECTION_DOWN
})source
in direction
dir
with slope slope
.GeomException
- if source point is null
public static XSegment createRay(int dir, double slope, XPoint target)
target
that points in direction
dir
(from target) and has slope slope
.dir
- direction (a constant of {XParametricCurve.DIRECTION_RIGHT
,
XParametricCurve.DIRECTION_LEFT
,XParametricCurve.DIRECTION_UP
,XParametricCurve.DIRECTION_DOWN
})slope
- the rays slopetarget
- target pointtarget
in direction
dir
with slope slope
.GeomException
- if target point is null
public static XSegment createLine(double x1, double y1, double x2, double y2)
(x1,y1)
and (x2,y2)
.x1,y1
- source pointx2,y2
- target point(x1,y1)
and (x2,y2)
.public static XSegment createLine(XPoint source, XPoint target)
source
and target
.source
- source pointtarget
- target pointsource
and target
.GeomException
- if source or target point is null
public static XSegment createDualLine(XPoint p)
p=(a,b) -> p*={Y=aX+b} g*(-a,b) <- g={Y=aX+b}
public java.lang.String toString()
toString
in class XObject
public java.lang.Object clone()
clone
in class XObject
OutOfMemoryError
- if there is not enough memory.Cloneable
public boolean equals(XSegment s)
s
- segment to compare with this
.public boolean equals(java.lang.Object o)
this
and o
)
are equal.equals
in class java.lang.Object
o
- Object to compare with.public void makeMutable()
this
Object
can modify its coordinates (and some other geometric
information). This must be assured by every subclass of XObject
itself - but propagation to all XObject members contained by
this class (returned by getXObjectMembers()
) is assured
by this method.makeMutable
in class XObject
public void makeImmutable()
this
Object
cannot modify its coordinates (and some other geometric
information). This must be assured by every subclass of XObject
itself - but propagation to all XObject members contained by
this class (returned by getXObjectMembers()
) is assured
by this method.makeImmutable
in class XObject
protected XObject[] getXObjectMembers()
makeMutable()
, makeImmutable()
,
XObject.clearDirty()
, XObject.lock()
and XObject.unlock()
. To make this
work there must not occur circular dependencies.getXObjectMembers
in class XObject
null
if none).public XPoint source()
source
in class XParametricCurve
public XPoint target()
target
in class XParametricCurve
public boolean isLine()
true
, if this XSegment is a straight line.public boolean isSegment()
true
, if this XSegment is a (real) segment.public boolean isRay()
true
, if this XSegment is a ray.public boolean vertical()
public boolean horizontal()
public boolean parallel(XSegment s)
this
segment.s
- the other segments
and this
are parallel.public int orientation(XPoint p)
p
lies with
respect to the directed line this
. The value will
be XPoint.ORIENTATION_LEFT
if p
lies left of
this
, XPoint.ORIENTATION_RIGHT
if it lies to the
right or XPoint.ORIENTATION_COLLINEAR
if p
is collinear
with this
segment.p
- the pointp
with respect to this
(one constant of {ORIENTATION_LEFT
,ORIENTATION_RIGHT
,
ORIENTATION_COLLINEAR
})GeomException
- p
is null
public double y_abs()
public double slope()
public double length()
this
segment, e.g. the distance between
source and target (no matter if source or target are open).public int direction()
XParametricCurve.DIRECTION_RIGHT
,
XParametricCurve.DIRECTION_LEFT
,XParametricCurve.DIRECTION_UP
,XParametricCurve.DIRECTION_DOWN
}).public XPoint vector(int dir, boolean normalize)
this
segment. The value of dir
specifies if
the vector should point along the segment (XParametricCurve.DIRECTION_UP
), point
in the opposite direction (XParametricCurve.DIRECTION_DOWN
), points orthogonal to
the right (XParametricCurve.DIRECTION_RIGHT
) or points orthogonal to the left
(XParametricCurve.DIRECTION_LEFT
).dir
- direction constantnormalize
- true, if result vector should be normalizedGeomException
- if dir has an illegal value.public XPoint vector(double t, int dir, boolean normalize)
this
segment at a point on the segment with parameter
t
. The value of dir
specifies if
the vector should point tangential along the segment (XParametricCurve.DIRECTION_UP
),
point tangential in the opposite direction (XParametricCurve.DIRECTION_DOWN
),
point normal to the segment to the right (XParametricCurve.DIRECTION_RIGHT
) or
point normal to the segment to the left (XParametricCurve.DIRECTION_LEFT
).vector
in class XParametricCurve
t
- parameter of the segment point where to calculate the vectordir
- direction constantnormalize
- true, if result vector should be normalizedGeomException
- if dir has an illegal value.vector(int,boolean)
public XPoint point(double t)
t
.
If the curve is XParametricCurve.finite()
, then holds 0≤t≤1
.point
in class XParametricCurve
t
- parameterPoint
- on the curve with parameter t
or
null
if the parameter is not valid.public double param(XPoint p)
GeomException
will be
thrown.param
in class XParametricCurve
p
- pointp
.GeomException
- if p
does not lie on the curvepublic XPoint calculatePoint(double x)
x
or
null
if no such point exists.x
- x-coordinatepublic XPoint calculatePointOnBorder(double x, boolean src)
x
from the source point (src==true
) resp. from the target point
(src==false
).x
- signed length parameterif
- true, measured from source, else measured from targetx
or
null
if no such point.public XPoint plumb(XPoint p)
this
segment through a plumb by
p
to the segment. null
will be returned, if
the orthogonal line along the plumb does not hit the segment.p
- point to plumb fromGeomException
- if p
is null
public XPoint plumbTo(XPoint p, XSegment l)
this
and throught p
with the given segment l
.p
- pointl
- segmentl
.GeomException
- if any argument is null
public XPoint closestPoint(XPoint p)
p
.
The result can be p
if p
lies on the
segment.p
- point to search fromp
on the segment.public XPoint dualPoint()
p=(a,b) -> p*={Y=aX+b} g*(-a,b) <- g={Y=aX+b}
public XSegment flip()
swapPoints()
public XSegment swapPoints()
flip()
public void set(double x1, double y1, double x2, double y2, boolean sc, boolean tc)
(x1,y1)-(x2,y2)
with source / target
closed according to sc
/ tc
.The object must be mutable.
x1,y1
- source pointx2,y2
- target pointsc
- segment is closed (true) or open (false) on source pointtc
- segment is closed (true) or open (false) on target pointGeomException
- if object is immutablepublic void set(double x1, double y1, double x2, double y2)
(x1,y1)-(x2,y2)
.
The object must be mutable.x1,y1
- source pointx2,y2
- target pointGeomException
- if object is immutablepublic void set(XPoint source, XPoint target, boolean sc, boolean tc)
source-target
with source / target
closed according to sc
/ tc
.If either (or both) point is null, the point won't be overwritten. The object must be mutable.
source
- source pointtarget
- target pointsc
- segment is closed (true) or open (false) on source pointtc
- segment is closed (true) or open (false) on target pointGeomException
- if object is immutablepublic void set(XPoint source, XPoint target)
source-target
.
If either (or both) point is null
, the point won't be overwritten.
The object must be mutable.
source
- source pointtarget
- target pointGeomException
- if object is immutablepublic void setRay(double x, double y, double slope, int dir)
(x,y)
and an unknown
point in direction dir
using slope slope
.The object must be mutable.
x,y
- source pointslope
- slope of segmentdir
- the direction used (any constant of {XParametricCurve.DIRECTION_UP
,
XParametricCurve.DIRECTION_DOWN
,XParametricCurve.DIRECTION_LEFT
,XParametricCurve.DIRECTION_RIGHT
})GeomException
- if invalid direction constant or if object is immutablepublic void setRay(XPoint source, double slope, int dir)
source
and an unknown
point in direction dir
using slope slope
.
If the point is null
, the point won't be overwritten.
The object must be mutable.
source
- source pointslope
- slope of segmentdir
- the direction used (any constant of {XParametricCurve.DIRECTION_UP
,
XParametricCurve.DIRECTION_DOWN
,XParametricCurve.DIRECTION_LEFT
,XParametricCurve.DIRECTION_RIGHT
})GeomException
- if invalid direction constant or if object is immutablepublic void setSource(XPoint source)
source
(if not null
).
The object must be mutable.setSource
in class XParametricCurve
source
- source pointGeomException
- if object is immutablepublic void setTarget(XPoint target)
target
(if not null
).
The object must be mutable.setTarget
in class XParametricCurve
target
- target pointGeomException
- if object is immutablepublic XSegment toSegment()
this
object. The return value is
this
if this object is a segment (XParametricCurve.STATE_BOTH_END
is set)
or it is mutable. In all other cases a new XSegment object will be returned.
Note that in this case source and target points refer to the same objects than
this source and target points.public XSegment toRay()
this
object (which is at the target point open).
The return value is this
if this object is a ray or it is mutable.
In all other cases a new XSegment object will be returned.
Note that in this case source and target points refer to the same objects than
this source and target points.public XSegment toLine()
this
object. The return value is
this
if this object is a line (XParametricCurve.STATE_BOTH_END
is cleared)
or it is mutable. In all other cases a new XSegment object will be returned.
Note that in this case source and target points refer to the same objects than
this source and target points.public XObject transform(double m00, double m01, double m02, double m10, double m11, double m12)
this
XObject by the given affine
transformation matrix.transform
in class XObject
m00,m01,m02
- first row of the transformation matrixm10,m11,m12
- second row of the transformation matrixthis
, only if it is
mutable, otherwise a new XObject represeting the transformed object)public boolean supportIntersection(int mode, java.lang.Object o)
mode
- intersection modeo
- object for intersectionpublic java.lang.Object intersection(int mode, java.lang.Object o)
BasicList
) of intersection objects.
This method does not verify, if the intersection with o can be
calculated (use supportIntersection(int, java.lang.Object)
instead), but throws an
IntersectionException
, if an error occures.
This means, it supportIntersection(int, java.lang.Object)
returns true and this method does
The resulted objects are always newly created and do not point to existing objects.
mode
- intersection modeo
- object for intersectionIntersectionException
- if an error occuredpublic int locate(XPoint p)
Intersectable.POINT_INSIDE
,Intersectable.POINT_OUTSIDE
,
Intersectable.POINT_ON_BORDER
}).
Because this class represents line objects, Intersectable.POINT_INSIDE
cannot occur as return value.p
- point to locateGeomException
- p
is null
public java.lang.Object getOldXObject()
getOldXObject
in class XObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |