reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofPolyline_< T > Class Template Reference

#include <ofPolyline.h>

Public Types

using VertexType = T
 

Public Member Functions

Add and Remove Vertices
void clear ()
 Removes all the points from the ofPolyline.
 
void addVertex (const T &p)
 Adds a point using an T at the end of the ofPolyline.
 
void addVertex (float x, float y, float z=0)
 Adds a point using floats at the end of the ofPolyline.
 
void addVertices (const std::vector< T > &verts)
 Add multiple points at the end of the ofPolyline using a vector of T objects.
 
void addVertices (const T *verts, int numverts)
 Adds multiple points at the end of the ofPolyline using a pointer to an array of T objects.
 
void insertVertex (const T &p, int index)
 
void insertVertex (float x, float y, float z, int index)
 
void removeVertex (int index)
 Remove a vertex at a given index.
 
void resize (size_t size)
 Resize the number of points in the ofPolyline to the value passed in.
 
Access Vertices
size_t size () const
 The number of points in the ofPolyline.
 
const T & operator[] (int index) const
 
T & operator[] (int index)
 
std::vector< T > & getVertices ()
 Gets a vector of vertices that the line contains.
 
const std::vector< T > & getVertices () const
 
std::vector< T >::iterator begin ()
 
std::vector< T >::const_iterator begin () const
 
std::vector< T >::reverse_iterator rbegin ()
 
std::vector< T >::const_reverse_iterator rbegin () const
 
std::vector< T >::iterator end ()
 
std::vector< T >::const_iterator end () const
 
std::vector< T >::reverse_iterator rend ()
 
std::vector< T >::const_reverse_iterator rend () const
 
Lines and Curves
void lineTo (const T &to)
 Add a straight line from the last point added, or from 0,0 if no point is set, to the point indicated by the T passesd in.
 
void lineTo (float x, float y, float z=0)
 Add a straight line from the last point added, or from 0,0 if no point is set, to the point indicated by the floats x,y,z passesd in.
 
void arc (const T &center, float radiusX, float radiusY, float angleBegin, float angleEnd, bool clockwise, int circleResolution=20)
 Adds an arc around the T center with the width of radiusX and the height of radiusY to the polyline.
 
void arc (const T &center, float radiusX, float radiusY, float angleBegin, float angleEnd, int circleResolution=20)
 Adds an arc around the T center with the width of radiusX and the height of radiusY.
 
void arc (float x, float y, float radiusX, float radiusY, float angleBegin, float angleEnd, int circleResolution=20)
 Adds an arc around the coordinates (x,y) with the width of radiusX and the height of radiusY.
 
void arc (float x, float y, float z, float radiusX, float radiusY, float angleBegin, float angleEnd, int circleResolution=20)
 Adds an arc around the coordinates (x,y,z) with the width of radiusX and the height of radiusY.
 
void arcNegative (const T &center, float radiusX, float radiusY, float angleBegin, float angleEnd, int circleResolution=20)
 
void arcNegative (float x, float y, float radiusX, float radiusY, float angleBegin, float angleEnd, int circleResolution=20)
 
void arcNegative (float x, float y, float z, float radiusX, float radiusY, float angleBegin, float angleEnd, int circleResolution=20)
 
void curveTo (const T &to, int curveResolution=20)
 Adds a curve to an T object passed in.
 
void curveTo (float x, float y, float z=0, int curveResolution=20)
 Adds a curve to the x,y,z points passed in with the optional resolution.
 
void bezierTo (const T &cp1, const T &cp2, const T &to, int curveResolution=20)
 Adds a cubic bezier line from the current drawing point with the 2 control points indicated by T cp1 and cp2, that ends at T to.
 
void bezierTo (float cx1, float cy1, float cx2, float cy2, float x, float y, int curveResolution=20)
 Adds a cubic bezier line from the current drawing point with the 2 control points indicated by the coordinates cx1, cy1 and cx2, cy2, that ends at the coordinates x, y.
 
void bezierTo (float cx1, float cy1, float cz1, float cx2, float cy2, float cz2, float x, float y, float z, int curveResolution=20)
 Adds a cubic bezier line in 3D space from the current drawing point with the 2 control points indicated by the coordinates cx1, cy1, cz1 and cx2, cy2, cz2, that ends at the coordinates x, y, z.
 
void quadBezierTo (float cx1, float cy1, float cz1, float cx2, float cy2, float cz2, float x, float y, float z, int curveResolution=20)
 Adds a quadratic bezier line in 3D space from the current drawing point with the beginning indicated by the coordinates cx1, cy1, cz1, the control point at cx2, cy2, cz2, and that ends at the coordinates x, y, z.
 
void quadBezierTo (const T &p1, const T &p2, const T &p3, int curveResolution=20)
 Adds a quadratic bezier line in 2D space from the current drawing point with the beginning indicated by the point p1, the control point at p2, and that ends at the point p3.
 
void quadBezierTo (float cx1, float cy1, float cx2, float cy2, float x, float y, int curveResolution=20)
 Adds a quadratic bezier line in 2D space from the current drawing point with the beginning indicated by the coordinates cx1, cy1, the control point at cx2, cy2, and that ends at the coordinates x, y.
 
Smoothing and Resampling
ofPolyline_ getSmoothed (int smoothingSize, float smoothingShape=0) const
 Gets a smoothed version of the ofPolyline.
 
ofPolyline_ getResampledBySpacing (float spacing) const
 Resamples the line based on the spacing passed in. The larger the spacing, the more points will be eliminated.
 
ofPolyline_ getResampledByCount (int count) const
 Resamples the line based on the count passed in. The lower the count passed in, the more points will be eliminated.
 
void simplify (float tolerance=0.3f)
 Simplifies the polyline, removing un-necessary vertices.
 
Transform polyline
void rotateDeg (float degrees, const glm::vec3 &axis)
 
void rotateRad (float radians, const glm::vec3 &axis)
 
 OF_DEPRECATED_MSG ("Use Deg/Rad versions.", void rotate(float degrees, const glm::vec3 &axis))
 
void translate (const glm::vec3 &p)
 
void rotateDeg (float degrees, const glm::vec2 &axis)
 
void rotateRad (float radians, const glm::vec2 &axis)
 
 OF_DEPRECATED_MSG ("Use Deg/Rad versions.", void rotate(float degrees, const glm::vec2 &axis))
 
void translate (const glm::vec2 &p)
 
void scale (float x, float y)
 Change the size of the ofPolyline These changes are non-reversible, so for instance scaling by 0,0 zeros out all data.
 
Polyline State
void close ()
 Closes the ofPolyline, meaning that all the vertices will be linked and can be "walked".
 
void setClosed (bool tf)
 Closes the ofPolyline, meaning that all the vertices will be linked and can be "walked".
 
bool isClosed () const
 
bool hasChanged ()
 Returns whether the vertices within the line have changed.
 
void flagHasChanged ()
 
Other Functions
float getIndexAtLength (float f) const
 Get (interpolated) index at given length along the path.
 
float getIndexAtPercent (float f) const
 Get (interpolated) index at given percentage along the path.
 
float getLengthAtIndex (int index) const
 Get length along path at index.
 
float getLengthAtIndexInterpolated (float findex) const
 Get length along path at interpolated index (e.g. f=5.75 => 75% along the path between 5th and 6th points)
 
getPointAtLength (float f) const
 Get point long the path at a given length (e.g. f=150 => 150 units along the path)
 
getPointAtPercent (float f) const
 Get point along the path at a given percentage (e.g. f=0.25 => 25% along the path)
 
getPointAtIndexInterpolated (float findex) const
 Get point along the path at interpolated index (e.g. f=5.75 => 75% along the path between 5th and 6th points)
 
 OF_DEPRECATED_MSG ("Use Deg/Rad versions.", float getAngleAtIndex(int index) const)
 Get angle (degrees) of the path at index.
 
 OF_DEPRECATED_MSG ("Use Deg/Rad versions.", float getAngleAtIndexInterpolated(float findex) const)
 Get angle (degrees) at interpolated index (interpolated between neighboring indices)
 
getRotationAtIndex (int index) const
 Get rotation vector at index (magnitude is sine of angle)
 
getRotationAtIndexInterpolated (float findex) const
 Get rotation vector at interpolated index (interpolated between neighboring indices) (magnitude is sine of angle)
 
float getDegreesAtIndex (int index) const
 Get angle (degrees) of the path at index.
 
float getDegreesAtIndexInterpolated (float findex) const
 Get angle (degrees) at interpolated index (interpolated between neighboring indices)
 
float getRadiansAtIndex (int index) const
 Get angle (degrees) of the path at index.
 
float getRadiansAtIndexInterpolated (float findex) const
 Get angle (degrees) at interpolated index (interpolated between neighboring indices)
 
getTangentAtIndex (int index) const
 Get tangent vector at index.
 
getTangentAtIndexInterpolated (float findex) const
 Get tangent vector at interpolated index (interpolated between neighboring indices)
 
getNormalAtIndex (int index) const
 Get normal vector at index.
 
getNormalAtIndexInterpolated (float findex) const
 Get normal vector at interpolated index (interpolated between neighboring indices)
 
int getWrappedIndex (int index) const
 Get wrapped index depending on whether poly is closed or not.
 
void setRightVector (T v=T(0, 0, -1))
 
getRightVector () const
 
Drawing
void draw () const
 Draw the line using the current renderer.
 

Constructors

 ofPolyline_ ()
 Creates an ofPolyline.
 
 ofPolyline_ (const std::vector< T > &verts)
 Creates an ofPolyline from a vector of glm::vec2 or T objects.
 
static ofPolyline_ fromRectangle (const ofRectangle &rect)
 

Geometric Functions

bool inside (float x, float y) const
 Tests whether the x,y coordinates are within a closed ofPolyline.
 
bool inside (const T &p) const
 Tests whether the T is within a closed ofPolyline.
 
ofRectangle getBoundingBox () const
 Get the bounding box of the polyline , taking into account all the points to determine the extents of the polyline.
 
float getPerimeter () const
 Gets the size of the perimeter of the polyline, good for determining length of the line, rather than just the bounding box shape.
 
float getArea () const
 Gets the precise area bounded by the line.
 
getCentroid2D () const
 Get the center of the area bounded by the line.
 
getClosestPoint (const T &target, unsigned int *nearestIndex=nullptr) const
 Gets the point on the line closest to the target. You can also optionally pass a pointer to/address of an unsigned int to get the index of the closest vertex.
 
static bool inside (float x, float y, const ofPolyline_ &polyline)
 Tests whether the x,y coordinates are within a closed ofPolyline.
 
static bool inside (const T &p, const ofPolyline_ &polyline)
 Tests whether the T is within a closed ofPolyline.
 

Member Typedef Documentation

◆ VertexType

template<class T >
using ofPolyline_< T >::VertexType = T

Constructor & Destructor Documentation

◆ ofPolyline_() [1/2]

template<class T >
ofPolyline_< T >::ofPolyline_ ( )

Creates an ofPolyline.

◆ ofPolyline_() [2/2]

template<class T >
ofPolyline_< T >::ofPolyline_ ( const std::vector< T > &  verts)

Creates an ofPolyline from a vector of glm::vec2 or T objects.

Member Function Documentation

◆ addVertex() [1/2]

template<class T >
void ofPolyline_< T >::addVertex ( const T &  p)

Adds a point using an T at the end of the ofPolyline.

◆ addVertex() [2/2]

template<class T >
void ofPolyline_< T >::addVertex ( float  x,
float  y,
float  z = 0 
)

Adds a point using floats at the end of the ofPolyline.

◆ addVertices() [1/2]

template<class T >
void ofPolyline_< T >::addVertices ( const std::vector< T > &  verts)

Add multiple points at the end of the ofPolyline using a vector of T objects.

// make a pentagon
float size = 80.f;
float X1 = 0.125*sqrt(10 + 2*sqrt(5)) * size;
float X2 = 0.125*sqrt(10 - 2*sqrt(5)) * size;
float Y1 = 0.125*(sqrt(5) - 1) * size;
float Y2 = 0.125*(sqrt(5) + 1) * size;
vector<T> verts = {
{0, -0.5 * size, 0.f),
{-X1, -Y1, 0.f},
{-X2, Y2, 0.f},
{X2, Y2, 0.f},
{X1, -Y1, 0.f},
};
p.addVertices(verts);
size_t size() const
The number of points in the ofPolyline.
Definition ofPolyline.inl:111
void addVertices(const std::vector< T > &verts)
Add multiple points at the end of the ofPolyline using a vector of T objects.
Definition ofPolyline.inl:67

◆ addVertices() [2/2]

template<class T >
void ofPolyline_< T >::addVertices ( const T *  verts,
int  numverts 
)

Adds multiple points at the end of the ofPolyline using a pointer to an array of T objects.

◆ arc() [1/4]

template<class T >
void ofPolyline_< T >::arc ( const T &  center,
float  radiusX,
float  radiusY,
float  angleBegin,
float  angleEnd,
bool  clockwise,
int  circleResolution = 20 
)

Adds an arc around the T center with the width of radiusX and the height of radiusY to the polyline.

The angleBegin and angleEnd indicate the start and end angles of the arc in degrees measured clockwise from the x-axis.

The clockwise boolean sets the drawing direction. Passing 'false' to it will draw the arc counter-clockwise.

Optionally, you can specify circleResolution, which is the number of line segments a circle would be drawn with.

If the arc doesn't start at the same point the last vertex finished a straight line will be created to join both

◆ arc() [2/4]

template<class T >
void ofPolyline_< T >::arc ( const T &  center,
float  radiusX,
float  radiusY,
float  angleBegin,
float  angleEnd,
int  circleResolution = 20 
)
inline

Adds an arc around the T center with the width of radiusX and the height of radiusY.

The angleBegin and angleEnd indicate the start and end angles of the arc in degrees measured clockwise from the x-axis.

Optionally, you can specify circleResolution, which is the number of line segments a circle would be drawn with. A partial arc will be drawn with the same resolution: if circleResolution == 20, a half- circle will be drawn with 10 segments.

If there are already vertexes in the ofPolyline the arc will extend them; a line will be created from the endmost point on the ofPolyline to the beginning point of the arc.

ofPolyline polyline1, polyline2;
// draw an line, then an semi-circle in red
polyline2.lineTo(300, 50);
T point2(450,120);
polyline2.arc(point2,100,100,0,180);
polyline2.draw();
static const ofColor_< unsigned char > red
Definition ofColor.h:594
void arc(const T &center, float radiusX, float radiusY, float angleBegin, float angleEnd, bool clockwise, int circleResolution=20)
Adds an arc around the T center with the width of radiusX and the height of radiusY to the polyline.
Definition ofPolyline.inl:331
void draw() const
Draw the line using the current renderer.
Definition ofPolyline.inl:870
void lineTo(const T &to)
Add a straight line from the last point added, or from 0,0 if no point is set, to the point indicated...
Definition ofPolyline.h:168
void ofSetColor(const ofColor &color)
Definition ofGraphics.cpp:531

Arc Example

◆ arc() [3/4]

template<class T >
void ofPolyline_< T >::arc ( float  x,
float  y,
float  radiusX,
float  radiusY,
float  angleBegin,
float  angleEnd,
int  circleResolution = 20 
)
inline

Adds an arc around the coordinates (x,y) with the width of radiusX and the height of radiusY.

The angleBegin and angleEnd indicate the start and end angles of the arc in degrees measured clockwise from the x-axis.

Optionally, you can specify circleResolution, which is the number of line segments a circle would be drawn with.

◆ arc() [4/4]

template<class T >
void ofPolyline_< T >::arc ( float  x,
float  y,
float  z,
float  radiusX,
float  radiusY,
float  angleBegin,
float  angleEnd,
int  circleResolution = 20 
)
inline

Adds an arc around the coordinates (x,y,z) with the width of radiusX and the height of radiusY.

The angleBegin and angleEnd indicate the start and end angles of the arc in degrees measured clockwise from the x-axis.

Optionally, you can specify circleResolution, which is the number of line segments a circle would be drawn with.

◆ arcNegative() [1/3]

template<class T >
void ofPolyline_< T >::arcNegative ( const T &  center,
float  radiusX,
float  radiusY,
float  angleBegin,
float  angleEnd,
int  circleResolution = 20 
)
inline

◆ arcNegative() [2/3]

template<class T >
void ofPolyline_< T >::arcNegative ( float  x,
float  y,
float  radiusX,
float  radiusY,
float  angleBegin,
float  angleEnd,
int  circleResolution = 20 
)
inline

◆ arcNegative() [3/3]

template<class T >
void ofPolyline_< T >::arcNegative ( float  x,
float  y,
float  z,
float  radiusX,
float  radiusY,
float  angleBegin,
float  angleEnd,
int  circleResolution = 20 
)
inline

◆ begin() [1/2]

template<class T >
std::vector< T >::iterator ofPolyline_< T >::begin ( )

◆ begin() [2/2]

template<class T >
std::vector< T >::const_iterator ofPolyline_< T >::begin ( ) const

◆ bezierTo() [1/3]

template<class T >
void ofPolyline_< T >::bezierTo ( const T &  cp1,
const T &  cp2,
const T &  to,
int  curveResolution = 20 
)

Adds a cubic bezier line from the current drawing point with the 2 control points indicated by T cp1 and cp2, that ends at T to.

line.addVertex(T(200, 400));
line.bezierTo(100, 100, 800, 100, 700, 400);

polyline bezier The control points are shown in red.

◆ bezierTo() [2/3]

template<class T >
void ofPolyline_< T >::bezierTo ( float  cx1,
float  cy1,
float  cx2,
float  cy2,
float  x,
float  y,
int  curveResolution = 20 
)
inline

Adds a cubic bezier line from the current drawing point with the 2 control points indicated by the coordinates cx1, cy1 and cx2, cy2, that ends at the coordinates x, y.

◆ bezierTo() [3/3]

template<class T >
void ofPolyline_< T >::bezierTo ( float  cx1,
float  cy1,
float  cz1,
float  cx2,
float  cy2,
float  cz2,
float  x,
float  y,
float  z,
int  curveResolution = 20 
)
inline

Adds a cubic bezier line in 3D space from the current drawing point with the 2 control points indicated by the coordinates cx1, cy1, cz1 and cx2, cy2, cz2, that ends at the coordinates x, y, z.

◆ clear()

template<class T >
void ofPolyline_< T >::clear ( )

Removes all the points from the ofPolyline.

◆ close()

template<class T >
void ofPolyline_< T >::close ( )

Closes the ofPolyline, meaning that all the vertices will be linked and can be "walked".

◆ curveTo() [1/2]

template<class T >
void ofPolyline_< T >::curveTo ( const T &  to,
int  curveResolution = 20 
)

Adds a curve to an T object passed in.

float angle = 0;
while (angle < TWO_PI ) {
b.curveTo( T(100*cos(angle), 100*sin(angle)));
b.curveTo( T(300*cos(angle), 300*sin(angle)));
angle += TWO_PI / 30;
}
#define TWO_PI
Definition ofMathConstants.h:25
#define b
Note
You need at least 4 points to be able to use curveTo()
See also
Catmull-Rom splines wiki

◆ curveTo() [2/2]

template<class T >
void ofPolyline_< T >::curveTo ( float  x,
float  y,
float  z = 0,
int  curveResolution = 20 
)
inline

Adds a curve to the x,y,z points passed in with the optional resolution.

◆ draw()

template<class T >
void ofPolyline_< T >::draw ( ) const

Draw the line using the current renderer.

◆ end() [1/2]

template<class T >
std::vector< T >::iterator ofPolyline_< T >::end ( )

◆ end() [2/2]

template<class T >
std::vector< T >::const_iterator ofPolyline_< T >::end ( ) const

◆ flagHasChanged()

template<class T >
void ofPolyline_< T >::flagHasChanged ( )

◆ fromRectangle()

template<class T >
ofPolyline_< T > ofPolyline_< T >::fromRectangle ( const ofRectangle rect)
static

◆ getArea()

template<class T >
float ofPolyline_< T >::getArea ( ) const

Gets the precise area bounded by the line.

◆ getBoundingBox()

template<class T >
ofRectangle ofPolyline_< T >::getBoundingBox ( ) const

Get the bounding box of the polyline , taking into account all the points to determine the extents of the polyline.

◆ getCentroid2D()

template<class T >
T ofPolyline_< T >::getCentroid2D ( ) const

Get the center of the area bounded by the line.

◆ getClosestPoint()

template<class T >
T ofPolyline_< T >::getClosestPoint ( const T &  target,
unsigned int *  nearestIndex = nullptr 
) const

Gets the point on the line closest to the target. You can also optionally pass a pointer to/address of an unsigned int to get the index of the closest vertex.

◆ getDegreesAtIndex()

template<class T >
float ofPolyline_< T >::getDegreesAtIndex ( int  index) const

Get angle (degrees) of the path at index.

◆ getDegreesAtIndexInterpolated()

template<class T >
float ofPolyline_< T >::getDegreesAtIndexInterpolated ( float  findex) const

Get angle (degrees) at interpolated index (interpolated between neighboring indices)

◆ getIndexAtLength()

template<class T >
float ofPolyline_< T >::getIndexAtLength ( float  f) const

Get (interpolated) index at given length along the path.

Includes info on percentage along segment, e.g. ret=5.75 => 75% along the path between 5th and 6th points

◆ getIndexAtPercent()

template<class T >
float ofPolyline_< T >::getIndexAtPercent ( float  f) const

Get (interpolated) index at given percentage along the path.

Includes info on percentage along segment, e.g. ret=5.75 => 75% along the path between 5th and 6th points

◆ getLengthAtIndex()

template<class T >
float ofPolyline_< T >::getLengthAtIndex ( int  index) const

Get length along path at index.

◆ getLengthAtIndexInterpolated()

template<class T >
float ofPolyline_< T >::getLengthAtIndexInterpolated ( float  findex) const

Get length along path at interpolated index (e.g. f=5.75 => 75% along the path between 5th and 6th points)

◆ getNormalAtIndex()

template<class T >
T ofPolyline_< T >::getNormalAtIndex ( int  index) const

Get normal vector at index.

◆ getNormalAtIndexInterpolated()

template<class T >
T ofPolyline_< T >::getNormalAtIndexInterpolated ( float  findex) const

Get normal vector at interpolated index (interpolated between neighboring indices)

◆ getPerimeter()

template<class T >
float ofPolyline_< T >::getPerimeter ( ) const

Gets the size of the perimeter of the polyline, good for determining length of the line, rather than just the bounding box shape.

◆ getPointAtIndexInterpolated()

template<class T >
T ofPolyline_< T >::getPointAtIndexInterpolated ( float  findex) const

Get point along the path at interpolated index (e.g. f=5.75 => 75% along the path between 5th and 6th points)

◆ getPointAtLength()

template<class T >
T ofPolyline_< T >::getPointAtLength ( float  f) const

Get point long the path at a given length (e.g. f=150 => 150 units along the path)

◆ getPointAtPercent()

template<class T >
T ofPolyline_< T >::getPointAtPercent ( float  f) const

Get point along the path at a given percentage (e.g. f=0.25 => 25% along the path)

◆ getRadiansAtIndex()

template<class T >
float ofPolyline_< T >::getRadiansAtIndex ( int  index) const

Get angle (degrees) of the path at index.

◆ getRadiansAtIndexInterpolated()

template<class T >
float ofPolyline_< T >::getRadiansAtIndexInterpolated ( float  findex) const

Get angle (degrees) at interpolated index (interpolated between neighboring indices)

◆ getResampledByCount()

template<class T >
ofPolyline_< T > ofPolyline_< T >::getResampledByCount ( int  count) const

Resamples the line based on the count passed in. The lower the count passed in, the more points will be eliminated.

This doesn't add new points to the line.

◆ getResampledBySpacing()

template<class T >
ofPolyline_< T > ofPolyline_< T >::getResampledBySpacing ( float  spacing) const

Resamples the line based on the spacing passed in. The larger the spacing, the more points will be eliminated.

line.draw();
ofTranslate(400, 0);
line.getResampledBySpacing(100).draw();
void ofTranslate(const glm::vec3 &p)
Definition ofGraphics.cpp:162

polyline resample

◆ getRightVector()

template<class T >
T ofPolyline_< T >::getRightVector ( ) const

◆ getRotationAtIndex()

template<class T >
T ofPolyline_< T >::getRotationAtIndex ( int  index) const

Get rotation vector at index (magnitude is sine of angle)

◆ getRotationAtIndexInterpolated()

template<class T >
T ofPolyline_< T >::getRotationAtIndexInterpolated ( float  findex) const

Get rotation vector at interpolated index (interpolated between neighboring indices) (magnitude is sine of angle)

◆ getSmoothed()

template<class T >
ofPolyline_< T > ofPolyline_< T >::getSmoothed ( int  smoothingSize,
float  smoothingShape = 0 
) const

Gets a smoothed version of the ofPolyline.

smoothingSize is the size of the smoothing window. So if smoothingSize is 2, then 2 points from the left, 1 in the center, and 2 on the right (5 total) will be used for smoothing each point. smoothingShape describes whether to use a triangular window (0) or box window (1) or something in between (for example, .5).

◆ getTangentAtIndex()

template<class T >
T ofPolyline_< T >::getTangentAtIndex ( int  index) const

Get tangent vector at index.

◆ getTangentAtIndexInterpolated()

template<class T >
T ofPolyline_< T >::getTangentAtIndexInterpolated ( float  findex) const

Get tangent vector at interpolated index (interpolated between neighboring indices)

◆ getVertices() [1/2]

template<class T >
std::vector< T > & ofPolyline_< T >::getVertices ( )

Gets a vector of vertices that the line contains.

◆ getVertices() [2/2]

template<class T >
const std::vector< T > & ofPolyline_< T >::getVertices ( ) const

◆ getWrappedIndex()

template<class T >
int ofPolyline_< T >::getWrappedIndex ( int  index) const

Get wrapped index depending on whether poly is closed or not.

◆ hasChanged()

template<class T >
bool ofPolyline_< T >::hasChanged ( )

Returns whether the vertices within the line have changed.

◆ insertVertex() [1/2]

template<class T >
void ofPolyline_< T >::insertVertex ( const T &  p,
int  index 
)

◆ insertVertex() [2/2]

template<class T >
void ofPolyline_< T >::insertVertex ( float  x,
float  y,
float  z,
int  index 
)

◆ inside() [1/4]

template<class T >
bool ofPolyline_< T >::inside ( const T &  p) const

Tests whether the T is within a closed ofPolyline.

◆ inside() [2/4]

template<class T >
bool ofPolyline_< T >::inside ( const T &  p,
const ofPolyline_< T > &  polyline 
)
static

Tests whether the T is within a closed ofPolyline.

◆ inside() [3/4]

template<class T >
bool ofPolyline_< T >::inside ( float  x,
float  y 
) const

Tests whether the x,y coordinates are within a closed ofPolyline.

◆ inside() [4/4]

template<class T >
bool ofPolyline_< T >::inside ( float  x,
float  y,
const ofPolyline_< T > &  polyline 
)
static

Tests whether the x,y coordinates are within a closed ofPolyline.

◆ isClosed()

template<class T >
bool ofPolyline_< T >::isClosed ( ) const

◆ lineTo() [1/2]

template<class T >
void ofPolyline_< T >::lineTo ( const T &  to)
inline

Add a straight line from the last point added, or from 0,0 if no point is set, to the point indicated by the T passesd in.

◆ lineTo() [2/2]

template<class T >
void ofPolyline_< T >::lineTo ( float  x,
float  y,
float  z = 0 
)
inline

Add a straight line from the last point added, or from 0,0 if no point is set, to the point indicated by the floats x,y,z passesd in.

◆ OF_DEPRECATED_MSG() [1/4]

template<class T >
ofPolyline_< T >::OF_DEPRECATED_MSG ( "Use Deg/Rad versions."  ,
float getAngleAtIndex(int index) const   
)

Get angle (degrees) of the path at index.

◆ OF_DEPRECATED_MSG() [2/4]

template<class T >
ofPolyline_< T >::OF_DEPRECATED_MSG ( "Use Deg/Rad versions."  ,
float getAngleAtIndexInterpolated(float findex) const   
)

Get angle (degrees) at interpolated index (interpolated between neighboring indices)

◆ OF_DEPRECATED_MSG() [3/4]

template<class T >
ofPolyline_< T >::OF_DEPRECATED_MSG ( "Use Deg/Rad versions."  ,
void   rotatefloat degrees, const glm::vec2 &axis 
)

◆ OF_DEPRECATED_MSG() [4/4]

template<class T >
ofPolyline_< T >::OF_DEPRECATED_MSG ( "Use Deg/Rad versions."  ,
void   rotatefloat degrees, const glm::vec3 &axis 
)

◆ operator[]() [1/2]

template<class T >
T & ofPolyline_< T >::operator[] ( int  index)

◆ operator[]() [2/2]

template<class T >
const T & ofPolyline_< T >::operator[] ( int  index) const

Allows you to access the points of the ofPolyline just like you would in an array, so to make the points of a line follow the mouse movement, you could do:

line[0].set(mouseX, mouseY);
int i = 1;
while ( i<bounds.size()) {
float angle = atan2(line[i-1].y - line[i].y, line[i-1].x - line[i].x);
bounds[i].set(bounds[i-1].x - cos(angle) * 20, bounds[i-1].y - sin(angle) * 20);
i++;
}

◆ quadBezierTo() [1/3]

template<class T >
void ofPolyline_< T >::quadBezierTo ( const T &  p1,
const T &  p2,
const T &  p3,
int  curveResolution = 20 
)
inline

Adds a quadratic bezier line in 2D space from the current drawing point with the beginning indicated by the point p1, the control point at p2, and that ends at the point p3.

◆ quadBezierTo() [2/3]

template<class T >
void ofPolyline_< T >::quadBezierTo ( float  cx1,
float  cy1,
float  cx2,
float  cy2,
float  x,
float  y,
int  curveResolution = 20 
)
inline

Adds a quadratic bezier line in 2D space from the current drawing point with the beginning indicated by the coordinates cx1, cy1, the control point at cx2, cy2, and that ends at the coordinates x, y.

◆ quadBezierTo() [3/3]

template<class T >
void ofPolyline_< T >::quadBezierTo ( float  cx1,
float  cy1,
float  cz1,
float  cx2,
float  cy2,
float  cz2,
float  x,
float  y,
float  z,
int  curveResolution = 20 
)

Adds a quadratic bezier line in 3D space from the current drawing point with the beginning indicated by the coordinates cx1, cy1, cz1, the control point at cx2, cy2, cz2, and that ends at the coordinates x, y, z.

polyline curves

◆ rbegin() [1/2]

template<class T >
std::vector< T >::reverse_iterator ofPolyline_< T >::rbegin ( )

◆ rbegin() [2/2]

template<class T >
std::vector< T >::const_reverse_iterator ofPolyline_< T >::rbegin ( ) const

◆ removeVertex()

template<class T >
void ofPolyline_< T >::removeVertex ( int  index)

Remove a vertex at a given index.

This function print an error and ignore the input if the index is invalid. When a vertex is removed, the internal caches are cleared.

Parameters
indexThe index of the vertex to remove.

◆ rend() [1/2]

template<class T >
std::vector< T >::reverse_iterator ofPolyline_< T >::rend ( )

◆ rend() [2/2]

template<class T >
std::vector< T >::const_reverse_iterator ofPolyline_< T >::rend ( ) const

◆ resize()

template<class T >
void ofPolyline_< T >::resize ( size_t  size)

Resize the number of points in the ofPolyline to the value passed in.

◆ rotateDeg() [1/2]

template<class T >
void ofPolyline_< T >::rotateDeg ( float  degrees,
const glm::vec2 &  axis 
)

◆ rotateDeg() [2/2]

template<class T >
void ofPolyline_< T >::rotateDeg ( float  degrees,
const glm::vec3 &  axis 
)

◆ rotateRad() [1/2]

template<class T >
void ofPolyline_< T >::rotateRad ( float  radians,
const glm::vec2 &  axis 
)

◆ rotateRad() [2/2]

template<class T >
void ofPolyline_< T >::rotateRad ( float  radians,
const glm::vec3 &  axis 
)

◆ scale()

template<class T >
void ofPolyline_< T >::scale ( float  x,
float  y 
)

Change the size of the ofPolyline These changes are non-reversible, so for instance scaling by 0,0 zeros out all data.

◆ setClosed()

template<class T >
void ofPolyline_< T >::setClosed ( bool  tf)

Closes the ofPolyline, meaning that all the vertices will be linked and can be "walked".

◆ setRightVector()

template<class T >
void ofPolyline_< T >::setRightVector ( v = T(0, 0, -1))

◆ simplify()

template<class T >
void ofPolyline_< T >::simplify ( float  tolerance = 0.3f)

Simplifies the polyline, removing un-necessary vertices.

Parameters
tolerancedetermines how dis-similar points need to be to stay in the line. Higher tolerance means more points removed, lower tolerance means less points removed.

◆ size()

template<class T >
size_t ofPolyline_< T >::size ( ) const

The number of points in the ofPolyline.

◆ translate() [1/2]

template<class T >
void ofPolyline_< T >::translate ( const glm::vec2 &  p)

◆ translate() [2/2]

template<class T >
void ofPolyline_< T >::translate ( const glm::vec3 &  p)

The documentation for this class was generated from the following files: