position relative to other
187192
public static <T extends IPositioned & ISized, U extends IPositioned & ISized> IPosition leftOf(ISized owner, U other, int spacing)
	{
		return of(Positions.leftOf(owner, other, spacing), middleAlignedTo(owner, other, 0));
	}
1205566
def inside(self, other):
        
        return ( self.left >= other.left and
                 self.right <= other.right and
                 self.top <= other.top and
                 self.bottom >= other.bottom)
443918
def get_position(self):
        """"""
        rect = _Rect()
        GetWindowRect(self._hwnd, ctypes.pointer(rect))
        return rect.left, rect.top, rect.right, rect.bottom
244871
def move_towards(self, other, beta, alpha):
        """"""
        self.position += beta * (other.position - self.position)
        self.position += alpha * (np.random.uniform(-0.5, 0.5, len(self.position)))
        self.position = np.minimum(self.position, [b[1] for b in self.bounds])
        self.position = np.maximum(self.position, [b[0] for b in self.bounds])
1297675
def handle_relative(self, event):
        """"""
        delta_x, delta_y, delta_z = self._get_deltas(event)
        if delta_x:
            self.events.append(
                self.emulate_rel(0x00,
                                 delta_x,
                                 self.timeval))
        if delta_y:
            self.events.append(
                self.emulate_rel(0x01,
                                 delta_y,
                                 self.timeval))
        if delta_z:
            self.events.append(
                self.emulate_rel(0x02,
                                 delta_z,
                                 self.timeval))
602644
def set_position(self, x, y, width, height):
        """"""
        SetWindowPos(self._hwnd, None, x, y, width, height, ctypes.c_uint(0))
635870
function (hostEl, targetEl, positionStr, appendToBody) {

        var positionStrParts = positionStr.split('-');
        var pos0 = positionStrParts[0], pos1 = positionStrParts[1] || 'center';

        var hostElPos,
          targetElWidth,
          targetElHeight,
          targetElPos;

        hostElPos = appendToBody ? this.offset(hostEl) : this.position(hostEl);

        targetElWidth = targetEl.prop('offsetWidth');
        targetElHeight = targetEl.prop('offsetHeight');

        var shiftWidth = {
          center: function () {
            return hostElPos.left + hostElPos.width / 2 - targetElWidth / 2;
          },
          left: function () {
            return hostElPos.left;
          },
          right: function () {
            return hostElPos.left + hostElPos.width;
          }
        };

        var shiftHeight = {
          center: function () {
            return hostElPos.top + hostElPos.height / 2 - targetElHeight / 2;
          },
          top: function () {
            return hostElPos.top;
          },
          bottom: function () {
            return hostElPos.top + hostElPos.height;
          }
        };

        switch (pos0) {
          case 'right':
            targetElPos = {
              top: shiftHeight[pos1](),
              left: shiftWidth[pos0]()
            };
            break;
          case 'left':
            targetElPos = {
              top: shiftHeight[pos1](),
              left: hostElPos.left - targetElWidth
            };
            break;
          case 'bottom':
            targetElPos = {
              top: shiftHeight[pos0](),
              left: shiftWidth[pos1]()
            };
            break;
          default:
            targetElPos = {
              top: hostElPos.top - targetElHeight,
              left: shiftWidth[pos1]()
            };
            break;
        }

        return targetElPos;
      }
847779
public static void orthoM(float[] m, int mOffset,
        float left, float right, float bottom, float top,
        float near, float far) {
        if (left == right) {
            throw new IllegalArgumentException("left == right");
        }
        if (bottom == top) {
            throw new IllegalArgumentException("bottom == top");
        }
        if (near == far) {
            throw new IllegalArgumentException("near == far");
        }

        final float r_width  = 1.0f / (right - left);
        final float r_height = 1.0f / (top - bottom);
        final float r_depth  = 1.0f / (far - near);
        final float x =  2.0f * (r_width);
        final float y =  2.0f * (r_height);
        final float z = -2.0f * (r_depth);
        final float tx = -(right + left) * r_width;
        final float ty = -(top + bottom) * r_height;
        final float tz = -(far + near) * r_depth;
        m[mOffset + 0] = x;
        m[mOffset + 5] = y;
        m[mOffset +10] = z;
        m[mOffset +12] = tx;
        m[mOffset +13] = ty;
        m[mOffset +14] = tz;
        m[mOffset +15] = 1.0f;
        m[mOffset + 1] = 0.0f;
        m[mOffset + 2] = 0.0f;
        m[mOffset + 3] = 0.0f;
        m[mOffset + 4] = 0.0f;
        m[mOffset + 6] = 0.0f;
        m[mOffset + 7] = 0.0f;
        m[mOffset + 8] = 0.0f;
        m[mOffset + 9] = 0.0f;
        m[mOffset + 11] = 0.0f;
    }
1247191
def pt_relative(pt=(0.0, 0.0), shift=[0.0, 0.0], angle=[0.0]):
    '''
    '''
    assert isinstance(pt, tuple)
    l_pt = len(pt)
    assert l_pt > 1
    for i in pt:
        assert isinstance(i, float)
    assert isinstance(shift, list)
    l_sh = len(shift)
    assert l_sh == l_pt
    for i in shift:
        assert isinstance(i, float)
    assert isinstance(angle, list)
    l_angle = len(angle)
    assert l_angle == l_pt-1
    for i in angle:
        assert isinstance(i, float)
        assert abs(i) <= 2*pi

    return pt_rotate(pt_shift(pt, shift), angle, pt)
1158990
function(items) {
            var hasRelativePositioning = hasNumberProperty(items, 'relativePosition');

            for(var i = 0; i < items.length; i++) {
                if(i == items.length - 1)
                    items[i].diffWithNextRelativePos = undefined;
                else
                    items[i].diffWithNextRelativePos = items[i + 1].relativePosition - items[i].relativePosition;
            }
        }
770438
def __set_position(self):
        

        rectangle = hasattr(self.parent(), "viewport") and self.parent().viewport().rect() or self.parent().rect()
        if not rectangle:
            return

        self.adjustSize()

        if self.__anchor == 0:
            point_x = rectangle.width() / 2 - self.width() / 2
            point_y = self.__vertical_padding
        elif self.__anchor == 1:
            point_x = rectangle.width() - self.width() - self.__horizontal_padding
            point_y = self.__vertical_padding
        elif self.__anchor == 2:
            point_x = rectangle.width() - self.width() - self.__horizontal_padding
            point_y = rectangle.height() / 2 - self.height() / 2
        elif self.__anchor == 3:
            point_x = rectangle.width() - self.width() - self.__horizontal_padding
            point_y = rectangle.height() - self.height() - self.__vertical_padding
        elif self.__anchor == 4:
            point_x = rectangle.width() / 2 - self.width() / 2
            point_y = rectangle.height() - self.height() - self.__vertical_padding
        elif self.__anchor == 5:
            point_x = self.__horizontal_padding
            point_y = rectangle.height() - self.height() - self.__vertical_padding
        elif self.__anchor == 6:
            point_x = self.__horizontal_padding
            point_y = rectangle.height() / 2 - self.height() / 2
        elif self.__anchor == 7:
            point_x = self.__horizontal_padding
            point_y = self.__vertical_padding
        elif self.__anchor == 8:
            point_x = rectangle.width() / 2 - self.width() / 2
            point_y = rectangle.height() / 2 - self.height() / 2

        self.setGeometry(point_x + self.__horizontal_offset, point_y +
                                                             self.__vertical_offset, self.width(), self.height())
1178627
def position(self):
        """"""
        line, col = self._position(self.chunkOffset)
        return (line + 1, col)
1029108
def distance(self, other):
        ''''''
        if self & other:
            return 0
        return numpy.max([other.left-self.right, self.left-other.right])
389326
function relativePosition(dim, val) {
    var ele = this[0];
    var cy = this.cy();
    var ppos = plainObject(dim) ? dim : undefined;
    var setting = ppos !== undefined || val !== undefined && string(dim);
    var hasCompoundNodes = cy.hasCompoundNodes();

    if (ele && ele.isNode()) {
      // must have an element and must be a node to return position
      if (setting) {
        for (var i = 0; i < this.length; i++) {
          var _ele2 = this[i];
          var parent = hasCompoundNodes ? _ele2.parent() : null;
          var hasParent = parent && parent.length > 0;
          var relativeToParent = hasParent;

          if (hasParent) {
            parent = parent[0];
          }

          var origin = relativeToParent ? parent.position() : {
            x: 0,
            y: 0
          };

          if (val !== undefined) {
            // set one dimension
            _ele2.position(dim, val + origin[dim]);
          } else if (ppos !== undefined) {
            // set whole position
            _ele2.position({
              x: ppos.x + origin.x,
              y: ppos.y + origin.y
            });
          }
        }
      } else {
        // getting
        var pos = ele.position();

        var _parent = hasCompoundNodes ? ele.parent() : null;

        var _hasParent = _parent && _parent.length > 0;

        var _relativeToParent = _hasParent;

        if (_hasParent) {
          _parent = _parent[0];
        }

        var _origin = _relativeToParent ? _parent.position() : {
          x: 0,
          y: 0
        };

        ppos = {
          x: pos.x - _origin.x,
          y: pos.y - _origin.y
        };

        if (dim === undefined) {
          // then return the whole rendered position
          return ppos;
        } else {
          // then return the specified dimension
          return ppos[dim];
        }
      }
    } else if (!setting) {
      return undefined; // for empty collection case
    }

    return this; // chaining
  }
1312086
def positions(self):
        
        for y in range(self.height):
            for x in range(self.length):
                yield x, y
1011700
def overlaps(self, other):
        """"""
        if self > other:
            smaller, larger = other, self
        else:
            smaller, larger = self, other
        if larger.empty():
            return False
        if smaller._upper_value == larger._lower_value:
            return smaller._upper == smaller.CLOSED and larger._lower == smaller.CLOSED
        return larger._lower_value < smaller._upper_value
739991
def touching(self, other):
        
        if self.top < other.bottom: return False
        if self.bottom > other.top: return False

        if self.left > other.right: return False
        if self.right < other.left: return False

        return True