|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.graphics.UtilitiesLine
The UtilitiesLine class provides the basic functionalities
needed to work on lines.
The parametric representation of a line in 2D space looks like follows:
x=x(t)
y=y(t)
In most cases cubic polynomials are used, because lower-degree polynomials give too little flexibility in controlling the shape of a line, and higher- degree polynomials can introduce unwanted difficulties and require more computation time.
The cubic polynomials that define in 2D space a line segment
Q(t)=[x(t) y(t)]
are of the form
x(t)=axt^3 + bxt^2 + cxt + dx
y(t)=ayt^3 + byt^2 + cyt + dy
Where t is restricted to the interval [0, 1].
|
C= |
[ax ay bx by cx cy dx dy] |
The coefficient matrix C can be rewritten as
C=M*G
where M is a 4x4 matrix and G is a four element
column vector of geometric constraints, called the geometry vector.
For the different types of cubic lines(hermite, bezier, catmull rom,
b spline, ...) M and/or G may differ.
Now the polynomials can be rewritten as
Q(t)=[x(t) y(t)]=T*M*G
expanding this gives
| Q(t)=[x(t) y(t)]= | [t^3 t^2 t 1] |
[m11 m12 m13 m14 m21 m22 m23 m24 m31 m32 m33 m34 m41 m42 m43 m44] |
[G1 G2 G3 G4] |
To see now that the coefficients of the cubic polynomial can depend on four
constraints, this definition is multiplied out just for
x(t)=T*M*Gx
Where Gx refers to the column vector of just the x components of the
geometry vector.
x(t)=
(t^3*m11 + t^2*m21 + t*m31 + m41)g1x +
(t^3*m12 + t^2*m22 + t*m32 + m42)g2x +
(t^3*m13 + t^2*m23 + t*m33 + m43)g3x +
(t^3*m14 + t^2*m24 + t*m34 + m44)g4x
The Hermite form of the cubic polynomial line segment is determined by
the endpoints P1 and P4 and tangent vectors at
the endpoints R1 and R4.
The geometry vector is
Gh=
[P1
P4
R1
R2]
and the basis matrix is
Mh=
[ 2 -2 1 1
-3 3 -2 -1
0 0 1 0
1 0 0 0]
The B�zier form of the cubic polynomial line segment indirectly specifies the
endpoint tangent vectors by specifing two intermediate points that are not on
the line. The starting and ending tangent vectors are determined by the
vectors P1 P2 and P3 P4 and are related to
R1 and R4 of the Hermite form.
The geometry vector is
Gb=
[P1
P2
P3
P4]
and the basis matrix is
Mh=
[-1 3 -3 1
3 -6 3 0
-3 3 0 0
1 0 0 0]
Because the Hermite form of the cubic polynomial line segments can always be represented by the B�zier form of the cubic polynomial line segments and have no benefit against the B�zier form they are not supported by this library.
For a further discussion on parametric cubic lines see the book 'Computer Graphics:Principles and Practice' from our library!
| Field Summary | |
static int |
BEZIER_GEOMETRY_VECTOR_P1
enumeration that tells about the indices in the bezier geometry vector |
static int |
BEZIER_GEOMETRY_VECTOR_P2
enumeration that tells about the indices in the bezier geometry vector |
static int |
BEZIER_GEOMETRY_VECTOR_P3
enumeration that tells about the indices in the bezier geometry vector |
static int |
BEZIER_GEOMETRY_VECTOR_P4
enumeration that tells about the indices in the bezier geometry vector |
static Matrix44D |
BEZIER_TRANSFORM
the transformation matrix needed to calculate the bezier line path |
static Matrix44D |
BEZIER_TRANSFORM_INVERSE
the inverse transformation matrix to the bezier transformation matrix |
static int |
CATMULL_ROM_GEOMETRY_VECTOR_P1
enumeration that tells about the indices in the catmull rom geometry vector |
static int |
CATMULL_ROM_GEOMETRY_VECTOR_P2
enumeration that tells about the indices in the catmull rom geometry vector |
static int |
CATMULL_ROM_GEOMETRY_VECTOR_P3
enumeration that tells about the indices in the catmull rom geometry vector |
static int |
CATMULL_ROM_GEOMETRY_VECTOR_P4
enumeration that tells about the indices in the catmull rom geometry vector |
static Matrix44D |
CATMULL_ROM_TRANSFORM
the transformation matrix needed to calculate the catmull rom line path |
static Matrix44D |
CATMULL_ROM_TRANSFORM_INVERSE
the inverse transformation matrix to the catmull rom transformation matrix |
static int |
CUBIC_BEZIER
enumeration that tells about the different types of the cubic polynomial line segments |
static int |
CUBIC_BEZIER_SEGMENT
enumeration that tells about the different styles a line segment can have |
static int |
CUBIC_CATMULL_ROM
enumeration that tells about the different types of the cubic polynomial line segments |
static int |
CUBIC_CATMULL_ROM_SEGMENT
enumeration that tells about the different styles a line segment can have |
static int |
LINEAR_SEGMENT
enumeration that tells about the different styles a line segment can have |
static int |
UNDEFINED
constant for any undefined state |
| Method Summary | |
static Boundary |
computeBoundingBox(int[] coordsX,
int[] coordsY,
int[] coordsXRef,
int[] coordsYRef,
int[] segmentTypes)
Computes the bounding box of a closed (polygon) or open (polyline) primitive. |
static Coordinate |
computeCoordinateOfSegment(double[] segment,
double t)
|
static void |
computeCoordinateOfSegment(double[] segment,
double t,
int[] result)
|
static int |
createCubicSegments(double[] coordsX,
double[] coordsY,
ArrayListInt ptXSegments,
ArrayListInt ptYSegments,
int transformation,
double weight)
creates linear segments of the cubic line that is given by the coordsX and coordsY. |
static double |
getLineDirection(int x1,
int y1,
int x2,
int y2)
Calculates the counter clockwise angle between the line given by x1, y1, x2 and y2
and the x axis. |
static boolean |
hits(double x1,
double y1,
double x2,
double y2,
int x,
int y,
int weight)
returns a flag that indicates whether the coordinate given by the components x and y hits the linear line segment
between the two given line points by with the coordinates x1
and y1 and x2 and y2 or not. |
static boolean |
isLinearSegment(double[] geometryX,
double[] geometryY,
double epsilon)
This method checks weather the amplitude of a bezier line segment is less than the given epsilon or not. |
static void |
subdivideBezier(ArrayListInt linePtX,
ArrayListInt linePtY,
double[] geometryX,
double[] geometryY,
double segmentStart,
double segmentEnd,
double weight,
int index)
This method devides a bezier line segment into a set of line segments, such that every generated segment is approximately a straight line. |
static void |
subdivideBezier(double[] geometryX,
double[] geometryY,
double[] geometryXFirst,
double[] geometryYFirst,
double[] geometryXSecond,
double[] geometryYSecond)
This method devides a bezier line segment at position t=0.5 into two parts. |
static void |
transformGeometryVector(double[] geometryXconverted,
double[] geometryYconverted,
int[] geometryX,
int[] geometryY,
int type,
int typeConvertTo)
This method converts the geometry vectors of one cubic line segment type, given by geometryX and geometryY,
into the geometry vector of antoher type. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int UNDEFINED
public static final int LINEAR_SEGMENT
public static final int CUBIC_BEZIER_SEGMENT
public static final int CUBIC_CATMULL_ROM_SEGMENT
public static final int CUBIC_BEZIER
public static final int CUBIC_CATMULL_ROM
public static final int BEZIER_GEOMETRY_VECTOR_P1
public static final int BEZIER_GEOMETRY_VECTOR_P2
public static final int BEZIER_GEOMETRY_VECTOR_P3
public static final int BEZIER_GEOMETRY_VECTOR_P4
public static final int CATMULL_ROM_GEOMETRY_VECTOR_P1
public static final int CATMULL_ROM_GEOMETRY_VECTOR_P2
public static final int CATMULL_ROM_GEOMETRY_VECTOR_P3
public static final int CATMULL_ROM_GEOMETRY_VECTOR_P4
public static final Matrix44D BEZIER_TRANSFORM
public static final Matrix44D BEZIER_TRANSFORM_INVERSE
public static final Matrix44D CATMULL_ROM_TRANSFORM
public static final Matrix44D CATMULL_ROM_TRANSFORM_INVERSE
| Method Detail |
public static final double getLineDirection(int x1,
int y1,
int x2,
int y2)
x1, y1, x2 and y2
and the x axis. The returned angle is given in degree. The starting point
of the line must not lie at the origin.
x1 - the x component of the lines starting pointy1 - the y component of the lines starting pointx2 - the x component of the lines ending pointy2 - the y component of the lines ending point
public static final boolean hits(double x1,
double y1,
double x2,
double y2,
int x,
int y,
int weight)
x and y hits the linear line segment
between the two given line points by with the coordinates x1
and y1 and x2 and y2 or not.
x1 - the x coordinate of the first line pointy1 - the y coordinate of the first line pointx2 - the x coordinate of the second line pointy2 - the y coordinate of the second line pointx - the x coordinate of the point to check fory - the y coordinate of the point to check forweight - the weight of the line
public static void transformGeometryVector(double[] geometryXconverted,
double[] geometryYconverted,
int[] geometryX,
int[] geometryY,
int type,
int typeConvertTo)
geometryX and geometryY,
into the geometry vector of antoher type. The converted geometry vectors
are returned through geometryXconverted and
geometryYconverted.
geometryXconverted - x components of the converted geometry vectorgeometryYconverted - y components of the converted geometry vectorgeometryX - x components of the geometry vector to convertgeometryY - y components of the geometry vector to converttype - of the geometry vectors to converttypeConvertTo - the type of geometry vectors to convert to
public static final void subdivideBezier(ArrayListInt linePtX,
ArrayListInt linePtY,
double[] geometryX,
double[] geometryY,
double segmentStart,
double segmentEnd,
double weight,
int index)
geometryX and geometryY are
the geometry vector for a bezier line segment.linePtX and linePtY.
linePtX - the x components of the generated segmentslinePtY - the y components of the generated segmentsgeometryX - the x components of the line to devidegeometryY - the y components of the line to devidesegmentStart - the starting delta of the given line segmentsegmentEnd - the ending delta of the given line segment
public static final void subdivideBezier(double[] geometryX,
double[] geometryY,
double[] geometryXFirst,
double[] geometryYFirst,
double[] geometryXSecond,
double[] geometryYSecond)
geometryX and
geometryY are the geometry vector for a bezier line segment.
The resulting bezier line segments are returned through the given vectors
geometryXFirst and geometryYFirst for the left
segment and geometryXSecond and geometryYSecond
for the right segment. They are also geometry vectors.
geometryX - x components of the bezier geometry vectorgeometryY - y components of the bezier geometry vectorgeometryXFirst - x components of the first bezier geometry vectorgeometryYFirst - y components of the first bezier geometry vectorgeometryXSecond - x components of the second bezier geometry vectorgeometryYSecond - y components of the second bezier geometry vector
public static final boolean isLinearSegment(double[] geometryX,
double[] geometryY,
double epsilon)
geometryX
and geometryY are the geometry vector for a bezier line
segment.
geometryX - x components of the bezier geometry vectorgeometryY - y components of the bezier geometry vector
public static final int createCubicSegments(double[] coordsX,
double[] coordsY,
ArrayListInt ptXSegments,
ArrayListInt ptYSegments,
int transformation,
double weight)
coordsX and coordsY. The x components of the
linear segment coordinates are stored in ptXSegment and the
y components are stored in ptYSegment. The transformation
type of the cubic line is given by transformation.
coordsX - the x components of the line coordinatescoordsY - the y components of the line coordinatesptXSegments - the calculated x components of the linear segmentsptYSegments - the calculated y components of the linear segmentstransformation - the transformation type of the cubic lineweight - the weight of the cubic line
CUBIC_BEZIER,
CUBIC_CATMULL_ROM
public static final Coordinate computeCoordinateOfSegment(double[] segment,
double t)
public static final void computeCoordinateOfSegment(double[] segment,
double t,
int[] result)
public static Boundary computeBoundingBox(int[] coordsX,
int[] coordsY,
int[] coordsXRef,
int[] coordsYRef,
int[] segmentTypes)
coordsX - The x coordinates of the shapecoordsY - The y coordinates of the shapecoordsXRef - The reference x coordinates of the shapecoordsYRef - The reference y coordinates of the shapesegmentTypes - The segment types of the shape
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||