Repair a connection from start.

@param {Bounds} moved
@param {Bounds} other
@param {Point} newDocking
@param {Array<Point>} points originalPoints from moved to other

@return {Array<Point>|null} the repaired points between the two rectangles
350844
function tryRepairConnectionStart(moved, other, newDocking, points) {
  return _tryRepairConnectionSide(moved, other, newDocking, points);
}
453288
def reconnect(self, old_node, new_node):
        

        self._check_node(old_node)
        self._check_node(new_node)
        if old_node.id == new_node.id:
            return
        old_rel = _rel_helper(lhs='us', rhs='old', ident='r', **self.definition)

        # get list of properties on the existing rel
        result, meta = self.source.cypher(
            "MATCH (us), (old) WHERE id(us)={self} and id(old)={old} "
            "MATCH " + old_rel + " RETURN r", {'old': old_node.id})
        if result:
            node_properties = _get_node_properties(result[0][0])
            existing_properties = node_properties.keys()
        else:
            raise NotConnected('reconnect', self.source, old_node)

        # remove old relationship and create new one
        new_rel = _rel_helper(lhs='us', rhs='new', ident='r2', **self.definition)
        q = "MATCH (us), (old), (new) " \
            "WHERE id(us)={self} and id(old)={old} and id(new)={new} " \
            "MATCH " + old_rel
        q += " CREATE UNIQUE" + new_rel

        # copy over properties if we have
        for p in existing_properties:
            q += " SET r2.{0} = r.{1}".format(p, p)
        q += " WITH r DELETE r"

        self.source.cypher(q, {'old': old_node.id, 'new': new_node.id})
208811
def fixPoint(self, plotterPoint, canvasPoint):
        ''
        self.visibleBox.xmin = canvasPoint.x - self.canvasW(plotterPoint.x-self.plotviewBox.xmin)
        self.visibleBox.ymin = canvasPoint.y - self.canvasH(plotterPoint.y-self.plotviewBox.ymin)
        self.refresh()
1145409
protected Result<PortalResult> getPortalPoints(long from, Poly fromPoly, MeshTile fromTile, long to, Poly toPoly,
            MeshTile toTile, int fromType, int toType) {
        float[] left = new float[3];
        float[] right = new float[3];
        // Find the link that points to the 'to' polygon.
        Link link = null;
        for (int i = fromPoly.firstLink; i != NavMesh.DT_NULL_LINK; i = fromTile.links.get(i).next) {
            if (fromTile.links.get(i).ref == to) {
                link = fromTile.links.get(i);
                break;
            }
        }
        if (link == null) {
            return Result.invalidParam("No link found");
        }

        // Handle off-mesh connections.
        if (fromPoly.getType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION) {
            // Find link that points to first vertex.
            for (int i = fromPoly.firstLink; i != NavMesh.DT_NULL_LINK; i = fromTile.links.get(i).next) {
                if (fromTile.links.get(i).ref == to) {
                    int v = fromTile.links.get(i).edge;
                    System.arraycopy(fromTile.data.verts, fromPoly.verts[v] * 3, left, 0, 3);
                    System.arraycopy(fromTile.data.verts, fromPoly.verts[v] * 3, right, 0, 3);
                    return Result.success(new PortalResult(left, right, fromType, toType));
                }
            }
            return Result.invalidParam("Invalid offmesh from connection");
        }

        if (toPoly.getType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION) {
            for (int i = toPoly.firstLink; i != NavMesh.DT_NULL_LINK; i = toTile.links.get(i).next) {
                if (toTile.links.get(i).ref == from) {
                    int v = toTile.links.get(i).edge;
                    System.arraycopy(toTile.data.verts, toPoly.verts[v] * 3, left, 0, 3);
                    System.arraycopy(toTile.data.verts, toPoly.verts[v] * 3, right, 0, 3);
                    return Result.success(new PortalResult(left, right, fromType, toType));
                }
            }
            return Result.invalidParam("Invalid offmesh to connection");
        }

        // Find portal vertices.
        int v0 = fromPoly.verts[link.edge];
        int v1 = fromPoly.verts[(link.edge + 1) % fromPoly.vertCount];
        System.arraycopy(fromTile.data.verts, v0 * 3, left, 0, 3);
        System.arraycopy(fromTile.data.verts, v1 * 3, right, 0, 3);

        // If the link is at tile boundary, dtClamp the vertices to
        // the link width.
        if (link.side != 0xff) {
            // Unpack portal limits.
            if (link.bmin != 0 || link.bmax != 255) {
                float s = 1.0f / 255.0f;
                float tmin = link.bmin * s;
                float tmax = link.bmax * s;
                left = vLerp(fromTile.data.verts, v0 * 3, v1 * 3, tmin);
                right = vLerp(fromTile.data.verts, v0 * 3, v1 * 3, tmax);
            }
        }

        return Result.success(new PortalResult(left, right, fromType, toType));
    }
1164664
void setEndPoint(StandardRoadConnection desiredConnection) {
		final StandardRoadConnection oldPoint = getEndPoint(StandardRoadConnection.class);
		if (oldPoint != null) {
			oldPoint.removeConnectedSegment(this, false);
		}
		this.lastConnection = desiredConnection;
		if (desiredConnection != null) {
			final Point2d pts = desiredConnection.getPoint();
			if (pts != null) {
				setPointAt(-1, pts, true);
			}
			desiredConnection.addConnectedSegment(this, false);
		}
	}
1207108
private void updateNeigbor(Collection<Tile> resolved,
                               Collection<Tile> toResolve,
                               Tile tile,
                               Tile neighbor,
                               int ox,
                               int oy)
    {
        final String group = mapGroup.getGroup(tile);
        final String neighborGroup = mapGroup.getGroup(neighbor);

        final Transition transitionA = getTransition(tile, neighborGroup);
        final Transition transitionB = getTransition(neighbor, group);

        if (transitionA != null && transitionB != null)
        {
            final TransitionType transitionTypeA = transitionA.getType();
            final TransitionType transitionTypeB = transitionB.getType();

            final TransitionType newType = getTransition(transitionTypeA, transitionTypeB, ox, oy);
            if (newType != null)
            {
                final Transition newTransition = new Transition(newType, transitionA.getOut(), transitionB.getIn());
                updateTransition(resolved, toResolve, tile, neighbor, neighborGroup, newTransition);
            }
        }
    }
510583
def append(self, new_points_len):
        '''

        '''
        new_points_len = int(new_points_len)
        assert new_points_len >= 1, "Must at least append one point!"

        # find out start and stop index of the new memory
        try:
            new_points_start = self._slice_for_run_nr[-1][-1]
        except IndexError:
            new_points_start = 0
        new_points_stop  = new_points_start + new_points_len

        # store slice for new_points
        self._slice_for_run_nr.append( (new_points_start , new_points_stop) )

        if self.memleft < new_points_len: #need to allocate new memory
            self.memleft = 0
            #careful: do not use self._points because this may include unused memory
            self._points  = _np.vstack(  (self[:],_np.empty((new_points_len, self.dim)))  )
        else: #have enough memory
            self.memleft -= new_points_len

        # return reference to the new points
        return self._points[new_points_start:new_points_stop]
1042187
static Point2d[] reorderCoords(Point2d[] coords, int[] order) {
        Point2d[] neworder = new Point2d[coords.length];
        for (int i = 0; i < order.length; i++)
            neworder[order[i]] = coords[i];
        return neworder;
    }
33784
def dock(self, other):
		'''
			
		'''

		# e.g. self has mults at indices [0, 1, 2, 3, 4, 5, 6] len=7
		# e.g. other has mults at indices [0, 1, 2] len=3
		new = list(self.mults)
		for i in reversed(range(len(other.mults))): # [2, 1, 0]
			# e.g. i = 1, j = 7 - 3 + 1 = 5
			j = len(self.mults) - len(other.mults) + i
			new[j] = new[j].dock(other.mults[i])

			if new[j].multiplier == zero:
				# omit that mult entirely since it has been factored out
				del new[j]

			# If the subtraction is incomplete but there is more to
			# other.mults, then we have a problem. For example, "ABC{2} - BC"
			# subtracts the C successfully but leaves something behind,
			# then tries to subtract the B too, which isn't possible
			else:
				if i != 0:
					raise Exception("Can't subtract " + repr(other) + " from " + repr(self))

		return conc(*new)
806590
private void markNeighbor( TriangulationPoint p1, 
                               TriangulationPoint p2, 
                               DelaunayTriangle t )
    {
        if( ( p1 == points[2] && p2 == points[1] ) || ( p1 == points[1] && p2 == points[2] ) )
        {
            neighbors[0] = t;
        }
        else if( ( p1 == points[0] && p2 == points[2] ) || ( p1 == points[2] && p2 == points[0] ) )
        {
            neighbors[1] = t;
        }
        else if( ( p1 == points[0] && p2 == points[1] ) || ( p1 == points[1] && p2 == points[0] ) )
        {
            neighbors[2] = t;
        }
        else
        {
            logger.error( "Neighbor error, please report!" );
            // throw new Exception("Neighbor error, please report!");
        }
    }
612838
def repair(self, x, copy_if_changed=True, copy_always=False):
        
        if copy_always:
            x = array(x, copy=True)
            copy = False
        else:
            copy = copy_if_changed
        if self.bounds is None:
            return x
        for ib in [0, 1]:
            if self.bounds[ib] is None:
                continue
            for i in rglen(x):
                idx = min([i, len(self.bounds[ib]) - 1])
                if self.bounds[ib][idx] is not None and \
                        (-1)**ib * x[i] < (-1)**ib * self.bounds[ib][idx]:
                    if copy:
                        x = array(x, copy=True)
                        copy = False
                    x[i] = self.bounds[ib][idx]
1018576
function (x, y, points) {
            this.pos.set(x, y);

            if (!Array.isArray(points)) {
                return this;
            }

            // convert given points to me.Vector2d if required
            if (!(points[0] instanceof me.Vector2d)) {
                var _points = this.points = [];
                points.forEach(function (point) {
                   _points.push(new me.Vector2d(point.x, point.y));
                });
            } else {
                // array of me.Vector2d
                this.points = points;
            }

            this.recalc();
            this.updateBounds();

            return this;
        }
627572
@SuppressWarnings("static-method")
	public Point1dfx newPoint(ObjectProperty<WeakReference<Segment1D<?, ?>>> segment, DoubleProperty x, DoubleProperty y) {
		return new Point1dfx(segment, x, y);
	}
1324722
function (positionChange) {
                var _this = this;
                // finds the current position of the point by it's roles, than splices it for the new position or pushes it if it's not yet in the array
                /** @type {?} */
                var index = this._points.findIndex(function (point) {
                    return _this.compareArray(positionChange.roles, point.roles);
                });
                if (index === -1) {
                    this._points.push(positionChange);
                }
                else {
                    this._points.splice(index, 1, positionChange);
                }
            }
1178564
function shouldRedraw(oldEntries, newEntries) {
        if (!oldEntries || !newEntries) {
            return true;
        }

        if (oldEntries.length !== newEntries.length) {
            return true;
        }
        var i, newEntry, oldEntry, newOpts, oldOpts;
        for (i = 0; i < newEntries.length; i++) {
            newEntry = newEntries[i];
            oldEntry = oldEntries[i];

            if (newEntry.label !== oldEntry.label) {
                return true;
            }

            if (newEntry.color !== oldEntry.color) {
                return true;
            }

            // check for changes in lines options
            newOpts = newEntry.options.lines;
            oldOpts = oldEntry.options.lines;
            if (checkOptions(newOpts, oldOpts)) {
                return true;
            }

            // check for changes in points options
            newOpts = newEntry.options.points;
            oldOpts = oldEntry.options.points;
            if (checkOptions(newOpts, oldOpts)) {
                return true;
            }

            // check for changes in bars options
            newOpts = newEntry.options.bars;
            oldOpts = oldEntry.options.bars;
            if (checkOptions(newOpts, oldOpts)) {
                return true;
            }
        }

        return false;
    }
73946
@SuppressWarnings("static-method")
	public Point3ifx newPoint(IntegerProperty x, IntegerProperty y, IntegerProperty z) {
	    return new Point3ifx(x, y, z);
	}
756830
public void copyRemainder(Text other) {
        other.chars = this.chars;
        other.pos = this.linePointer + 1;
        other.len = this.len - this.linePointer - 1;
    }