rigComponent 0.1.1
RigKit pack API - rigComponent
Loading...
Searching...
No Matches
PrimitiveVertices.h File Reference

Expands the parametric 2D primitives into local-space vertex lists. More...

#include <glm/glm.hpp>
#include <vector>
#include "CArc.h"
#include "CRegularPolygon.h"
#include "CRing.h"
#include "CSpline.h"
#include "CStar.h"
Include dependency graph for PrimitiveVertices.h:

Functions

int rigkit::ecs::segmentsForRadius (float radius, int requested=0)
 Vertex expansion for the parametric primitives.
std::vector< glm::vec2 > rigkit::ecs::verticesOf (const CRegularPolygon &shape)
 Corner vertices of a regular n-gon, rotation included.
std::vector< glm::vec2 > rigkit::ecs::verticesOf (const CStar &shape)
 Alternating outer and inner vertices of a star.
std::vector< glm::vec2 > rigkit::ecs::verticesOf (const CArc &shape, int segments=0)
 Arc as a polyline from start angle to end angle.
std::vector< glm::vec2 > rigkit::ecs::verticesOf (const CSpline &shape, int segments=0)
 Spline samples along the knot domain (closed loops repeat the first point).
glm::vec2 rigkit::ecs::pointOn (const CSpline &shape, float t)
 Point at normalized parameter t in [0, 1] along the knot domain.
void rigkit::ecs::rimsOf (const CRing &shape, std::vector< glm::vec2 > &outer, std::vector< glm::vec2 > &inner, int segments=0)
 Outer and inner rims of a ring, same winding and matching lengths.

Detailed Description

Expands the parametric 2D primitives into local-space vertex lists.

Segment counts follow radius, so small shapes stay cheap to tessellate on Raspberry Pi.

Function Documentation

◆ pointOn()

glm::vec2 rigkit::ecs::pointOn ( const CSpline & shape,
float t )

Point at normalized parameter t in [0, 1] along the knot domain.

Returns
{0,0} when the spline cannot be evaluated.

◆ segmentsForRadius()

int rigkit::ecs::segmentsForRadius ( float radius,
int requested = 0 )

Vertex expansion for the parametric primitives.

Drawing, picking, and bounds all need the same points. Deriving them in one place is what keeps a star the same star everywhere. Curve tessellation for radius, clamped so tiny shapes stay cheap and big ones stay smooth. Pass a positive requested to override.

◆ verticesOf() [1/3]

std::vector< glm::vec2 > rigkit::ecs::verticesOf ( const CArc & shape,
int segments = 0 )

Arc as a polyline from start angle to end angle.

Includes the centre as the final point when pie is set, so the result closes into a wedge. Uses rx/ry (elliptical when unequal).

◆ verticesOf() [2/3]

std::vector< glm::vec2 > rigkit::ecs::verticesOf ( const CRegularPolygon & shape)

Corner vertices of a regular n-gon, rotation included.

Empty below three sides.

◆ verticesOf() [3/3]

std::vector< glm::vec2 > rigkit::ecs::verticesOf ( const CStar & shape)

Alternating outer and inner vertices of a star.

Empty below three points.