Skip to content

Latest commit

 

History

History
237 lines (183 loc) · 4.8 KB

damage.md

File metadata and controls

237 lines (183 loc) · 4.8 KB

Damage

Quickly generate randomized damage templates driven by seed.
see: example


The idea is that you generate a plate of randomized damage templates. And choose the ones you like best.

Blast

Generates damage template derived from a modified pinwheel.

parameters

  • seed: str
  • height: float
  • count: tuple[int,int]
  • x_jiggle: tuple[int,int] | int - can be tuple or int
  • y_jiggle: tuple[int,int] | int - can be tuple or int
  • ring_params: list[dict]
result = damage.blast(
    seed="test",
    height=10,
    count = (5,10),
    x_jiggle = (-2,2), 
    y_jiggle = 0,
    ring_params = [
        {"radius":(35,50), "start_angle":0}, 
        {"radius":25,"start_angle":30}
    ]
)


if given a height of 0 will return the wire instead.


Random Nudge Points

Utility function to randomize the x and y values of a list of points.

parameters

  • seed: str
  • points
  • x_jiggle: tuple[int,int] | int - can be tuple or int
  • y_jiggle: tuple[int,int] | int - can be tuple or int

Returns

Uneven Plane

Creates an uneven plane.

parameters

  • length: float
  • width: float
  • segments: int
  • height: float
  • min_height: float
  • step: float
  • peak_count: tuple[int,int] | int
  • seed: str | None
  • render_plate: bool
  • plate_height: float
import cadquery as cq
from cqterrain.damage import uneven_plane

u_plane_safe = uneven_plane(
    length=20, 
    width=25,
    height=4,
    #peak_count=(3,5),
    peak_count=5,

    segments=5,
    seed='test',
    render_plate=True,
    plate_height = 0.1
)

show_object(u_plane_safe)

Uneven Plane Grid Example

import cadquery as cq
from cqterrain.damage import uneven_plane

#grid of surfaces
seed='test_2'

def add_surface(loc:cq.Location) -> cq.Shape:
    u_plane_risky = uneven_plane(
        length = 60, 
        width = 35,
        height = 5,
        peak_count = (4,5),
        step = .5,
        #peak_count=5,
        segments = 5,
        seed = None,
        render_plate = True,
        plate_height = 0.1
    )
    return u_plane_risky.val().located(loc) #type:ignore

uneven_surface_example = (
    cq.Workplane("XY")
    .rarray(
        xSpacing = 70, 
        ySpacing = 40,
        xCount = 5, 
        yCount= 5, 
        center = True)
    .eachpoint(callback = add_surface)
)

show_object(uneven_surface_example)


Uneven Spline Plane

parameters

  • length: float
  • width: float
  • segments: int
  • height: float
  • min_height: float
  • step: float
  • peak_count: tuple[int,int]|int
  • seed: str|None
  • render_plate: bool
  • plate_height: float
import cadquery as cq
from cqterrain.damage import uneven_plane, uneven_spline_plane

u_plane_safe = uneven_spline_plane(
    length=20, 
    width=25,
    height=4,
    #peak_count=(3,5), - risky
    peak_count=5,

    segments=5,
    seed='test',
    render_plate=True,
    plate_height = 0.1
)

# show_object(u_plane_safe)

Uneven Spline Plane Grid Example

import cadquery as cq
from cqterrain.damage import uneven_spline_plane

#grid of surfaces
seed='test'

def add_surface(loc:cq.Location) -> cq.Shape:
    u_plane_risky = uneven_spline_plane(
        length = 90, 
        width = 90,
        height = 9,
        #peak_count = (4,5),
        peak_count=5,
        min_height = 2,
        step = 1,
        
        segments = 6,
        seed = None,
        render_plate = True,
        plate_height = 0.5
    )
    return u_plane_risky.val().located(loc) #type:ignore

uneven_surface_example = (
    cq.Workplane("XY")
    .rarray(
        xSpacing = 100, 
        ySpacing = 100,
        xCount = 3, 
        yCount= 3, 
        center = True)
    .eachpoint(callback = add_surface)
)

show_object(uneven_surface_example)