Home Explore Blog CI



postgresql

7th chunk of `doc/src/sgml/cube.sgml`
de9d94491798208c30cbe62beb5c6cb91c8aad7ff3d239a80000000100000895
 Increases the size of the cube by the specified
        radius <parameter>r</parameter> in at least <parameter>n</parameter>
        dimensions.  If the radius is negative the cube is shrunk instead.
        All defined dimensions are changed by the
        radius <parameter>r</parameter>.  Lower-left coordinates are decreased
        by <parameter>r</parameter> and upper-right coordinates are increased
        by <parameter>r</parameter>.  If a lower-left coordinate is increased
        to more than the corresponding upper-right coordinate (this can only
        happen when <parameter>r</parameter> &lt; 0) than both coordinates are
        set to their average.  If <parameter>n</parameter> is greater than the
        number of defined dimensions and the cube is being enlarged
        (<parameter>r</parameter> &gt; 0), then extra dimensions are added to
        make <parameter>n</parameter> altogether; 0 is used as the initial
        value for the extra coordinates.  This function is useful for creating
        bounding boxes around a point for searching for nearby points.
       </para>
       <para>
        <literal>cube_enlarge('(1,2),(3,4)', 0.5, 3)</literal>
        <returnvalue>(0.5, 1.5, -0.5),(3.5, 4.5, 0.5)</returnvalue>
       </para></entry>
      </row>
     </tbody>
    </tgroup>
  </table>
 </sect2>

 <sect2 id="cube-defaults">
  <title>Defaults</title>

  <para>
   This union:
  </para>
<programlisting>
select cube_union('(0,5,2),(2,3,1)', '0');
cube_union
-------------------
(0, 0, 0),(2, 5, 2)
(1 row)
</programlisting>

   <para>
    does not contradict common sense, neither does the intersection:
   </para>

<programlisting>
select cube_inter('(0,-1),(1,1)', '(-2),(2)');
cube_inter
-------------
(0, 0),(1, 0)
(1 row)
</programlisting>

   <para>
    In all binary operations on differently-dimensioned cubes,
    the lower-dimensional one is assumed to be a Cartesian projection, i. e., having zeroes
    in place of coordinates omitted in the string representation. The above
    examples are equivalent to:
   </para>

<programlisting>
cube_union('(0,5,2),(2,3,1)','(0,0,0),(0,0,0)');
cube_inter('(0,-1),(1,1)','(-2,0),(2,0)');
</programlisting>

Title: Cube Enlargement and Default Behavior for Binary Operations
Summary
This section explains how to increase the size of a cube using the cube_enlarge function, which modifies the cube's dimensions by a specified radius. It also discusses the default behavior for binary operations on cubes with different dimensions, where the lower-dimensional cube is treated as a Cartesian projection with omitted coordinates assumed to be zero.