cqmore/polyhedron.py
def dodecahedron(radius: float, detail: int = 0) -> Polyhedron:
    '''
    Create a dodecahedron.

    ## Parameters

    - `radius`: radius of the dodecahedron.
    - `detail`: setting this to a value greater than 0 adds vertices making it no longer a dodecahedron.

    ## Examples 

        from cqmore.polyhedron import dodecahedron
        from cqmore import Workplane

        radius = 1
        polyhedra = Workplane()
        for detail in range(5):
            polyhedra.add(
                Workplane()
                    .polyhedron(*dodecahedron(radius, detail))
                    .translate((2 * radius * detail, 0, 0))
            )

    '''

    t = (1 + 5 ** 0.5) / 2
    r = 1 / t
    vectors = (
        # (±1, ±1, ±1)
        Vector(-1, -1, -1), Vector(-1, -1, 1),
        Vector(-1, 1, -1), Vector(-1, 1, 1),
        Vector(1, -1, -1), Vector(1, -1, 1),
        Vector(1, 1, -1), Vector(1, 1, 1),

        # (0, ±1/φ, ±φ)
        Vector(0, -r, -t), Vector(0, -r, t),
        Vector(0, r, -t), Vector(0, r, t),

        # (±1/φ, ±φ, 0)
        Vector(-r, -t, 0), Vector(-r, t, 0),
        Vector(r, -t, 0), Vector(r, t, 0),

        # (±φ, 0, ±1/φ)
        Vector(-t, 0, -r), Vector(t, 0, -r),
        Vector(-t, 0, r), Vector(t, 0, r)
    )
    faces = (
        (3, 11, 7), (3, 7, 15), (3, 15, 13),
        (7, 19, 17), (7, 17, 6), (7, 6, 15),
        (17, 4, 8), (17, 8, 10), (17, 10, 6),
        (8, 0, 16), (8, 16, 2), (8, 2, 10),
        (0, 12, 1), (0, 1, 18), (0, 18, 16),
        (6, 10, 2), (6, 2, 13), (6, 13, 15),
        (2, 16, 18), (2, 18, 3), (2, 3, 13),
        (18, 1, 9), (18, 9, 11), (18, 11, 3),
        (4, 14, 12), (4, 12, 0), (4, 0, 8),
        (11, 9, 5), (11, 5, 19), (11, 19, 7),
        (19, 5, 14), (19, 14, 4), (19, 4, 17),
        (1, 12, 14), (1, 14, 5), (1, 5, 9)
    )
    return _divide_project(vectors, faces, radius, detail)

    Create a dodecahedron.

    ## Parameters

    - `radius`: radius of the dodecahedron.
    - `detail`: setting this to a value greater than 0 adds vertices making it no longer a dodecahedron.

    ## Examples 

        from cqmore.polyhedron import dodecahedron
        from cqmore import Workplane

        radius = 1
        polyhedra = Workplane()
        for detail in range(5):
            polyhedra.add(
                Workplane()
                    .polyhedron(*dodecahedron(radius, detail))
                    .translate((2 * radius * detail, 0, 0))
            )

    
Create a dodecahedron.
Parameters

`radius`: radius of the dodecahedron.
`detail`: setting this to a value greater than 0 adds vertices making it no longer a dodecahedron.

Examples

from cqmore.polyhedron import dodecahedron
from cqmore import Workplane


Create a dodecahedron . Parameters ` radius ` : radius of the dodecahedron . ` detail ` : setting this to a value greater than 0 adds vertices making it no longer a dodecahedron . Examples from cqmore . polyhedron import dodecahedron from cqmore import Workplane
def dodecahedron(radius: float, detail: int = 0) -> Polyhedron:
    t = (1 + 5 ** 0.5) / 2
    r = 1 / t
    vectors = (
        Vector(-1, -1, -1), Vector(-1, -1, 1),
        Vector(-1, 1, -1), Vector(-1, 1, 1),
        Vector(1, -1, -1), Vector(1, -1, 1),
        Vector(1, 1, -1), Vector(1, 1, 1),
        Vector(0, -r, -t), Vector(0, -r, t),
        Vector(0, r, -t), Vector(0, r, t),
        Vector(-r, -t, 0), Vector(-r, t, 0),
        Vector(r, -t, 0), Vector(r, t, 0),
        Vector(-t, 0, -r), Vector(t, 0, -r),
        Vector(-t, 0, r), Vector(t, 0, r)
    )
    faces = (
        (3, 11, 7), (3, 7, 15), (3, 15, 13),
        (7, 19, 17), (7, 17, 6), (7, 6, 15),
        (17, 4, 8), (17, 8, 10), (17, 10, 6),
        (8, 0, 16), (8, 16, 2), (8, 2, 10),
        (0, 12, 1), (0, 1, 18), (0, 18, 16),
        (6, 10, 2), (6, 2, 13), (6, 13, 15),
        (2, 16, 18), (2, 18, 3), (2, 3, 13),
        (18, 1, 9), (18, 9, 11), (18, 11, 3),
        (4, 14, 12), (4, 12, 0), (4, 0, 8),
        (11, 9, 5), (11, 5, 19), (11, 19, 7),
        (19, 5, 14), (19, 14, 4), (19, 4, 17),
        (1, 12, 14), (1, 14, 5), (1, 5, 9)
    )
    return _divide_project(vectors, faces, radius, detail)
def dodecahedron ( radius : float , detail : int = 0 ) -> Polyhedron : t = ( 1 + 5 ** 0.5 ) / 2 r = 1 / t vectors = ( Vector ( - 1 , - 1 , - 1 ) , Vector ( - 1 , - 1 , 1 ) , Vector ( - 1 , 1 , - 1 ) , Vector ( - 1 , 1 , 1 ) , Vector ( 1 , - 1 , - 1 ) , Vector ( 1 , - 1 , 1 ) , Vector ( 1 , 1 , - 1 ) , Vector ( 1 , 1 , 1 ) , Vector ( 0 , - r , - t ) , Vector ( 0 , - r , t ) , Vector ( 0 , r , - t ) , Vector ( 0 , r , t ) , Vector ( - r , - t , 0 ) , Vector ( - r , t , 0 ) , Vector ( r , - t , 0 ) , Vector ( r , t , 0 ) , Vector ( - t , 0 , - r ) , Vector ( t , 0 , - r ) , Vector ( - t , 0 , r ) , Vector ( t , 0 , r ) ) faces = ( ( 3 , 11 , 7 ) , ( 3 , 7 , 15 ) , ( 3 , 15 , 13 ) , ( 7 , 19 , 17 ) , ( 7 , 17 , 6 ) , ( 7 , 6 , 15 ) , ( 17 , 4 , 8 ) , ( 17 , 8 , 10 ) , ( 17 , 10 , 6 ) , ( 8 , 0 , 16 ) , ( 8 , 16 , 2 ) , ( 8 , 2 , 10 ) , ( 0 , 12 , 1 ) , ( 0 , 1 , 18 ) , ( 0 , 18 , 16 ) , ( 6 , 10 , 2 ) , ( 6 , 2 , 13 ) , ( 6 , 13 , 15 ) , ( 2 , 16 , 18 ) , ( 2 , 18 , 3 ) , ( 2 , 3 , 13 ) , ( 18 , 1 , 9 ) , ( 18 , 9 , 11 ) , ( 18 , 11 , 3 ) , ( 4 , 14 , 12 ) , ( 4 , 12 , 0 ) , ( 4 , 0 , 8 ) , ( 11 , 9 , 5 ) , ( 11 , 5 , 19 ) , ( 11 , 19 , 7 ) , ( 19 , 5 , 14 ) , ( 19 , 14 , 4 ) , ( 19 , 4 , 17 ) , ( 1 , 12 , 14 ) , ( 1 , 14 , 5 ) , ( 1 , 5 , 9 ) ) return _divide_project ( vectors , faces , radius , detail )
Create a dodecahedron.
Create a dodecahedron .
'''
    Create a dodecahedron.

    ## Parameters

    - `radius`: radius of the dodecahedron.
    - `detail`: setting this to a value greater than 0 adds vertices making it no longer a dodecahedron.

    ## Examples 

        from cqmore.polyhedron import dodecahedron
        from cqmore import Workplane

        radius = 1
        polyhedra = Workplane()
        for detail in range(5):
            polyhedra.add(
                Workplane()
                    .polyhedron(*dodecahedron(radius, detail))
                    .translate((2 * radius * detail, 0, 0))
            )

    ''' # (±1, ±1, ±1) # (0, ±1/φ, ±φ) # (±1/φ, ±φ, 0) # (±φ, 0, ±1/φ)
radius
float
detail
int