geomerative
Class RCommand

java.lang.Object
  extended by geomerative.RGeomElem
      extended by geomerative.RCommand

public class RCommand
extends RGeomElem


Field Summary
static int ADAPTATIVE
           
 RPoint[] controlPoints
           
static int CUBICBEZIERTO
           
 RPoint endPoint
           
static int LINETO
           
static int QUADBEZIERTO
           
static float segmentAngleTol
           
static int segmentType
           
 RPoint startPoint
           
 int type
           
static int UNIFORMLENGTH
           
static int UNIFORMSTEP
           
 
Fields inherited from class geomerative.RGeomElem
COMMAND, CONTOUR, GROUP, height, MESH, name, POLYGON, SHAPE, SUBSHAPE, TRISTRIP, UNKNOWN, width
 
Constructor Summary
RCommand()
          Create an empty command
RCommand(float spx, float spy, float epx, float epy)
          Create a LINETO command object with specific start and end point coordinates.
RCommand(float spx, float spy, float cp1x, float cp1y, float epx, float epy)
          Create a QUADBEZIERTO command object with specific start, control and end point coordinates.
RCommand(float spx, float spy, float cp1x, float cp1y, float cp2x, float cp2y, float epx, float epy)
          Create a CUBICBEZIERTO command object with specific start, controls and end point coordinates.
RCommand(RCommand c)
          Make a copy of another RCommand object.
RCommand(RCommand c, RPoint sp)
          Make a copy of another RCommand object with a specific start point.
RCommand(RPoint sp, RPoint ep)
          Create a LINETO command object with specific start and end points.
RCommand(RPoint sp, RPoint cp1, RPoint ep)
          Create a QUADBEZIERTO command object with specific start, control and end points.
RCommand(RPoint sp, RPoint cp1, RPoint cp2, RPoint ep)
          Create a CUBICBEZIERTO command object with specific start, controls and end point coordinates.
 
Method Summary
static float closestAdvFrom(RCommand c, RPoint p)
           
 RClosest closestPoints(RCommand other)
           
 boolean contains(RPoint p)
           
 int countControlPoints()
          Use this to return the number of control points of the curve.
static RClosest cubicCubicClosest(RCommand c1, RCommand c2)
           
static RPoint[] cubicCubicIntersection(RCommand c1, RCommand c2)
           
 void draw(processing.core.PApplet a)
          Use this method to draw the command.
 void draw(processing.core.PGraphics g)
          Use this method to draw the command.
 int getCommandType()
          Use this to return the command type.
 float getCurveLength()
          Use this to return arc length of a curve.
 float getCurveLength(float t)
          Use this to return arc length of a curve.
 RPoint[] getHandles()
          Use this to return the start, control and end points of the curve.
 RPoint[][] getHandlesInPaths()
           
 RPoint getPoint(float t)
          Use this to return a specific point on the curve.
 RPoint[] getPoints()
          Use this to return the points on the curve.
 RPoint[][] getPointsInPaths()
           
 RPoint getTangent(float t)
          Use this to return a specific tangent on the curve.
 RPoint[] getTangents()
           
 RPoint[] getTangents(int segments)
          Use this to return the tangents on the curve.
 RPoint[][] getTangentsInPaths()
           
 int getType()
           
 RPoint[] intersectionPoints(RCommand other)
           
static RClosest lineCubicClosest(RCommand c1, RCommand c2)
           
static RPoint[] lineCubicIntersection(RCommand c1, RCommand c2)
           
static RClosest lineLineClosest(RCommand c1, RCommand c2)
           
static RPoint[] lineLineIntersection(RCommand c1, RCommand c2)
           
static RClosest lineQuadClosest(RCommand c1, RCommand c2)
           
static RPoint[] lineQuadIntersection(RCommand c1, RCommand c2)
           
static RClosest quadCubicClosest(RCommand c1, RCommand c2)
           
static RPoint[] quadCubicIntersection(RCommand c1, RCommand c2)
           
static RClosest quadQuadClosest(RCommand c1, RCommand c2)
           
static RPoint[] quadQuadIntersection(RCommand c1, RCommand c2)
           
static void setSegmentAngle(float segmentAngleTolerance)
          Use this to set the segmentator angle tolerance for the ADAPTATIVE segmentator and set the segmentator to ADAPTATIVE.
static void setSegmentator(int segmentatorType)
          Use this to set the segmentator type.
static void setSegmentGraphic(processing.core.PGraphics g)
          Use this to set the segmentator graphic context.
static void setSegmentLength(float segmentLngth)
          Use this to set the segmentator length for the UNIFORMLENGTH segmentator and set the segmentator to UNIFORMLENGTH.
static void setSegmentOffset(float segmentOffst)
          Use this to set the segmentator offset for the UNIFORMLENGTH segmentator and set the segmentator to UNIFORMLENGTH.
static void setSegmentStep(float segmentStps)
          Use this to set the segmentator step for the UNIFORMSTEP segmentator and set the segmentator to UNIFORMSTEP.
 RCommand[] split(float t)
          Returns two commands resulting of splitting the command.
 RShape toShape()
           
 
Methods inherited from class geomerative.RGeomElem
centerIn, centerIn, centerIn, contains, contains, containsBounds, containsHandles, draw, getArea, getBottomLeft, getBottomRight, getBounds, getBoundsPoints, getCenter, getCenteringTransf, getCenteringTransf, getCenteringTransf, getCentroid, getCurveLengths, getHeight, getOrigHeight, getOrigWidth, getStyle, getTopLeft, getTopRight, getWidth, getX, getY, intersects, intersects, intersectsBounds, intersectsHandles, isIn, isIn, print, rotate, rotate, rotate, scale, scale, scale, scale, scale, scale, setAlpha, setAlpha, setAlpha, setFill, setFill, setFill, setFillAlpha, setFillAlpha, setName, setStroke, setStroke, setStroke, setStrokeAlpha, setStrokeAlpha, setStrokeCap, setStrokeJoin, setStrokeWeight, setStrokeWeight, setStyle, shear, skewX, skewY, toMesh, toPolygon, transform, transform, transform, translate, translate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

public int type

controlPoints

public RPoint[] controlPoints

startPoint

public RPoint startPoint

endPoint

public RPoint endPoint

LINETO

public static final int LINETO
See Also:
Constant Field Values

QUADBEZIERTO

public static final int QUADBEZIERTO
See Also:
Constant Field Values

CUBICBEZIERTO

public static final int CUBICBEZIERTO
See Also:
Constant Field Values

ADAPTATIVE

public static final int ADAPTATIVE
See Also:
Constant Field Values

UNIFORMLENGTH

public static final int UNIFORMLENGTH
See Also:
Constant Field Values

UNIFORMSTEP

public static final int UNIFORMSTEP
See Also:
Constant Field Values

segmentType

public static int segmentType

segmentAngleTol

public static float segmentAngleTol
Constructor Detail

RCommand

public RCommand()
Create an empty command


RCommand

public RCommand(RCommand c)
Make a copy of another RCommand object. This can be useful when wanting to transform one but at the same time keep the original.

Parameters:
c - the object of which to make the copy

RCommand

public RCommand(RCommand c,
                RPoint sp)
Make a copy of another RCommand object with a specific start point.

Parameters:
c - the object of which to make the copy
sp - the start point of the command to be created

RCommand

public RCommand(RPoint sp,
                RPoint ep)
Create a LINETO command object with specific start and end points.

Parameters:
sp - the start point of the command to be created
ep - the end point of the command to be created

RCommand

public RCommand(float spx,
                float spy,
                float epx,
                float epy)
Create a LINETO command object with specific start and end point coordinates.

Parameters:
spx - the x coordinate of the start point of the command to be created
spy - the y coordinate of the start point of the command to be created
epx - the x coordinate of the end point of the command to be created
epy - the y coordinate of the end point of the command to be created

RCommand

public RCommand(RPoint sp,
                RPoint cp1,
                RPoint ep)
Create a QUADBEZIERTO command object with specific start, control and end points.

Parameters:
sp - the start point of the command to be created
cp1 - the first control point of the command to be created
ep - the end point of the command to be created

RCommand

public RCommand(float spx,
                float spy,
                float cp1x,
                float cp1y,
                float epx,
                float epy)
Create a QUADBEZIERTO command object with specific start, control and end point coordinates.

Parameters:
spx - the x coordinate of the start point of the command to be created
spy - the y coordinate of the start point of the command to be created
cp1x - the x coordinate of the first control point of the command to be created
cp1y - the y coordinate of the first control point of the command to be created
epx - the x coordinate of the end point of the command to be created
epy - the y coordinate of the end point of the command to be created

RCommand

public RCommand(RPoint sp,
                RPoint cp1,
                RPoint cp2,
                RPoint ep)
Create a CUBICBEZIERTO command object with specific start, controls and end point coordinates.

Parameters:
sp - the start point of the command to be created
cp1 - the first control point of the command to be created
cp2 - the second control point of the command to be created
ep - the end point of the command to be created

RCommand

public RCommand(float spx,
                float spy,
                float cp1x,
                float cp1y,
                float cp2x,
                float cp2y,
                float epx,
                float epy)
Create a CUBICBEZIERTO command object with specific start, controls and end point coordinates.

Parameters:
spx - the x coordinate of the start point of the command to be created
spy - the y coordinate of the start point of the command to be created
cp1x - the x coordinate of the first control point of the command to be created
cp1y - the y coordinate of the first control point of the command to be created
cp2x - the x coordinate of the second control point of the command to be created
cp2y - the y coordinate of the second control point of the command to be created
epx - the x coordinate of the end point of the command to be created
epy - the y coordinate of the end point of the command to be created
Method Detail

toShape

public RShape toShape()
Specified by:
toShape in class RGeomElem

getType

public int getType()
Specified by:
getType in class RGeomElem

setSegmentator

public static void setSegmentator(int segmentatorType)
Use this to set the segmentator type. ADAPTATIVE segmentator minimizes the number of segments avoiding perceptual artifacts like angles or cusps. Use this in order to have Polygons and Meshes with the fewest possible vertices. This can be useful when using or drawing a lot the same Polygon or Mesh deriving from this Shape. UNIFORMLENGTH segmentator is the slowest segmentator and it segments the curve on segments of equal length. This can be useful for very specific applications when for example drawing incrementaly a shape with a uniform speed. UNIFORMSTEP segmentator is the fastest segmentator and it segments the curve based on a constant value of the step of the curve parameter, or on the number of segments wanted. This can be useful when segmpointsentating very often a Shape or when we know the amount of segments necessary for our specific application.


setSegmentGraphic

public static void setSegmentGraphic(processing.core.PGraphics g)
Use this to set the segmentator graphic context.

Parameters:
g - graphics object too which to adapt the segmentation of the command.

setSegmentAngle

public static void setSegmentAngle(float segmentAngleTolerance)
Use this to set the segmentator angle tolerance for the ADAPTATIVE segmentator and set the segmentator to ADAPTATIVE.

Parameters:
segmentAngleTolerance - an angle from 0 to PI/2 it defines the maximum angle between segments.

setSegmentLength

public static void setSegmentLength(float segmentLngth)
Use this to set the segmentator length for the UNIFORMLENGTH segmentator and set the segmentator to UNIFORMLENGTH.

Parameters:
segmentLngth - the length of each resulting segment.

setSegmentOffset

public static void setSegmentOffset(float segmentOffst)
Use this to set the segmentator offset for the UNIFORMLENGTH segmentator and set the segmentator to UNIFORMLENGTH.

Parameters:
segmentOffst - the offset of the first point on the path.

setSegmentStep

public static void setSegmentStep(float segmentStps)
Use this to set the segmentator step for the UNIFORMSTEP segmentator and set the segmentator to UNIFORMSTEP.

Parameters:
segmentStps - if a float from +0.0 to 1.0 is passed it's considered as the step, else it's considered as the number of steps. When a value of 0.0 is used the steps will be calculated automatically depending on an estimation of the length of the curve. The special value -1 is the same as 0.0 but also turning of the segmentation of lines (faster segmentation).

countControlPoints

public int countControlPoints()
Use this to return the number of control points of the curve.

Returns:
int, the number of control points.

getCommandType

public int getCommandType()
Use this to return the command type.

Returns:
int, an integer which can take the following values: RCommand.LINETO, RCommand.QUADBEZIERTO, RCommand.CUBICBEZIERTO.

getPoints

public RPoint[] getPoints()
Use this to return the points on the curve. It returns the points in the way of an array of RPoint.

Specified by:
getPoints in class RGeomElem
Returns:
RPoint[], the vertices returned in an array.

getPoint

public RPoint getPoint(float t)
Use this to return a specific point on the curve. It returns the RPoint for a given advancement parameter t on the curve.

Specified by:
getPoint in class RGeomElem
Parameters:
t - float, the parameter of advancement on the curve. t must have values between 0 and 1.
Returns:
RPoint, the vertice returned.

getTangents

public RPoint[] getTangents(int segments)
Use this to return the tangents on the curve. It returns the vectors in the form of an array of RPoint.

Parameters:
segments - int, the number of segments in which to divide the curve.
Returns:
RPoint[], the tangent vectors returned in an array.

getTangents

public RPoint[] getTangents()
Specified by:
getTangents in class RGeomElem

getTangent

public RPoint getTangent(float t)
Use this to return a specific tangent on the curve. It returns the RPoint representing the tangent vector for a given value of the advancement parameter t on the curve.

Specified by:
getTangent in class RGeomElem
Parameters:
t - float, the parameter of advancement on the curve. t must have values between 0 and 1.
Returns:
RPoint, the vertice returned.

getCurveLength

public float getCurveLength(float t)
Use this to return arc length of a curve. It returns the float representing the length given the value of the advancement parameter t on the curve. The current implementation of this function is very slow, not recommended for using during frame draw.

Parameters:
t - float, the parameter of advancement on the curve. t must have values between 0 and 1.
Returns:
float, the length returned.

getCurveLength

public float getCurveLength()
Use this to return arc length of a curve. It returns the float representing the length given the value of the advancement parameter t on the curve. The current implementation of this function is very slow, not recommended for using during frame draw.

Overrides:
getCurveLength in class RGeomElem
Returns:
float, the length returned.

getPointsInPaths

public RPoint[][] getPointsInPaths()
Specified by:
getPointsInPaths in class RGeomElem

getHandlesInPaths

public RPoint[][] getHandlesInPaths()
Specified by:
getHandlesInPaths in class RGeomElem

getTangentsInPaths

public RPoint[][] getTangentsInPaths()
Specified by:
getTangentsInPaths in class RGeomElem

contains

public boolean contains(RPoint p)
Specified by:
contains in class RGeomElem

draw

public void draw(processing.core.PGraphics g)
Use this method to draw the command.

Specified by:
draw in class RGeomElem
Parameters:
g - PGraphics, the graphics object on which to draw the command

draw

public void draw(processing.core.PApplet a)
Use this method to draw the command.

Specified by:
draw in class RGeomElem
Parameters:
a - the applet object on which to draw the command

getHandles

public RPoint[] getHandles()
Use this to return the start, control and end points of the curve. It returns the points in the way of an array of RPoint.

Specified by:
getHandles in class RGeomElem
Returns:
RPoint[], the vertices returned in an array.

split

public RCommand[] split(float t)
Returns two commands resulting of splitting the command.

Parameters:
t - the advancement on the curve where command should be splitted.
Returns:
RPoint[], the tangent vectors returned in an array.

intersectionPoints

public RPoint[] intersectionPoints(RCommand other)

lineLineIntersection

public static RPoint[] lineLineIntersection(RCommand c1,
                                            RCommand c2)

lineQuadIntersection

public static RPoint[] lineQuadIntersection(RCommand c1,
                                            RCommand c2)

lineCubicIntersection

public static RPoint[] lineCubicIntersection(RCommand c1,
                                             RCommand c2)

quadQuadIntersection

public static RPoint[] quadQuadIntersection(RCommand c1,
                                            RCommand c2)

quadCubicIntersection

public static RPoint[] quadCubicIntersection(RCommand c1,
                                             RCommand c2)

cubicCubicIntersection

public static RPoint[] cubicCubicIntersection(RCommand c1,
                                              RCommand c2)

closestPoints

public RClosest closestPoints(RCommand other)

closestAdvFrom

public static float closestAdvFrom(RCommand c,
                                   RPoint p)

lineLineClosest

public static RClosest lineLineClosest(RCommand c1,
                                       RCommand c2)

lineQuadClosest

public static RClosest lineQuadClosest(RCommand c1,
                                       RCommand c2)

lineCubicClosest

public static RClosest lineCubicClosest(RCommand c1,
                                        RCommand c2)

quadQuadClosest

public static RClosest quadQuadClosest(RCommand c1,
                                       RCommand c2)

quadCubicClosest

public static RClosest quadCubicClosest(RCommand c1,
                                        RCommand c2)

cubicCubicClosest

public static RClosest cubicCubicClosest(RCommand c1,
                                         RCommand c2)


Geomerative by Ricard Marxer, http://www.ricardmarxer.com/geomerative/