Package geomerative

Class RCommand

    • 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 point coordinates.
        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, control 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, 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
        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

      • 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.
      • 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.
      • 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 split.
        Returns:
        RPoint[], the tangent vectors returned in an array.
      • intersectionPoints

        public RPoint[] intersectionPoints​(RCommand other)
      • closestAdvFrom

        public static float closestAdvFrom​(RCommand c,
                                           RPoint p)