示例#1
0
const PositionRaw& PositionRaw::changePoint(const PositionRaw& newPoint)
{
    this->m_data[0] += newPoint(0);
    this->m_data[1] += newPoint(1);
    this->m_data[2] += newPoint(2);

    return *this;
}
示例#2
0
    void QmlMapControl::touchEvent(QTouchEvent *evnt)
    {
        const QList<QTouchEvent::TouchPoint> & touchs = evnt->touchPoints();
        if( touchs.count() != 2 )
        {
            QQuickPaintedItem::touchEvent(evnt);
        }
        else
        {
            evnt->accept();

            const QTouchEvent::TouchPoint & t0 = touchs.first();
            const QTouchEvent::TouchPoint & t1 = touchs.last();

            if( last_t0_startPos.isNull() )
                last_t0_startPos = t0.startPos();
            if( last_t1_startPos.isNull() )
                last_t1_startPos = t1.startPos();

            qreal startW = qPow( qPow(last_t0_startPos.x()-last_t1_startPos.x(),2)+qPow(last_t0_startPos.y()-last_t1_startPos.y(),2), 0.5 );
            qreal endW = qPow( qPow(t0.pos().x()-t1.pos().x(),2)+qPow(t0.pos().y()-t1.pos().y(),2), 0.5 );

            if( startW*4/3<endW )
            {
                QPoint pnt( last_t0_startPos.x()/2+last_t1_startPos.x()/2, last_t0_startPos.y()/2+last_t1_startPos.y()/2 );
                QPoint newPoint( width()-pnt.x(), height()-pnt.y() );

                setView(clickToWorldCoordinate(pnt));
                zoomIn(pnt);
                setView(clickToWorldCoordinate(newPoint));

                last_t0_startPos = t0.pos();
                last_t1_startPos = t1.pos();
            }
            else
            if( startW*3/4>endW )
            {
                QPoint pnt( t0.pos().x()/2+t1.pos().x()/2, t0.pos().y()/2+t1.pos().y()/2 );
                QPoint newPoint( width()-pnt.x(), height()-pnt.y() );

                setView(clickToWorldCoordinate(pnt));
                zoomOut(pnt);
                setView(clickToWorldCoordinate(newPoint));

                last_t0_startPos = t0.pos();
                last_t1_startPos = t1.pos();
            }
        }
    }
QPoint GameSceneController::nearestPoint(int xNew, int yNew) const {
	if (mPoints.isEmpty()) {
		return QPoint();
	}

	QPoint newPoint(xNew, yNew);
	QPoint nearestP = mPoints.first();

	bool isSet = false;
	int turnDist = distance(mPoints.first(), mPoints.last()) * 0.2;

	int minDist = distance(newPoint, nearestP);

	for (int i = 1; i < mPoints.size(); i++) {
		QPoint temp = mPoints.at(i);

		if (distance(mPoints.first(), temp) > turnDist &&
			distance(mPoints.last(), temp) > turnDist) {
			int dist = distance(temp, newPoint);

			if (!isSet) {
				minDist = dist;
				nearestP = temp;
				isSet = true;
			}

			if (dist < minDist) {
				nearestP = temp;
				minDist = dist;
			}
		}
	}

	return nearestP;
}
示例#4
0
point3D rotateZ(point3D p1, float angle) {
	float radangle = ToRadian(angle);
	point3D newPoint(cos(radangle)*p1.x + -sin(radangle)*p1.y + 0*p1.z, 
					sin(radangle)*p1.x + cos(radangle)*p1.y + 0*p1.z ,
					0*p1.x + 0*p1.y + 1*p1.z);
	return newPoint;
}
//===============================================================================================================================
void IndoorEnvironment::Update()
{
	mCube->SetWireframe( bWireframeMode );
	
	// Enable collision against the bottom of the cube when gravity is turned on
	
	// Apply simple gravity
	//m_CameraSystem->SetPositionY(eye.y - 0.3f);
	
	// I think that this will make the camera collide on top of the cube
	// Since the check is whether or not the camera is inside the cube
	// for the contact normal to be applied.
	
	// Clip the camera to the cube
	XMFLOAT3 eye = m_CameraSystem->Position();
	if (mCube->IntersectsAABB(eye))
	{
		// Find the contact normal and push the camera away from the cube
		
		float dist;
		ZShadeSandboxMath::XMMath3 contactNormal = ShapeContact::NormalFromPoint(*mCube->GetAABB(), eye, dist);
		
		// Point the contact normal to look inside the cube
		if (contactNormal.x > 0) contactNormal.x = -contactNormal.x;
		if (contactNormal.y > 0) contactNormal.y = -contactNormal.y;
		if (contactNormal.z > 0) contactNormal.z = -contactNormal.z;
		
		// The contact normal is already normalized
		ZShadeSandboxMath::XMMath3 newPoint(eye);
		newPoint += contactNormal;
		
		m_CameraSystem->SetPosition(newPoint.x, newPoint.y, newPoint.z);
	}
}
示例#6
0
void VtkColorTable::delPoint() {
    int currentRow = mainTable->currentRow();

    // Ensure that there is at least one row to remove.
    if (mainTable->rowCount() <= 0) return;

    // Set the current row if none exists
    if(currentRow == -1)
          currentRow = mainTable->rowCount()-1;

    removeCheckDupe(points.at(currentRow).scalarValue);

    points.remove(currentRow);
    
    mainTable->removeRow(currentRow);

    //if there are no more points, make a new one
    if (mainTable->rowCount() == 0) {
        newPoint();
    }
    //highlight the a row near the deleted row
    if (currentRow == mainTable->rowCount())
        mainTable->setCurrentCell(currentRow - 1, 0);
    else
        mainTable->setCurrentCell(currentRow, 0);
}
示例#7
0
const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
	if (_workingWindow.contains(point)) {
		// Convert from screen space to working window space
		Common::Point newPoint(point - Common::Point(_workingWindow.left, _workingWindow.top));

		RenderTable::RenderState state = _renderTable.getRenderState();
		if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
			newPoint = _renderTable.convertWarpedCoordToFlatCoord(newPoint);
		}

		if (state == RenderTable::PANORAMA) {
			newPoint += (Common::Point(_backgroundOffset - _screenCenterX, 0));
		} else if (state == RenderTable::TILT) {
			newPoint += (Common::Point(0, _backgroundOffset - _screenCenterY));
		}

		if (_backgroundWidth)
			newPoint.x %= _backgroundWidth;
		if (_backgroundHeight)
			newPoint.y %= _backgroundHeight;

		if (newPoint.x < 0)
			newPoint.x += _backgroundWidth;
		if (newPoint.y < 0)
			newPoint.y += _backgroundHeight;

		return newPoint;
	} else {
		return Common::Point(0, 0);
	}
}
void WCModeSketchArcThreePointCreate::OnMouseMove(const WPFloat &x, const WPFloat &y) {
    //Get suggestion from workbench
    this->_xSuggest = this->_workbench->SnapMouseX();
    this->_ySuggest = this->_workbench->SnapMouseY();
    this->_suggestionType = this->_workbench->SuggestAlignment(this->_alignRules, NULL, this->_xSuggest, this->_ySuggest);

    //Init some variables
    WCVector4 newPoint(this->_xSuggest, this->_ySuggest, 0.0, 1.0);
    //Get the updated position
    newPoint = this->_workbench->Sketch()->ReferencePlane()->TransformMatrix() * newPoint;

    //Switch on click stage
    if (this->_stage == 1) {
        //Update second point
        this->_secondPoint->Set(newPoint);
        //Update end of firstLine
        this->_firstLine->End(newPoint);
    }
    //Second click has occured
    else if (this->_stage == 2) {
        //Update third point
        this->_thirdPoint->Set(newPoint);
        //Calculate center and radius
        WCVector4 center;
        WPFloat radius = WCSketchArc::CalculateCenterAndRadius(this->_firstPoint->Data(), this->_secondPoint->Data(), this->_thirdPoint->Data(), center);
        if (radius == 0.0) {
            //Clean up and wait for good radius
            if (this->_arc != NULL) delete this->_arc;
            this->_arc = NULL;
            //Make first line visible
            this->_firstLine->IsVisible(true);
        }
        else {
            //Make first line not visible
            this->_firstLine->IsVisible(false);
            //Recreate arc
            WCVector4 xUnit(1.0, 0.0, 0.0, 0.0);
            WCVector4 yUnit(0.0, 1.0, 0.0, 0.0);
            xUnit = this->_workbench->Sketch()->ReferencePlane()->TransformMatrix() * xUnit;
            yUnit = this->_workbench->Sketch()->ReferencePlane()->TransformMatrix() * yUnit;
            xUnit.Normalize(true);
            yUnit.Normalize(true);
            //Back project center onto the plane to determine rotation angles
            WCVector4 planeCenter = this->_workbench->Sketch()->ReferencePlane()->InverseTransformMatrix() * center;
            WPFloat firstAngle = WCSketchArc::PointsToDegrees(planeCenter, this->_first);
            WPFloat secondAngle = WCSketchArc::PointsToDegrees(planeCenter, this->_second);
            //If not on right, then swap first and second
            if (!IsOnRight2D(this->_first.I(), this->_first.J(), this->_second.I(), this->_second.J(), this->_workbench->SnapMouseX(), this->_workbench->SnapMouseY()))
                std::swap(firstAngle, secondAngle);
            //Delete the old arc
            if (this->_arc != NULL) delete this->_arc;
            //Create the new one
            this->_arc = WCNurbsCurve::CircularArc(this->_creator->Document()->Scene()->GeometryContext(),
                                                   center, xUnit, yUnit, radius, firstAngle, secondAngle);
            this->_arc->Color(WCSketchFeature::InprocessColor);
            this->_arc->Thickness(WCSketchFeature::LineThickness);
//			this->_arc->Layer( this->_workbench->Layer() );
        }
    }
}
示例#9
0
void
TimeInstantLayer::moveSelection(Selection s, size_t newStartFrame)
{
    if (!m_model) return;

    SparseOneDimensionalModel::EditCommand *command =
	new SparseOneDimensionalModel::EditCommand(m_model,
						   tr("Drag Selection"));

    SparseOneDimensionalModel::PointList points =
	m_model->getPoints(s.getStartFrame(), s.getEndFrame());

    for (SparseOneDimensionalModel::PointList::iterator i = points.begin();
	 i != points.end(); ++i) {

	if (s.contains(i->frame)) {
	    SparseOneDimensionalModel::Point newPoint(*i);
	    newPoint.frame = i->frame + newStartFrame - s.getStartFrame();
	    command->deletePoint(*i);
	    command->addPoint(newPoint);
	}
    }

    finish(command);
}
Point Point::cross(Point & p) const
{
	Point newPoint(0, 0);


	return Point();
}
示例#11
0
void
TimeInstantLayer::resizeSelection(Selection s, Selection newSize)
{
    if (!m_model) return;

    SparseOneDimensionalModel::EditCommand *command =
	new SparseOneDimensionalModel::EditCommand(m_model,
						   tr("Resize Selection"));

    SparseOneDimensionalModel::PointList points =
	m_model->getPoints(s.getStartFrame(), s.getEndFrame());

    double ratio =
	double(newSize.getEndFrame() - newSize.getStartFrame()) /
	double(s.getEndFrame() - s.getStartFrame());

    for (SparseOneDimensionalModel::PointList::iterator i = points.begin();
	 i != points.end(); ++i) {

	if (s.contains(i->frame)) {

	    double target = i->frame;
	    target = newSize.getStartFrame() + 
		double(target - s.getStartFrame()) * ratio;

	    SparseOneDimensionalModel::Point newPoint(*i);
	    newPoint.frame = lrint(target);
	    command->deletePoint(*i);
	    command->addPoint(newPoint);
	}
    }

    finish(command);
}
QModelIndex HistogramView::indexAt(const QPoint &point)const
{
    QPoint newPoint(point.x(),point.y());
    QRegion region;
    foreach(region,MRegionList)				// 男 列
    {
        if (region.contains(newPoint))
        {
            int row = MRegionList.indexOf(region);
            QModelIndex index = model()->index(row,1,rootIndex());
            return index;
        }
    }
    foreach(region,FRegionList)				// 女 列
    {
        if (region.contains(newPoint))
        {
            int row = FRegionList.indexOf(region);
            QModelIndex index = model()->index(row,2,rootIndex());
            return index;
        }
    }
    foreach(region,SRegionList)				// 合计 列
    {
        if (region.contains(newPoint))
        {
            int row = SRegionList.indexOf(region);
            QModelIndex index = model()->index(row,3,rootIndex());
            return index;
        }
    }
    return QModelIndex();
}
示例#13
0
/* Tests setState and getScore */
void test_scoring() {
  point_type *points[4];
  int i;

  for(i = 0; i < 4; i++)
    points[i] = newPoint(0, i);

  CU_ASSERT_EQUAL(getScore(points), 0);

  for(i = 0; i < 4; i++)
    setState(points[i], PLAYER_ONE);

  CU_ASSERT_EQUAL(getScore(points), 4);

  for(i = 0; i < 4; i++)
    setState(points[i], PLAYER_TWO);

  CU_ASSERT_EQUAL(getScore(points), -4);

  setState(points[1], PLAYER_ONE);

  CU_ASSERT_EQUAL(getScore(points), 0);

  for(i = 0; i < 4; i++)
    free(points[i]);
}
示例#14
0
void BezierCurve::draw(){

	glDisable(GL_CULL_FACE);
	Vector3 cPt0;
	Vector3 cPt1;
	for (float t = 0.0; t < 1.0; t += 0.01){
		//glPushMatrix();
		/*
		glBegin(GL_LINES);
		cPt0 = newPoint(t);
		this->times.push_back(cPt0);
		cPt1 = newPoint(t + 0.01);
		glColor3f(1.0, 1.0, 1.0);
		glVertex3f(cPt0[0], cPt0[1], cPt0[2]);
		glVertex3f(cPt1[0], cPt1[1], cPt1[2]);
		glEnd();
		*/

		//glBegin(GL_POINTS);
		cPt0 = newPoint(t);
		this->times.push_back(cPt0);
		//glColor3f(1.0, 1.0, 1.0);
		//glVertex3f(cPt0[0], cPt0[1], cPt0[2]);
		//glEnd();
		
		//glPopMatrix();
	}
	//this->times.push_back(cPt1);
	glEnable(GL_CULL_FACE);
}
示例#15
0
    int GeoHopper::addSpecific(const GeoIndexEntry& node, const Point& keyP, bool onBounds,
            double keyD, bool potentiallyNewDoc) {
        // Unique documents
        GeoPoint newPoint(node, _collection->docFor(node.recordLoc), keyD, false);
        int prevSize = _points.size();

        // STEP 1 : Remove old duplicate points from the set if needed

        // Lookup old point with same doc
        map<DiskLoc, Holder::iterator>::iterator oldPointIt = _seenPts.find(newPoint.loc());

        if(oldPointIt != _seenPts.end()){
            const GeoPoint& oldPoint = *(oldPointIt->second);
            // We don't need to care if we've already seen this same approx pt or better,
            // or we've already gone to disk once for the point
            if(oldPoint < newPoint){
                return 0;
            }
            _points.erase(oldPointIt->second);
        }

        //cout << "inserting point\n";
        Holder::iterator newIt = _points.insert(newPoint);
        _seenPts[ newPoint.loc() ] = newIt;

        verify(_max > 0);

        Holder::iterator lastPtIt = _points.end();
        lastPtIt--;
        _farthest = lastPtIt->distance() + 2 * _distError;
        return _points.size() - prevSize;
    }
void KisCurveWidget::mousePressEvent(QMouseEvent * e)
{
    if (d->m_readOnlyMode) return;

    if (e->button() != Qt::LeftButton)
        return;

    double x = e->pos().x() / (double)(width() - 1);
    double y = 1.0 - e->pos().y() / (double)(height() - 1);



    int closest_point_index = d->nearestPointInRange(QPointF(x, y), width(), height());
    if (closest_point_index < 0) {
        QPointF newPoint(x, y);
        if (!d->jumpOverExistingPoints(newPoint, -1))
            return;
        d->m_grab_point_index = d->m_curve.addPoint(newPoint);
    } else {
        d->m_grab_point_index = closest_point_index;
    }

    d->m_grabOriginalX = d->m_curve.points()[d->m_grab_point_index].x();
    d->m_grabOriginalY = d->m_curve.points()[d->m_grab_point_index].y();
    d->m_grabOffsetX = d->m_curve.points()[d->m_grab_point_index].x() - x;
    d->m_grabOffsetY = d->m_curve.points()[d->m_grab_point_index].y() - y;
    d->m_curve.setPoint(d->m_grab_point_index, QPointF(x + d->m_grabOffsetX, y + d->m_grabOffsetY));

    d->m_draggedAwayPointIndex = -1;
    d->setState(ST_DRAG);


    d->setCurveModified();
}
示例#17
0
///////////////////////////////////////////////////////////////////////////////
// Driver program to test above functions
int testGrahamScan(const int argv, const char** argc)
{
    double points[] = { 0, 3,
                        1, 1,
                        2, 2,
                        4, 4,
                         0, 0,
                         1, 2,
                         3, 1,
                         3, 3};
    size_t n = sizeof(points)/sizeof(points[0]) / 2;
    
    std::vector<Point*> v;
    std::vector<Point*> curve;


    for(size_t i=0, k=0; i<n; i++, k += 2)
    {
        v.push_back(newPoint(points[k], points[k+1]));
    }
    fprintf(stdout, "start\n");
    computeConvexHull(v, curve, true);

    for(size_t i=0; i<curve.size(); i++)
    {
        fprintf(stdout, "[%04ld] %s\n", i, curve[i]->toString().c_str());
    }
    return 0;
}
示例#18
0
文件: STARS.cpp 项目: megadoro/OpenGL
point getPosition(int x, int y)
{
    int viewport[4];
    glGetIntegerv(GL_VIEWPORT, viewport);
    y = viewport[3]-y;
    return newPoint((2.0*x/viewport[2]-1)*viewport[2]/viewport[3],2.0*y/viewport[3]-1) * a + b;
}
示例#19
0
QgsPoint QgsMapToolCapture::mapPoint( const QgsPointXY &point ) const
{
  QgsPoint newPoint( QgsWkbTypes::Point, point.x(), point.y() );

  // get current layer
  QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
  if ( !vlayer )
  {
    return newPoint;
  }

  // convert to the corresponding type for a full ZM support
  const QgsWkbTypes::Type type = vlayer->wkbType();
  if ( QgsWkbTypes::hasZ( type ) && !QgsWkbTypes::hasM( type ) )
  {
    newPoint.convertTo( QgsWkbTypes::PointZ );
  }
  else if ( !QgsWkbTypes::hasZ( type ) && QgsWkbTypes::hasM( type ) )
  {
    newPoint.convertTo( QgsWkbTypes::PointM );
  }
  else if ( QgsWkbTypes::hasZ( type ) && QgsWkbTypes::hasM( type ) )
  {
    newPoint.convertTo( QgsWkbTypes::PointZM );
  }

  // set z value if necessary
  if ( QgsWkbTypes::hasZ( newPoint.wkbType() ) )
  {
    newPoint.setZ( defaultZValue() );
  }

  return newPoint;
}
示例#20
0
std::vector<Point> TetrisPiece::getBlocks()
{
	std::vector<Point> temp;
	for(std::vector<Point>::iterator it = my_blocks.begin(),
			end = my_blocks.end() ; it != end ; ++it)
		temp.push_back(newPoint(it->x,it->y));
	return temp;
}
示例#21
0
TetrisPiece TetrisPiece::rotateCW()
{
	// O pieces don't get rotated, so just return the current piece
	if(my_type == TetrisPiece::O)
		return getCopy();//return this;

	int oldX = 0, oldY = 0, lowY=3;
	std::vector<Point> new_blocks;

	// if it's an I block you need to do special rotation
	if(my_type == TetrisPiece::I)
	{
		if(isHorizI())
		{
			new_blocks.push_back(newPoint(1,0));
			new_blocks.push_back(newPoint(1,1));
			new_blocks.push_back(newPoint(1,2));
			new_blocks.push_back(newPoint(1,3));
		}
		else
		{
			new_blocks.push_back(newPoint(0,1));
			new_blocks.push_back(newPoint(1,1));
			new_blocks.push_back(newPoint(2,1));
			new_blocks.push_back(newPoint(3,1));
		}

		return TetrisPiece(new_blocks, my_type, my_location.x,
				my_location.y);
	}

	// if it's not an I or O, do rotation as normal
	for(std::vector<Point>::iterator it = my_blocks.begin(),
			end = my_blocks.end() ; it != end; ++it)
	{
		oldX = it->x;
		oldY = it->y;

		if(3 - oldX < lowY)
			lowY = 3 - oldX;

		new_blocks.push_back(newPoint(oldY,3-oldX));
	}

	// move to lower left corner
	for(std::vector<Point>::iterator it = new_blocks.begin(),
			end = new_blocks.end() ; it != end ; ++it)
		it->y -= lowY;

	return TetrisPiece(new_blocks, my_type, my_location.x, my_location.y);
}
示例#22
0
void Trajectory::insert(double x, double y) {
    SpTrajectoryPoint newPoint(new TrajectoryPoint(x, y));

    if(maxLength > 0 && size() == maxLength)
        trajectoryPoints.pop_front();

    trajectoryPoints.push_back(newPoint);
}
示例#23
0
TetrisPiece TetrisPiece::rotateCCW()
{
	// O pieces don't get rotated, so just return the current piece
	if(my_type == TetrisPiece::O)
		return getCopy();//return this;

	int oldX = 0, oldY = 0, lowX=3;
	std::vector<Point> new_blocks;

	//if it's an I block you need to do special rotation
	if(my_type == TetrisPiece::I)
	{
		if(isHorizI())
		{
			new_blocks.push_back(newPoint(1,0));
			new_blocks.push_back(newPoint(1,1));
			new_blocks.push_back(newPoint(1,2));
			new_blocks.push_back(newPoint(1,3));
		}
		else
		{
			new_blocks.push_back(newPoint(0,1));
			new_blocks.push_back(newPoint(1,1));
			new_blocks.push_back(newPoint(2,1));
			new_blocks.push_back(newPoint(3,1));
		}

		return TetrisPiece(new_blocks, my_type, my_location.x,
				my_location.y);
	}

	// if it's not an I or an O, rotate using this algorithm
	for(std::vector<Point>::iterator it = my_blocks.begin(),
			end = my_blocks.end() ; it != end ; ++it)
	{
		oldX = it->x;
		oldY = it->y;

		if(3 - oldY < lowX)
			lowX = 3 - oldY;

		new_blocks.push_back(newPoint(3-oldY,oldX));
	}

	// move it to the left
	for(std::vector<Point>::iterator it = new_blocks.begin(),
			end = new_blocks.end() ; it != end ; ++it)
		it->x -= lowX;

	return TetrisPiece(new_blocks, my_type, my_location.x, my_location.y);
}
示例#24
0
QPointF MathUtils::rotatePoint(const QPointF &point, qint32 angle)
{
    QPointF newPoint(point.x()*::cos(MathUtils::degreeToRadian(angle))+
                     point.y()*::sin(MathUtils::degreeToRadian(angle)),
                     point.y()*::cos(MathUtils::degreeToRadian(angle))-
                     point.x()*::sin(MathUtils::degreeToRadian(angle)));
    return newPoint;
}
示例#25
0
// Computes a cross product of point1 x point2
// USE ONLY ON VECTORS, NOT COORDINATES!
Coordinates crossProduct(Coordinates& point1,
						 Coordinates& point2)
{
	Coordinates newPoint((point1.y * point2.z - point1.z * point2.y),
						 (point1.z * point2.x - point1.x * point2.z),
						 (point1.x * point2.y - point1.y * point2.x));
	return newPoint;
}
示例#26
0
void ExampleVisualizer::moveAbsoluteStep(const MoveAbsoluteStep *step)
{
    QVector3D newPoint(step->x, step->y, step->z);
    if(not firstPoint)
        m_visual->add(new Line(QColor(255, 255, 255), prev, newPoint));
    else
        firstPoint = false;
    prev = newPoint;
}
示例#27
0
void VtkColorTable::setupSignals() {
    connect(mainTable, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(cellEditingSlot(int,int)));
    connect(mainTable, SIGNAL(cellChanged(int,int)), this, SLOT(updateCell(int,int)));

    connect(clampCheckBox, SIGNAL(stateChanged(int)), this, SLOT(updateClamp(int)));

    connect(newButton, SIGNAL(clicked()), this, SLOT(newPoint()));
    connect(delButton, SIGNAL(clicked()), this, SLOT(delPoint()));
}
short newSide( short alpha, short beta, short gamma, short c1)
{ // generates a cube center side (1 x face) 
  // alpha beta gamma indicate the rotation
  // c1 is the colors 
  // return index to face table  (containing 1 new face)
  
  short f, po;
  short x, y, z;
  short a, b ,c, d;
  
  // determin vertex coordinates  
  x = (+ U/2 );
  y = (+ U/2 );
  z = (U + U/2 +3);
  
  // rotation
  initMatrix( mo, alpha, beta, gamma, 0, 0, 0);

  // verify there is room in the tables
  if ((facec>=1) && (pyc>=1) && (pc>=4))
  {
      // generate all points necessary for the cube corner
      // in base position
      a = newPoint( x,   y,   z);        // A        
      b = newPoint( x,   y-U, z);        // B
      c = newPoint( x-U, y-U, z);        // C
      d = newPoint( x-U, y,   z);        // D
        
      // generate all the polygons and faces 
      // with proper orientation (normal outbound)
      f = newFace ( newPoly( a, b, c, d), c1);
        
      // add an object with 1 face
      po = newObj( f, 1);

      // rotate as required
      rotateObject( mo, po);
              
      // returns the object index
      return po;
  } // if 
    else 
        while( 1);
} // new cube side
示例#29
0
int
isAttractorConverging (struct attractor *at)
{
    point p, pe, pnew = NULL;
    int i, result = 0;

    p = newPoint ();
    pe = newPoint ();
    for (i = 0; i < fset.dimension; i++)
        p[i] = pe[i] = 0.1;
    pe[0] += LYAPU_DELTA;
    at->lyapunov->lsum = at->lyapunov->ly = at->lyapunov->n = 0;

    for (i = 0; i < at->convergenceIterations; i++) {
        pnew = eval (p, at->polynom);

        if (_abs (pnew) > AT_INFINITY) {        /* Diverging - not an SA */
            free (p);
            break;
        }
        point ptmp = _sub (pnew, p);
        if (_abs (ptmp) < 1 / AT_INFINITY) {    /* Fixed point - not an SA */
            free (p);
            free (ptmp);
            break;
        }
        free (ptmp);
        ptmp = computeLyapunov (pnew, pe, at);
        free (pe);
        pe = ptmp;
        if (at->lyapunov->ly < 0.005 && i >= NUM_CONVERGENCE_POINTS) {  /* Limit cycle - not an SA */
            free (p);
            break;
        }
        free (p);
        p = pnew;
    }
    if (i == at->convergenceIterations)
        result = 1;
    free (pnew);
    free (pe);
    return result;
}
示例#30
0
void GenericBrush::apply(QImage* image, const QPoint& currentPoint)
{
    int stampCenter = (STAMP_SIZE - 1) / 2;

    QPainter painter(image);
    QPoint newPoint(currentPoint.x() - stampCenter,
                    currentPoint.y() - stampCenter);

    painter.drawImage(newPoint, m_Stamp);
}