コード例 #1
0
ファイル: ge_waveform.cpp プロジェクト: holt0102/giada
void gWaveform::recalcPoints() 
{
  selectionA = relativePoint(selectionA_abs);
  selectionB = relativePoint(selectionB_abs);
  chanStart  = relativePoint(chan->begin / 2);

  /* fix the rounding error when chanEnd is set on the very end of the
   * sample */

  if (chan->end == chan->wave->size)
    chanEnd = data.size - 2; // 2 px border
  else
    chanEnd = relativePoint(chan->end / 2);
}
コード例 #2
0
std::list<Contact*> CollisionBox::pointAndBox(CollisionBox* b1, Vector v, std::list<Contact*> conts)
{
	std::list<Contact*> result;
	Vector n;
	precision deepestPoint;

	// TODO: pack up the reused code
	Vector rel_xaxis = b1->getAxis(0);
	Vector rel_yaxis = b1->getAxis(1);
	Vector rel_zaxis = b1->getAxis(2);

	Vector boxToPoint(v - b1->centre);
	precision xDist = rel_xaxis.scalarProduct(boxToPoint);
	precision yDist = rel_yaxis.scalarProduct(boxToPoint);
	precision zDist = rel_zaxis.scalarProduct(boxToPoint);

	Vector relativePoint(xDist, yDist, zDist);

	// If the vertex is inside our box then a point-face 
	// calculation is needed. Take axis with shallowest
	// penetration

	// X-Axis
	precision x_depth = b1->halfLength.x - std::abs(relativePoint.x);
	if (x_depth<0) return result;
	else
	{
		deepestPoint = x_depth;
		n = rel_xaxis;
		if (relativePoint.x < 0) n = rel_xaxis * -1;
	}

	// Y-Axis
	precision y_depth = b1->halfLength.y - std::abs(relativePoint.y);
	if (y_depth<0) return result;
	else if (y_depth< deepestPoint)
	{
		deepestPoint = y_depth;
		n = rel_yaxis;
		if (relativePoint.y < 0) n = rel_yaxis * -1;
	}

	// Z-Axis
	precision z_depth = b1->halfLength.z - std::abs(relativePoint.z);
	if (z_depth<0) return result;
	else if (z_depth< deepestPoint)
	{
		deepestPoint = z_depth;
		n = rel_zaxis;
		if (relativePoint.z < 0) n = rel_zaxis * -1;
	}

	result.push_back(new Contact(v,	deepestPoint,	n, this, b1));

	return result;
}
コード例 #3
0
ファイル: maptilesframe.cpp プロジェクト: ryfx/EasyGIS
bool MapTilesFrame::isInCurrentViewport(QPoint serverCoordinate, int scaleLevel)
{
    QPoint relativePoint(convertServerCoordinateToRelativeCoordinate(serverCoordinate, getScaleLevel(), scaleLevel));
    return QRect(0,0,getViewportWidth(),getViewportHeight()).contains(relativePoint);
}