<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="/pattern.xsl"?>
<pattern id="">
  <name>Transformer</name>
  <!-- The diagram is a graphic representation of the pattern.-->
  <diagram>
  <web>
    <img src="Diagram_Tran_sm.jpg" width="400" height="300" />
  </web>
   <latex>
    <img src="Diagram_Tran.jpg" width="400" height="300" />
	</latex>
  </diagram>
  <relatedPatterns>
    <relatedPattern ref="">
      <patternLink>A related pattern</patternLink>
    </relatedPattern>
  </relatedPatterns>
  <what>
    <paragraph>
      Change an object's form by translating and/or rotating its rigid
      components.
    </paragraph>
  </what>
  <when>
    <paragraph>
      In physics, a rigid body is an idealization of a solid body of
      finite size in which deformation is neglected. Although most
      architecture structures are, in essence, rigid bodies as a
      whole, most have mechanisms within them (think of a door
      hinge). Interest in larger scale mechanisms in increasing,
      though the most obvious examples are still to be found in
      stadium roofs <latex>\cite{aGoodRetractableStadiumRoof}</latex>.
      Use this pattern when you are making quick approximate models of
      the motion of an assembly of rigid bodies.
    </paragraph>
  </when>
  <why>
    <paragraph>
      Apart from such systems as tensioned membranes, bending members
      or inflatable structures, mechanisms are needed for movement in
      design. In such a structure, every components is a rigid body
      and links between components restrict feasible relative
      motion. Components can rotate and slide with respect to each
      other. Some parametric modeling systems provide <em>kinematic
      analysis</em> packages, which compute allowable states of
      mechanisms. Certainly use these when they are available, but
      understanding how to model simple mechanisms directly remains an
      important technique.
    </paragraph>
  </why>
  <how>
    <paragraph>
      The <patternName>Transformer</patternName> pattern has two basic
      features: rigid bodies maintain the same shapes and sizes during
      a transformation, and these bodies slide and/or rotate along a
      path or according to a rule. Understanding and codifying the
      rule is critical to modeling a mechanism.
    </paragraph>
    <paragraph>
      First the components must be rigid bodies.  Before
      creating the model, you should distinguish the rigid bodies from
      other parts in the models. While the body can be complex, it
      will typically be based on a <patternLink>Jig</patternLink>: a
      relatively small collection of simple geometric elements. Except
      for position, these must be indepdent of any parameter that
      drives the mechanism. In a model of a rigid body, make its
      <patternLink>Jig</patternLink> as simple as possible and then
      define all the detail solely in terms of the
      <patternLink>Jig</patternLink>.
    </paragraph>
    <paragraph>
      Secondly, the transformation is constrained by the
      components. After the first step, the rigid body has one or
      several geometries as the anchor. Making this anchor
      transformable is the key. Some properties of this anchor could
      be variables such as the parameter along the curve, the number
      of the panels or the angle of rotation. Some properties could
      also be driven by independent <patternLink>Controllers</patternLink>.
    </paragraph>
  </how>
  <samples>
    <sample id="">
      <name>Scissor Arm</name>
      <when>
	<paragraph> 
	  Model a scissor mechanism, that is, an arm whose horizontal
	  extension is controlled by its handle's vertical movement
	  along a line.
	</paragraph>
      <diagram>
      <img src="Img_Tran_ExtensionArm.jpg" width="200" height="250" />
      </diagram>
      </when>
      <how>
	<paragraph>
	  In this model, lines model the scissor arm rigid bodies. All
	  lines are of the same length. The anchor comprises a fixed
	  line in space and one of its endpoints.
	</paragraph>
	<paragraph>
	  The next step is to define the anchor. There are several
	  parts available to be used as the anchor - the start point
	  or the endpoint of frames. In this sample file, you take the
	  two frames crossing point as the anchor. This series of
	  points slide on both X and Y directions, anchoring a middle
	  line path between the two controlling points and a
	  changeable distance between each other. Since all the frames
	  are of the same length, after calculating the first anchor
	  point, it is easy to locate all the rest anchors. Finally,
	  you apply crossing frames on each anchor points and get the
	  extendible frames.
	</paragraph>
      </how>
      <a href="Samples/Tran_Arm/Tran_Arm.gct" >Download Tran_Arm.gct</a>
      <animation src="Samples/Tran_Arm/Animation_Arm.swf"/>
    </sample>
    
    <sample id="">
      <name>Square</name>
      <when><paragraph> Use polygons with right angles as a shutter.
      </paragraph>
      </when>
      <how>
	<paragraph>
	  Four polygons, each having one right angle, can be arranged in spiral pattern around a square.
	</paragraph>
	<diagram>
	  <img src="SpiralSquare.jpg" width="350"/>
	</diagram>
	<paragraph>
	  Changing the size of the square moves the polygons such that
	  they model a shutter. Polygon sides appear to slide along
	  each other. A parametric model for this is almost trivial. 
	</paragraph>
      </how>
      <a href="Samples/Tran_Square/Tran_Square_Simple.gct" >Download Tran_Square_Simple.gct</a>
      <more>
	<paragraph>
	  Rotary action of the shutter, and perhaps more geometric
	  insight, can be had by realizing the that shutter corners
	  move along arcs of circles with centres at <math
	  latex="90\circ">90 degree</math> intervals on the
	  circumference of a circle of the same size.
	</paragraph>
	<diagram>
	  <img src="GuideCircles.jpg" width="350"/>
	</diagram>
	<paragraph>
	  The lines defining the right-angle sides start at the
	  shutter corners and pass through the guide circle
	  intersections.
	</paragraph>
      </more>
      <a href="Samples/Tran_Square/Tran_Square.gct" >Download Tran_Square.gct</a>
      <animation src="Samples/Tran_Square/Animation_Square.swf"/>
    </sample>

    <sample id="">
      <name>Shades</name>
      <when>
	<paragraph> 
	  Model vertical and horizontal shades covering a window.
	</paragraph>
      </when>
      <how>
	<paragraph>
	  Sliding blinds are a common window covering. Overlapping horizontal
	  and vertical blinds open a view slowly at first, then rapidly as they
	  approach their full travel. Of course, they require double the
	  material of a single blind system. Modeling such blinds is
	  straigtforward, except for one trick: coordinating smooth movement
	  across all of the blinds. The trick is that the points controlling the
	  location of the blinds are parametric points on the window diagonal
	  and are themselves controlled by the <math
	  latex="slidePoint">slidePoint</math>, a single parametric point on any
	  curve, anywhere in the model. Here is how it works.
	</paragraph>
      </how>
      <diagram>
	<img src="Img_SlidePoint.jpg" width="350"/>
      </diagram>
	<paragraph>
	  <a href="Samples/Tran_HVShades/Tran_HVShades_Feature.gct" >Download
	  Tran_HVShades_Feature.gct</a>
	</paragraph>
	<paragraph>
	  <a href="Samples/Tran_HVShades/Tran_HVShades.gct" >Download
	  Tran_HVShades.gct</a>
	</paragraph>
      <animation src="Samples/Tran_HVShades/Animation_HVShades.swf"/>
    </sample>
    
    <sample id="">
      <name>Differential</name>
      <when>
	<paragraph> 
	  A mechanical differential mechanism links rotation through three
	  axes. Using coordinate systems multiple axes can be linked. Of course,
	  this is a representational device only---actually constructing such a
	  system could be a challenge.
      </paragraph>
      </when>
      <how>
	<paragraph>
	  In this sample, a vertical axes is linked to multiple axes at
	  <math latex="90\circ">90 degrees</math> to the vertical axis. The
	  horizontal rotations are a function of the vertical rotation. The
	  modeling process is straightforward. To clarify the geometric structure, each successive
	  coordinate system is displaced by a small amount. Reducing this amount
	  to zero brings all objects to a central point.
	<paragraph>
	</paragraph>
	  The <math latex="Z">Z</math>-axis of the <math
	  latex="differentialCS">differentialCS</math> coordinate system defines
	  the vertical axis.
	<paragraph>
	</paragraph>
	  The origin of the <math latex="inputCS">inputCS</math> coordinate
	  system  coincides with <math
	  latex="differentialCS">differentialCS</math> and is rotated by <math
	  latex="input\circe">input degrees</math> about the vertical axis.
	<paragraph>
	</paragraph>
	  Place <math latex="count">count</math> coordinate systems (call these
	  <math latex="outputBase">outputBase</math>) on the <math
	  latex="XY">XY</math>-plane of the <math
	  latex="inputCS">inputCS</math>, each rotated about the vertical axis
	  by <math latex="360/count\circ">360/count degrees</math> from each
	  other.
	<paragraph>
	</paragraph>
	  Place an <math
	  latex="outputCS">outputCS</math> coordinate system, coincident with each
	  <math latex="outputBase">outputBase</math>, with <math
	  latex="Z">Z</math>-axes aligned with the corresponding <math
	  latex="outputBase">outputBase</math> coordinate systems. Bind the rotation around the
	  <math latex="Z">Z</math>-axis of each outputCS to a function (the
	  simplest is <math latex="\afFuncF{F}{x}=x">f(x)=x</math>) of <math
	  latex="input/circ">input degrees</math>.
	<paragraph>
	</paragraph>
	  Attach an object to each <math latex="outputCS">outputCS</math>. The
	  objects will rotate as the input rotation changes. 
	<paragraph>
	</paragraph>
	  In this sample the rigid bodies are circle segments, governing by
	  parameters for their subtending angle and radius. When the subtending
	  angle is <math latex="180/circ">180 degrees</math>, and <math
	  latex="input">input</math> is <math latex="0\circ">0 degrees</math>,
	  the overall form approximates a sphere. When <math
	  latex="input">input</math> is <math latex="90\circ">90 degrees</math>,
	  all objects lie in the <math latex="XY">XY</math>-plane.
	</paragraph>
      </how>
      <a href="Samples/Tran_Differential/Tran_Differential.gct" >Download Tran_Differential.gct</a>
      <animation src="Samples/Tran_Differential/Animation_Differential.swf"/>
    </sample>
    <web>
    <sample id="">
      <name>Shutters</name>
      <when>
	<paragraph> 
	  Simulate the shutters' movement along a free curve.  
	</paragraph>
	<diagram>
	  <img src="Img_Tran_Shutters.jpg" width="350"/>
	</diagram>
      </when>
      <how>
	<paragraph>
	  <latex>\NtS{The function in this script doesn't work and is
	  very long. Debug and simplify.}</latex> In the image,
	  Mercedes Benz ML320 uses shutters to cover its curved
	  sunroof. It is easy to draw the shutters of a planar door,
	  but tricky to deal with a curved surface. No need for
	  reticence, the shutters are rigid bodies. Each piece of
	  shutters not only slide along the curve, but also cover on
	  the previous piece so that there is no leaking.
	</paragraph>
	<diagram><img src="Img_Tran_ShuttersDiagram.jpg" width="500" /></diagram>
	<paragraph>
	  In this model, the most interesting part is not the anchor
	  of shutter, but the rest part of the shutter. One side of
	  the shutter slides along the curve. Each shutter's anchor is located
	  and indentified through its index number. For the rest
	  part of the shutter, to cover the previous piece property,
	  there are two conditions: <em>covering on</em> the previous
	  piece (A) or <em>snaping</em> to previous piece's starting
	  points and <em>sticking</em> out (B). How to distinguish
	  these two conditions? You can draw two directions (direction
	  1 from the current shutter's start point to previous
	  shutter's start point, and direction 2 from the current
	  start point to the previous's endpoint) and get their cross
	  product direction. Wether or not this direction is positive
	  determine which condition it belongs to. Through using
	  "if...else" statement in the script, you can make your
	  shutters responsive to the different conditions along the
	  free curve.
	</paragraph>
      </how>
      <a href="Samples/Tran_Shutters/Tran_Shutters.gct" >Download Tran_Shutters.gct</a> 
      <animation src="Samples/Tran_Shutters/Animation_Shutters.swf"/>
    </sample>
    </web>
      </samples>
</pattern>

