CG_NurbsCurveDerivative — Computes the derivative (tangent, curvature) of a NURBS curve at a given parameter
geometry CG_NurbsCurveDerivative(geometry nurbscurve, float8 parameter, integer derivative_order);
Computes the derivative of a NURBS curve at a specific parameter value. The derivative represents the rate of change at that point:
Order 1: Tangent vector (direction and speed)
Order 2: Curvature vector (how the tangent changes)
Order 3: Third-order derivative (supported maximum)
Parameters:
nurbscurve - A NURBS curve geometry.
parameter - Parameter value for evaluation (typically 0.0 to 1.0).
derivative_order - Order of derivative to compute (1, 2, or 3).
Returns a POINT geometry representing the derivative vector at the specified parameter.
Availability: 3.7.0 - requires SFCGAL >= 2.3.0.
Cette méthode nécessite le backend SFCGAL.
Cette fonction prend en charge la 3D et ne supprime pas l'indice z.
This example returns the tangent vector at the curve midpoint.
WITH nurbs AS (
SELECT ST_MakeNurbsCurve(2, 'LINESTRING(0 0, 5 10, 10 0)'::geometry) AS geom
)
SELECT CG_NurbsCurveDerivative(geom, 0.5, 1) FROM nurbs;
-- Get curvature at start of curve
WITH nurbs AS (
SELECT ST_MakeNurbsCurve(3, 'LINESTRING(0 0, 2 5, 5 5, 8 2, 10 0)'::geometry) AS geom
)
SELECT CG_NurbsCurveDerivative(geom, 0.0, 2) FROM nurbs;
-- Analyze tangent at multiple points
WITH nurbs AS (
SELECT ST_MakeNurbsCurve(2, 'LINESTRING(0 0, 5 10, 10 0)'::geometry) AS geom
)
SELECT
t.param,
CG_NurbsCurveDerivative(n.geom, t.param, 1) AS tangent
FROM nurbs n
CROSS JOIN (VALUES (0.0), (0.25), (0.5), (0.75), (1.0)) AS t(param);