polarToCartesian

Chart
stable

Convert a polar coordinate (centre, radius, angle in radians) into a Cartesian `[x, y]` point. Uses the mathematical convention — zero at 3 o'clock, counter-clockwise — shifted to noon/clockwise for visual consistency with radar and pie charts.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

cx
required
number
X coordinate of the circle centre in SVG user units.
cy
required
number
Y coordinate of the circle centre in SVG user units.
radius
required
number
Distance from the centre to the point.
angle
required
number
Angle in radians using the mathematical convention (0 = 3 o'clock, counter-clockwise). Internally shifted by `-π/2` so that 0 = noon, clockwise, matching `arcPath`.

API

Return value

The value returned by this util.

A `[x, y]` tuple in SVG user units representing the Cartesian equivalent of the given polar coordinate.

Usage

Examples

Ready-to-paste usage snippets.

Position a label at the top of a circle

typescript