Home Explore Blog CI



postgresql

6th chunk of `doc/src/sgml/cube.sgml`
bfc4330244aef3e1c618b2716ef2b1277e92c0ea137a977e0000000100000d23
 <para>
        Returns the distance between two cubes. If both
        cubes are points, this is the normal distance function.
       </para>
       <para>
        <literal>cube_distance('(1,2)', '(3,4)')</literal>
        <returnvalue>2.8284271247461903</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube_subset</function> ( <type>cube</type>, <type>integer[]</type> )
        <returnvalue>cube</returnvalue>
       </para>
       <para>
        Makes a new cube from an existing cube, using a list of
        dimension indexes from an array. Can be used to extract the endpoints
        of a single dimension, or to drop dimensions, or to reorder them as
        desired.
       </para>
       <para>
        <literal>cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[2])</literal>
        <returnvalue>(3),(7)</returnvalue>
       </para>
       <para>
        <literal>cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[3,2,1,1])</literal>
        <returnvalue>(5, 3, 1, 1),(8, 7, 6, 6)</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube_union</function> ( <type>cube</type>, <type>cube</type> )
        <returnvalue>cube</returnvalue>
       </para>
       <para>
        Produces the union of two cubes.
       </para>
       <para>
        <literal>cube_union('(1,2)', '(3,4)')</literal>
        <returnvalue>(1, 2),(3, 4)</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube_inter</function> ( <type>cube</type>, <type>cube</type> )
        <returnvalue>cube</returnvalue>
       </para>
       <para>
        Produces the intersection of two cubes.
       </para>
       <para>
        <literal>cube_inter('(1,2)', '(3,4)')</literal>
        <returnvalue>(3, 4),(1, 2)</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube_enlarge</function> ( <parameter>c</parameter> <type>cube</type>, <parameter>r</parameter> <type>double</type>, <parameter>n</parameter> <type>integer</type> )
        <returnvalue>cube</returnvalue>
       </para>
       <para>
        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

Title: Advanced Cube Functions for Union, Intersection, and Modification
Summary
This section describes advanced functions for working with cubes, including calculating the union and intersection of two cubes, enlarging or shrinking a cube by a specified radius, and creating a new cube by subset or reordering dimensions. These functions provide a range of tools for modifying and analyzing cubes, such as combining cubes, adjusting their size, and extracting specific dimensions.