Thursday, June 26, 2008

Escher "Cubic Space"

It's always good to use the right tools. Someone was asking on the POV-Ray news group about adding edge effects to a scene, and I realized that a paint program was a much better tool, and that some simple macros could duplicate the scene in minutes. I also saw on TV a nice portable sawhorse that converts into a large stable workbench with the addition of a door or a sheet of plywood, and it struck home that I've spent at least twice as much time setting a simple foundation for the permanent work bench I'm building as building the bench itself. Oh the woes of gravel covered dirt floor garages! Floors are a definite "to do". Here's some macros for those POV inclined, they're the floor in a POV garage so to speak.
// a line of object starting at a location and repeating at an interval
#macro LineOf(Obj StartPos IncPos Num)
#local _COUNT = 0;
#local _CPOS = StartPos;
#while (_COUNT < Num)
object {Obj translate _CPOS}
#local _CPOS = _CPOS + IncPos;
#local _COUNT = _COUNT + 1;
#end
#end

// a ring of objects starting at a location and orbiting the origin by IncRot
#macro RingOf(Obj StartPos IncRot Num)
#local _COUNT = 0;
#local _ROT = <0,0,0>;
#while (_COUNT < Num)
object {Obj translate StartPos
rotate <_rot.x,0,0>
rotate <0,_rot.y,0>
rotate <0,0,_rot.z>}
#local _ROT = _ROT + IncRot;
#local _COUNT = _COUNT + 1;
#end
#end

// helix
#macro HelixOf(Obj StartPos IncRot IncPos Num)
#local _COUNT = 0;
#local _CPOS = StartPos;
#local _ROT = <0,0,0>;
#while (_COUNT < Num)
object {Obj
rotate <_rot.x,0,0>
rotate <0,_rot.y,0>
rotate <0,0,_rot.z>
translate _CPOS}
#local _ROT = _ROT + IncRot;
#local _CPOS = _CPOS + IncPos;
#local _COUNT = _COUNT + 1;
#end
#end

// a grid of object starting at a location and repeating at IncPos and IncPos2
#macro GridOf(Obj StartPos IncPos IncPos2 Num Num2)
#local _COUNT2 = 0;
#local _CPOS2 = StartPos;
#while (_COUNT2 < Num2)
#local _COUNT = 0;
#local _CPOS = _CPOS2;
#while (_COUNT < Num)
object {Obj translate _CPOS}
#local _CPOS = _CPOS + IncPos;
#local _COUNT = _COUNT + 1;
#end
#local _CPOS2 = _CPOS2 + IncPos2;
#local _COUNT2 = _COUNT2 + 1;
#end
#end

No comments: