Skip to content

Instantly share code, notes, and snippets.

@ToJans
ToJans / auch.fs
Last active August 29, 2015 13:58
Here's some of the code causing the headache
// coords are a list of Vector3D
// polygons are a sequence of triangles
// triangles are a list of 3 vertices
// vertices are a Vector3D
let triangle a b c = [a;b;c]
let coordsToPolygon coords =
let fst = Seq.head coords
let triangleF = function
@ToJans
ToJans / example.pov
Created April 4, 2014 12:40
Disappointing render results with POVRAY
#include "colors.inc"
#include "textures.inc"
global_settings {
assumed_gamma 1.0
radiosity {
brightness 2.2
count 300
error_bound 0.15
gray_threshold 0.0
@ToJans
ToJans / DSL.fs
Last active August 29, 2015 13:58
My DSL is slowly getting there...
let frame_old (size:Vector3D) =
let beamThickness = VerandaOpts.unit.beamUnit.z
let horizontalGeometry = CubeGeometry <| Vector3D.fromDecimal (size.x-beamThickness*2M) beamThickness size.z
let horizontalObject = Object3D.mesh horizontalGeometry ShinyStuff
let width = size.y - beamThickness |> DY
let topBeam = horizontalObject + width.half
let bottomBeam = horizontalObject - width.half
@ToJans
ToJans / new.fs
Last active August 29, 2015 13:58
Still optimizing my 3D construction DSL
let frame width height =
let context = Builder.zero
let horizontalBeam = a_beam.with_a_width_of ( width )
let verticalBeam = a_beam.with_a_height_of ( height - horizontalBeam.height * 2M )
let topBeam = context.add a horizontalBeam anchoring its TopLeftFront on the TopLeftFront context.boundingBox
let leftBeam = context.add a verticalBeam anchoring its TopLeftFront on the BottomLeftFront topBeam.boundingBox
let rightBeam = context.add a verticalBeam anchoring its TopRightFront on the BottomRightFront topBeam.boundingBox
let bottomBeam = context.add a horizontalBeam anchoring its BottomLeftFront on the BottomLeftFront leftBeam.boundingBox
$el.find("input[type=checkbox]").change(function () {
var checked = $(this).is(":checked");
var $parent = $($(this).parent());
$parent.find("input[type=checkbox]").each(function () {
if (checked) {
$(this).attr("checked", "checked");
}
else {
$(this).removeAttr("checked");
}
var specification =
TSql.Projection().
When<PortfolioAdded>(@event =>
TSql.NonQuery(
"INSERT INTO [Portfolio] (Id, Name) VALUES ({0}, {1})",
TSql.Int(@event.Id), TSql.NVarChar(@event.Name, 40)
).
When<PortfolioRemoved>(@event =>
TSql.NonQuery(
"DELETE FROM [Portfolio] WHERE Id = {0}",
@ToJans
ToJans / new.fsx
Last active August 29, 2015 14:01
let getSupportingWalls veranda =
let boundingBox = {size=Vector3D.zero;center = {x=0M;y=0M;z= -veranda.buildingBlocks.wall.size.depth/2M}}
let walls = veranda.walls
let bricks = veranda.buildingBlocks.wall
let context = Builder.zero
let backWallBlock = bricks.with_a_width_and_height_of walls.middle walls.height
@ToJans
ToJans / BuildingBlocks.fs
Created June 18, 2014 09:32
I think it's time for a functor
type BuildingBlocks = {
beam: BuildingBlock
wall: BuildingBlock
roof: BuildingBlock
floor: BuildingBlock
ground: BuildingBlock
outsideFloor: BuildingBlock
flatBeam: BuildingBlock
pilar: BuildingBlock
blackPilar: BuildingBlock
@ToJans
ToJans / fzip.fs
Last active August 29, 2015 14:02
Does something like "fzip" even exist? Or did I just invent a wacko name to do this stuff?
open System.Runtime.Serialization
[<DataContract>]
type Vector3D = {
[<DataMember>] x: decimal
[<DataMember>] y: decimal
[<DataMember>] z: decimal
} with
member this.width = this.x
member this.height = this.y
@ToJans
ToJans / Fpexplained2.cs
Last active August 29, 2015 14:02
This is a C# implementation showing what functors, applicatives and monads look like.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
namespace FPExplainedV2
{
// another implementation to test category theory; this time I implement a list...
public class FList<TObject>