Interesting question.
My suggestion is to use a simplified circle (only 12 segments) and then calculate a delaunay triangulation on that. Here's a working example:
CREATE TABLE twelves AS
WITH points AS (
SELECT 1::int as id, ST_MakePoint(100,100) as geom
)
,dump AS (
SELECT id, (ST_DumpPoints(ST_Buffer(geom,50,3))).geom as geom
FROM points --insert your point table here
UNION ALL
SELECT id, geom FROM points --same here
)
SELECT id, (ST_Dump(ST_DelaunayTriangles(ST_Collect(geom),0, 0))).geom geom
FROM dump
GROUP BY id;
If you want to have a nicer (rounder) circle, you will have a lot more work to do but there may be interesting solutions for that as well.
[un-asked-for advice:] By the way, if this is for a visualisation, there might be more convenient client-sides way to do this.
EDIT:
Here's a more complex version that adds rounded triangles, at the expense of some speed.
WITH points AS (
SELECT 1::int as id, ST_MakePoint(100,100) as geom
)
,circle AS ( --first make a nice circle with a lot of segments
SELECT id, ST_Buffer(geom, 50,25) as geom FROM points
)
,dump AS ( --make the pie segments, but make them bigger than the nice circle
SELECT id, (ST_DumpPoints(ST_Buffer(geom,60,3))).geom as geom
FROM points --insert your point table here
UNION ALL
SELECT id, geom FROM points --same here
)
,triangles AS (
SELECT id, (ST_Dump(ST_DelaunayTriangles(ST_Collect(geom),0, 0))).geom geom
FROM dump
GROUP BY id
)
--now get the intersection between the nice circle and the segments
SELECT a.id, ST_Intersection(a.geom, b.geom) geom
FROM circle as a, triangles as b
WHERE a.id = b.id;
EDIT2:
Here's an even more complex example that gives the order of the triangles with a number
WITH points AS (
SELECT 1::int as id, ST_MakePoint(100,100) as geom
)
,circle AS ( --first make a nice circle with a lot of segments
SELECT id, ST_Buffer(geom, 50,25) as geom FROM points
)
,segments AS ( --create segments from a smaller circle so we can find out later wich triangle belongs to which segment
SELECT id, (pt).path path, ST_MakeLine(lag((pt).geom, 1, NULL) OVER (PARTITION BY id ORDER BY id, (pt).path), (pt).geom) AS geom
FROM (SELECT id, ST_DumpPoints(ST_Buffer(geom,40,3)) AS pt FROM points) as dumps
)
,dump AS ( --make the pie segments, but make them bigger than the nice circle
SELECT id, (ST_DumpPoints(ST_Buffer(geom,60,3))).geom as geom
FROM points --insert your point table here
UNION ALL
SELECT id, geom FROM points --same here
)
,triangles AS ( --triangles will have a random order
SELECT id, (ST_Dump(ST_DelaunayTriangles(ST_Collect(geom),0, 0))).geom geom
FROM dump
GROUP BY id
)
--now get the intersection between the nice circle and the segments, and add the ordernr of the triangle based on the segments we got earlier on
SELECT a.id, c.path[2]-1 path, ST_Intersection(a.geom, b.geom) geom
FROM circle as a, triangles as b
LEFT JOIN segments c ON ST_Intersects(b.geom,ST_Centroid(c.geom))
WHERE a.id = b.id
ORDER BY a.id, path;
(Thanks to Paul Ramsey for the excellent example of getting segments from a linestring: http://blog.cleverelephant.ca/2015/02/breaking-linestring-into-segments.html)