trefoil_knot_param_eq.xml 6.2 KB

12345678
  1. <xml xmlns="http://blockscad.einsteinsworkshop.com"><version num="1.3.3"></version><color rgba="0,153,0"></color><block type="variables_set" id="794" x="-1917" y="-99"><field name="VAR">size</field><comment pinned="true" h="235" w="731">A trefoil knot can be described by these parametric equations:
  2. x(t) = sin(t) + 2sin(2t)
  3. y(t) = cos(t) - 2cos(2t)
  4. z(t) = -sin(3t)
  5. Each equation is represented by a module. Given an input value of t, they return values for x, y, and z.
  6. These x,y,z values are used to translate a "point", which here is a cube. Hulling the loop connects the points.
  7. To make the rainbow color, each cube is given a different hue in the chain hull loop. Since the hue can run between 0 and 100, and the loop runs between 0 and 360, i is divided by (360 / 100) = 3.6. You can get the rainbow loop twice through if you divide by 1.8.</comment><value name="VALUE"><block type="math_number" id="795"><field name="NUM">10</field></block></value></block><block type="procedures_defreturn" id="796" x="-1913" y="-53"><mutation statements="false"><arg name="t"></arg></mutation><field name="NAME">x</field><value name="RETURN"><block type="math_arithmetic" id="797"><field name="OP">ADD</field><value name="A"><block type="math_trig" id="798"><field name="OP">SIN</field><value name="NUM"><block type="variables_get" id="799"><field name="VAR">t</field></block></value></block></value><value name="B"><block type="math_arithmetic" id="800"><field name="OP">MULTIPLY</field><value name="A"><block type="math_number" id="801"><field name="NUM">2</field></block></value><value name="B"><block type="math_trig" id="802"><field name="OP">SIN</field><value name="NUM"><block type="math_arithmetic" id="803"><field name="OP">MULTIPLY</field><value name="A"><block type="math_number" id="804"><field name="NUM">2</field></block></value><value name="B"><block type="variables_get" id="805"><field name="VAR">t</field></block></value></block></value></block></value></block></value></block></value></block><block type="procedures_defreturn" id="806" x="-1915" y="38"><mutation statements="false"><arg name="t"></arg></mutation><field name="NAME">y</field><value name="RETURN"><block type="math_arithmetic" id="807"><field name="OP">MINUS</field><value name="A"><block type="math_trig" id="808"><field name="OP">COS</field><value name="NUM"><block type="variables_get" id="809"><field name="VAR">t</field></block></value></block></value><value name="B"><block type="math_arithmetic" id="810"><field name="OP">MULTIPLY</field><value name="A"><block type="math_number" id="811"><field name="NUM">2</field></block></value><value name="B"><block type="math_trig" id="812"><field name="OP">COS</field><value name="NUM"><block type="math_arithmetic" id="813"><field name="OP">MULTIPLY</field><value name="A"><block type="math_number" id="814"><field name="NUM">2</field></block></value><value name="B"><block type="variables_get" id="815"><field name="VAR">t</field></block></value></block></value></block></value></block></value></block></value></block><block type="procedures_defreturn" id="816" x="-1909" y="128"><mutation statements="false"><arg name="t"></arg></mutation><field name="NAME">z</field><value name="RETURN"><block type="math_single" id="817"><field name="OP">NEG</field><value name="NUM"><block type="math_trig" id="818"><field name="OP">SIN</field><value name="NUM"><block type="math_arithmetic" id="819"><field name="OP">MULTIPLY</field><value name="A"><block type="math_number" id="820"><field name="NUM">3</field></block></value><value name="B"><block type="variables_get" id="821"><field name="VAR">t</field></block></value></block></value></block></value></block></value></block><block type="scale" id="822" x="-1916" y="221"><value name="XVAL"><block type="variables_get" id="823"><field name="VAR">size</field></block></value><value name="YVAL"><block type="variables_get" id="824"><field name="VAR">size</field></block></value><value name="ZVAL"><block type="variables_get" id="825"><field name="VAR">size</field></block></value><statement name="A"><block type="controls_for" id="826"><field name="VAR">i</field><field name="HULL">TRUE</field><value name="FROM"><block type="math_number" id="827"><field name="NUM">0</field></block></value><value name="TO"><block type="math_number" id="828"><field name="NUM">365</field></block></value><value name="BY"><block type="math_number" id="829"><field name="NUM">15</field></block></value><statement name="DO"><block type="translate" id="830" inline="false"><value name="XVAL"><block type="procedures_callreturn" id="831" inline="true"><mutation name="x"><arg name="t"></arg></mutation><value name="ARG0"><block type="variables_get" id="832"><field name="VAR">i</field></block></value></block></value><value name="YVAL"><block type="procedures_callreturn" id="833" inline="true"><mutation name="y"><arg name="t"></arg></mutation><value name="ARG0"><block type="variables_get" id="834"><field name="VAR">i</field></block></value></block></value><value name="ZVAL"><block type="procedures_callreturn" id="835" inline="true"><mutation name="z"><arg name="t"></arg></mutation><value name="ARG0"><block type="variables_get" id="836"><field name="VAR">i</field></block></value></block></value><statement name="A"><block type="color_rgb" id="837"><mutation plus="0" isrgb="false"></mutation><field name="SCHEME">HSV</field><value name="RED"><block type="math_arithmetic" id="838"><field name="OP">DIVIDE</field><value name="A"><block type="variables_get" id="839"><field name="VAR">i</field></block></value><value name="B"><block type="math_number" id="840"><field name="NUM">3.6</field></block></value></block></value><value name="GREEN"><block type="math_number" id="841"><field name="NUM">100</field></block></value><value name="BLUE"><block type="math_number" id="842"><field name="NUM">100</field></block></value><statement name="A"><block type="cube" id="843"><field name="CENTERDROPDOWN">true</field><value name="XVAL"><block type="math_number" id="844"><field name="NUM">0.6</field></block></value><value name="YVAL"><block type="math_number" id="845"><field name="NUM">0.6</field></block></value><value name="ZVAL"><block type="math_number" id="846"><field name="NUM">0.6</field></block></value></block></statement></block></statement></block></statement></block></statement></block></xml>