Created
June 18, 2014 09:32
-
-
Save ToJans/473ce0432c4ae879639d to your computer and use it in GitHub Desktop.
I think it's time for a functor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type BuildingBlocks = { | |
beam: BuildingBlock | |
wall: BuildingBlock | |
roof: BuildingBlock | |
floor: BuildingBlock | |
ground: BuildingBlock | |
outsideFloor: BuildingBlock | |
flatBeam: BuildingBlock | |
pilar: BuildingBlock | |
blackPilar: BuildingBlock | |
} with | |
static member unit = | |
let beamScale = {x=0.060M;y = 0.060M;z = 0.050M} |> SV | |
{ | |
beam = (BuildingBlock.unit ShinyStuff) * beamScale | |
wall = (BuildingBlock.unit Brick)* (S 5.000M) | |
roof = (BuildingBlock.unit ShinyStuff) * (S 0.400M) | |
floor = (BuildingBlock.unit Floor) * (S 0.050M) | |
outsideFloor = (BuildingBlock.unit ShinyStuff) * (S 0.070M) | |
ground = (BuildingBlock.unit Ground) * (S 0.050M) | |
flatBeam = (BuildingBlock.unit Black) * beamScale * (SZ 0.001M) | |
pilar = (BuildingBlock.unit ShinyStuff) * (S 0.075M) | |
blackPilar = (BuildingBlock.unit Black) * (S 0.075M) | |
} | |
static member (*) (left, right) = | |
{ | |
beam = left.beam * right | |
wall = left.wall * right | |
roof = left.roof * right | |
floor = left.floor * right | |
outsideFloor = left.outsideFloor * right | |
ground = left.ground * right | |
flatBeam = left.flatBeam * right | |
pilar = left.pilar * right | |
blackPilar = left.blackPilar * right | |
} | |
and BuildingBlock = {size: Vector3D;material: Material} with | |
static member unit material:BuildingBlock = {size = Vector3D.unit;material=material} | |
member x.with_a_width_of width = CubeGeometry ({x.size with x = width},x.material) | |
member x.with_a_height_of height = CubeGeometry ({x.size with y = height},x.material) | |
member x.with_a_depth_of depth = CubeGeometry ({x.size with z = depth},x.material) | |
member x.with_a_width_and_depth_of width depth= CubeGeometry ({x.size with x = width;z=depth},x.material) | |
member x.with_a_width_and_height_of width height= CubeGeometry ({x.size with x = width;y=height},x.material) | |
member x.with_a_height_and_depth_of height depth= CubeGeometry ({x.size with y = height;z=depth},x.material) | |
static member (*)(left:BuildingBlock,right:Scale):BuildingBlock = | |
{left with size = left.size * right} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment