ruled.inc — backgrounds for scale modelling

a re-implementation of Friedrich Lohmüller's "Macros for a Squared Background", for the Persistence of Vision Raytracer, version 3.8 or later.

the aim was, initially, to select different colours and choose the number of (sub)divisions. another motivation was wanting to understand the late FL's elegant (lateral thinking!) method for creating the dividing lines. while I've achieved my aims, thinking about his color_map still gives me .. headaches. :-)

in the process of writing this include file, the primary macro was renamed to "Ruled()", and the interface changed to using a dictionary argument. the macro now returns a 'plane{}', optionally clipped, rather than a 'box{}'.

the reference page: Scale Modelling with POV-Ray.

note that if lines look broken, rendering at a high(er) resolution, and scaling down to the desired resolution, helps.

the interface

macro Ruled(dict)

the Ruled() macro takes a single 'dictionary' argument, and expands to ("returns") a 'plane{}' object, oriented, pigmented, and clipped, as per the given parameters.

from the list of recognised keys below only two are required, all others will be given "sensible" defaults where omitted.

.norm: <x,y,z>
determines the orientation of the plane, perpendicular to one of axes, and given in the usual 3-vector notation.
mandatory.
.offs: n.n
the plane's distance from the origin, a single float value; may be negative.
mandatory.
.divs: n
the number of sub-divisions per unit. the Lohmüller macro's "resolution" is fixed at ten. Ruled() defaults to the same value, however, from one to ten sub-divisions can be set.
.from: <col,row>
the lower bound for clipped_by{}, a 2-vector giving the start coordinate in the plane. the default is to clip a _very_ large area.
.to: <col,row>
the upper bound for clipped_by{}, a 2-vector giving the end coordinate in the plane; default as 'from'.
.bg: pigment
the background pigment, defaults to a light-ish gray. use "pigment {color rgbt 1}" for a transparent background.
.fg: n
the foreground/line colour. while Lohmüller's original code uses a hardwired colour in the pigment's color_map, this macro offers choice from the basic set below. the default foreground/line colour is blue.
  1. black
  2. red
  3. green
  4. blue
  5. cyan
  6. magenta
  7. yellow
  8. white
.dim: {0|1}
a boolean value which slightly reduces line brightness when true. default false.

example

the image shows a selection of sub-divisions, with different foregrounds and backgrounds. it sort of replicates FL's "squared background" image, on the reference page. the corresponding SDL code is listed below.

cf Lohmueller image squared background

#version 3.8;

global_settings {assumed_gamma 1}

light_source {<.5,.5,-1>*1e3 color rgb 1 parallel}

camera {
  location <4.5,4,-5>
  right x * (4/3)
  up y
  angle 80
  look_at <0,0,0>
}

merge {
  cylinder {<-4,0,0>, <3,0,0>, .035}
  cylinder {<0,-1,0>, <0,3,0>, .035}
  cylinder {<0,0,-4>, <0,0,3>, .035}
  cone {<3,0,0>, .08, <3.25,0,0>, 0}
  cone {<0,3,0>, .08, <0,3.25,0>, 0}
  cone {<0,0,3>, .08, <0,0,3.25>, 0}
  texture {pigment {checker color rgb <1,.839844,0>, color rgb <1,1,1>}}
}

#include "ruled.inc"

#declare xP = dictionary {
  .norm: <1,0,0>,
  .offs: -3,
  .divs: 4,
  .bg:   pigment {color rgb <.976562,.976562,.820312>},
  .fg:   1,
  .dim:  1,
  .from: <0,-3>,
  .to:   <3,3>
};

#declare yP = dictionary {
  .norm: <0,1,0>,
  .offs: 0,
  .divs: 5,
  .bg:   pigment {color rgb <.9375,.96875,1>},
  .fg:   2,
  .dim:  1,
  .from: <-3,-3>,
  .to:   <3,3>
};

#declare zP = dictionary {
  .norm: <0,0,1>,
  .offs: 3,
  .fg:   3,
  .dim:  1,
  .from: <-3,0>,
  .to:   <3,3>
};

Ruled(xP)
Ruled(yP)
Ruled(zP)