Esempio n. 1
0
void wxTransform2D::InverseTransform( wxRect2DInt* r ) const
{
    wxPoint2DInt a = r->GetLeftTop(), b = r->GetRightBottom();
    InverseTransform( &a );
    InverseTransform( &b );
    *r = wxRect2DInt( a , b );
}
//Transform a point from world to thing coords
HRESULT C2DThingCoordTransformer::TransformToThingCoords(float * pflX, float * pflY, float * pflZ)
{

	HRESULT hr = S_OK;
	D3DVECTOR d3dVDst, d3dVSrc;

	if(NULL == pflX || NULL == pflY	|| NULL == pflZ)
	{
		hr = E_POINTER;
		goto EXIT_FAIL;
	}

	if (m_bDoTransform)
	{
		d3dVSrc.x = *pflX;
		d3dVSrc.y = *pflY;
		d3dVSrc.z = *pflZ;

		InverseTransform(&d3dVDst, &d3dVSrc);

		*pflX = d3dVDst.x;
		*pflY = d3dVDst.y;
		*pflZ = d3dVDst.z;
	}

EXIT_FAIL:

	return hr;
}
Esempio n. 3
0
bool Move::GetCurrentState(float m[])
{
  if(LookAheadRingFull())
    return false;
    
  for(int8_t i = 0; i < DRIVES; i++)
  {
    if(i < AXES)
      m[i] = lastMove->MachineToEndPoint(i);
    else
      m[i] = 0.0; //FIXME This resets extruders to 0.0, even the inactive ones (is this behaviour desired?)
      //m[i] = lastMove->MachineToEndPoint(i); //FIXME TEST alternative that does not reset extruders to 0
  }
  if(currentFeedrate >= 0.0)
    m[DRIVES] = currentFeedrate;
  else
    m[DRIVES] = lastMove->FeedRate();
  currentFeedrate = -1.0;
  InverseTransform(m);
  return true;
}
//Transform a vector from world to thing coords
HRESULT C2DThingCoordTransformer::TransformToThingCoordsNoTranslation(float * pflX, float * pflY, float * pflZ)
{
	HRESULT hr = S_OK;
	D3DVECTOR d3dVDst, d3dVSrc;
	IVector * pVector = NULL;


	if(NULL == pflX || NULL == pflY	|| NULL == pflZ)
	{
		hr = E_POINTER;
		goto EXIT_FAIL;
	}

	if (m_bDoTransform)
	{
		hr = m_pThing->get_ObjectProperty(bstrPosition, (IObjectProperty **) &pVector);
		if( FAILED(hr) ) goto EXIT_FAIL;

		hr = pVector->get(&d3dVSrc.x, &d3dVSrc.y, &d3dVSrc.z);
		if( FAILED(hr) ) goto EXIT_FAIL;

		d3dVSrc.x = *pflX + d3dVSrc.x;
		d3dVSrc.y = *pflY + d3dVSrc.y;
		d3dVSrc.z = *pflZ + d3dVSrc.z;

		InverseTransform(&d3dVDst, &d3dVSrc);

		*pflX = d3dVDst.x;
		*pflY = d3dVDst.y;
		*pflZ = d3dVDst.z;
	}

EXIT_FAIL:
	SAFERELEASE(pVector);

	return hr;
}
Esempio n. 5
0
wxRect2DInt wxTransform2D::InverseTransform( const wxRect2DInt &r ) const
{
    wxRect2DInt res = r;
    InverseTransform( &res );
    return res;
}
Esempio n. 6
0
wxPoint2DInt wxTransform2D::InverseTransform( const wxPoint2DInt &pt ) const
{
    wxPoint2DInt res = pt;
    InverseTransform( &res );
    return res;
}
Esempio n. 7
0
File: PCA.cpp Progetto: dmead/sc2bot
void PCA<T>::InverseTransform(Vector<T> &Result, const Vector<T> &Input)
{
	const UINT Dimension = _Means.Length();
	Result.Allocate(Dimension);
	InverseTransform(Result.CArray(), Input.CArray(), Input.Length());
}
Esempio n. 8
0
// _DragStateFor
//! where is expected in canvas view coordinates
DragState*
TransformBox::_DragStateFor(BPoint where, float canvasZoom)
{
	DragState* state = NULL;
	// convert to canvas zoom level
	//
	// the conversion is necessary, because the "hot regions"
	// around a point should be the same size no matter what
	// zoom level the canvas is displayed at

	float inset = INSET / canvasZoom;

	// priorities:
	// transformation center point has highest priority ?!?
	if (point_point_distance(where, fPivot) < inset)
		state = fOffsetCenterState;

	if (!state) {
		// next, the inner area of the box

		// for the following calculations
		// we can apply the inverse transformation to all points
		// this way we have to consider BRects only, not transformed polygons
		BPoint lt = fLeftTop;
		BPoint rb = fRightBottom;
		BPoint w = where;

		InverseTransform(&w);
		InverseTransform(&lt);
		InverseTransform(&rb);

		// next priority has the inside of the box
		BRect iR(lt, rb);
		float hInset = min_c(inset, max_c(0, (iR.Width() - inset) / 2.0));
		float vInset = min_c(inset, max_c(0, (iR.Height() - inset) / 2.0));

		iR.InsetBy(hInset, vInset);
		if (iR.Contains(w))
			state = fTranslateState;
	}

	if (!state) {
		// next priority have the corners
		float dLT = point_point_distance(fLeftTop, where);
		float dRT = point_point_distance(fRightTop, where);
		float dLB = point_point_distance(fLeftBottom, where);
		float dRB = point_point_distance(fRightBottom, where);
		float d = min4(dLT, dRT, dLB, dRB);
		if (d < inset) {
			if (d == dLT)
				state = fDragLTState;
			else if (d == dRT)
				state = fDragRTState;
			else if (d == dLB)
				state = fDragLBState;
			else if (d == dRB)
				state = fDragRBState;
		}
	}

	if (!state) {
		// next priority have the sides
		float dL = point_line_dist(fLeftTop, fLeftBottom, where, inset);
		float dR = point_line_dist(fRightTop, fRightBottom, where, inset);
		float dT = point_line_dist(fLeftTop, fRightTop, where, inset);
		float dB = point_line_dist(fLeftBottom, fRightBottom, where, inset);
		float d = min4(dL, dR, dT, dB);
		if (d < inset) {
			if (d == dL)
				state = fDragLState;
			else if (d == dR)
				state = fDragRState;
			else if (d == dT)
				state = fDragTState;
			else if (d == dB)
				state = fDragBState;
		}
	}

	if (!state) {
		BPoint lt = fLeftTop;
		BPoint rb = fRightBottom;
		BPoint w = where;

		InverseTransform(&w);
		InverseTransform(&lt);
		InverseTransform(&rb);

		// check inside of the box again
		BRect iR(lt, rb);
		if (iR.Contains(w)) {
			state = fTranslateState;
		} else {
			// last priority has the rotate state
			state = fRotateState;
		}
	}

	return state;
}