Пример #1
0
inline void AbstractPath::filterOffset(const int i, Vec2f& here) const {
  Vec2f P1(getElement(i-1), getElement(i));
  Vec2f P2(getElement(i+1), getElement(i));
  
  float p1len = P1.Len(), p2len = P2.Len(), sum = p1len+p2len;
  P1 *= p2len / sum;
  P2 *= p1len / sum;

  here = P1;
  here += P2;
}
Пример #2
0
int main() {
  __CPROVER_ASYNC_0: P0(0);
  __CPROVER_ASYNC_1: P1(0);
  __CPROVER_ASYNC_2: P2(0);
  __CPROVER_ASYNC_3: P3(0);
  __CPROVER_assume(__unbuffered_cnt==4);
  fence();
  // EXPECT:exists
  __CPROVER_assert(!(x==2 && y==2 && __unbuffered_p0_r3==1 && __unbuffered_p1_r5==0 && __unbuffered_p2_r3==1 && __unbuffered_p3_r5==0), "Program proven to be relaxed for PPC, model checker says YES.");
  return 0;
}
Пример #3
0
void MainWindow::resizeItem() {
for (int i = 0;  i < 10;  i++) {
    QGraphicsRectItem* theFrame = item1;
    QPointF P1(100 - (7.0 * i)/3.0, 50 -(5.0*i)/3.0);

    graphicsSheet->addPoint("P1", P1);
    graphicsSheet->addPoint("pos", theFrame->pos());

    QPointF P2i = QPointF(theFrame->rect().width(), theFrame->rect().height());
    QPointF P2 = theFrame->mapToScene(P2i);

    qDebug() << "P1:" << P1;
    qDebug() << "P2:" << P2;
    graphicsSheet->addPoint("P2", P2);

    QTransform t;
    t.rotate(-theFrame->rotation());
    t.translate(-P1.x(), -P1.y());

    QPointF P2t = t.map(P2);

//    qDebug() << "P2t:" << P2t;  // OK

/*************************/
    QPointF P3(P2t.x()/2, P2t.y()/2);
 //   qDebug() << "P3:" << P3;

    QTransform t2;
    t2.translate(P1.x(), P1.y());
    t2.rotate(theFrame->rotation());
    QPointF P3t = t2.map(P3);
////    qDebug() << "P3t:" << P3t;      // OK

    graphicsSheet->addPoint("P3t", P3t);

    QTransform t3;
    t3.translate(P3t.x(), P3t.y());
    t3.rotate(-theFrame->rotation());
    t3.translate(-(P3t.x()), -(P3t.y()));

    QPointF newPos = t3.map(P1);
    QSizeF newSize = QSizeF(P2t.x(), P2t.y());

    graphicsSheet->addPoint("newPos", newPos);

    RectItem* item1 = new RectItem(QRectF(newPos.x(), newPos.y(), newSize.width(), newSize.height()));
    qreal angle = 30;
    QPointF center2 = QPointF(item1->rect().width() / 2, item1->rect().height() / 2);
    item1->setTransformOriginPoint(center2);
    item1->setRotation(angle);
    graphicsSheet->scene()->addItem(item1);

}
}
AREXPORT ArMapObject::ArMapObject(const char *type, 
					                        ArPose pose, 
                                  const char *description,
 		                              const char *iconName, 
                                  const char *name,
 		                              bool hasFromTo, 
                                  ArPose fromPose, 
                                  ArPose toPose) :
  myType((type != NULL) ? type : ""),
  myBaseType(),
  myName((name != NULL) ? name : "" ),
  myDescription((description != NULL) ? description : "" ),
  myPose(pose),
  myIconName((iconName != NULL) ? iconName : "" ),
  myHasFromTo(hasFromTo),
  myFromPose(fromPose),
  myToPose(toPose),
  myFromToSegments(),
  myStringRepresentation()
{
  if (myHasFromTo)
  {
    double angle = myPose.getTh();
    double sa = ArMath::sin(angle);
    double ca = ArMath::cos(angle);
    double fx = fromPose.getX();
    double fy = fromPose.getY();
    double tx = toPose.getX();
    double ty = toPose.getY();
    ArPose P0((fx*ca - fy*sa), (fx*sa + fy*ca));
    ArPose P1((tx*ca - fy*sa), (tx*sa + fy*ca));
    ArPose P2((tx*ca - ty*sa), (tx*sa + ty*ca));
    ArPose P3((fx*ca - ty*sa), (fx*sa + ty*ca));
    myFromToSegments.push_back(ArLineSegment(P0, P1));
    myFromToSegments.push_back(ArLineSegment(P1, P2));
    myFromToSegments.push_back(ArLineSegment(P2, P3));
    myFromToSegments.push_back(ArLineSegment(P3, P0));
  }
  else { // pose
    size_t whPos = myType.rfind("WithHeading");
    size_t whLen = 11;
    if (whPos > 0) {
      if (whPos == myType.size() - whLen) {
        myBaseType = myType.substr(0, whPos);
      }
    }
  } // end else pose

  IFDEBUG(
  ArLog::log(ArLog::Normal, 
             "ArMapObject::ctor() created %s (%s)",
             myName.c_str(), myType.c_str());
  );
Пример #5
0
void test_Bbox_E3_operator_incr()
{
    Point_E3d P1(-5,-4,-3);
    Point_E3d P2( 7, 6, 5);

    Bbox_E3d box(P1);
    box += P2;

    assert( box == Bbox_E3d(P1, P2) );

    assert( box.center() == Point_E3d(1,1,1) );
}
Пример #6
0
std::vector<sf::Vector2f> _getEdges(TPPLPoly& A)
{
	std::vector<sf::Vector2f> edges;
	for(unsigned int i=0; i < (A.GetNumPoints()+1) ; ++i)
	{
		sf::Vector2f P1( A[i].x, A[i].y);
		sf::Vector2f P2( A[(i+1)%A.GetNumPoints()].x, A[(i+1)%A.GetNumPoints()].y );

		edges.push_back( P2 - P1 );
	}
	return edges;
}
Пример #7
0
int main() {
__CPROVER_ASYNC_0:
    P0(0);
__CPROVER_ASYNC_1:
    P1(0);
__CPROVER_ASYNC_2:
    P2(0);
    __CPROVER_assume(__unbuffered_cnt==3);
    fence();
    // EXPECT:exists
    __CPROVER_assert(!(z==2 && __unbuffered_p1_r1==1 && __unbuffered_p1_r3==0), "Program was expected to be safe for PPC, model checker should have said NO.\nThis likely is a bug in the tool chain.");
    return 0;
}
Пример #8
0
bool CSPrimBox::Write2XML(TiXmlElement &elem, bool parameterised)
{
    CSPrimitives::Write2XML(elem,parameterised);

    TiXmlElement P1("P1");
    m_Coords[0].Write2XML(&P1,parameterised);
    elem.InsertEndChild(P1);

    TiXmlElement P2("P2");
    m_Coords[1].Write2XML(&P2,parameterised);
    elem.InsertEndChild(P2);
    return true;
}
Пример #9
0
		void	compress(sm3_data_picker& data){

			boost::uint32_t A= ctx_.hash32[0];
			boost::uint32_t B= ctx_.hash32[1];
			boost::uint32_t C= ctx_.hash32[2];
			boost::uint32_t D= ctx_.hash32[3];
			boost::uint32_t E= ctx_.hash32[4];
			boost::uint32_t F= ctx_.hash32[5];
			boost::uint32_t G= ctx_.hash32[6];
			boost::uint32_t H= ctx_.hash32[7];

			boost::uint32_t SS1=0, SS2=0, TT1=0, TT2=0;
			boost::uint32_t W[64+4]={0},W1[64]={0};
			for (int i=0;i<16;++i){
				W[i]=data.next_uint32_be();
			}

			for (int j = 16; j < 68; j++) {
				W[j] = P1(W[j - 16] ^ W[j - 9] ^ circular_shift_l<boost::uint32_t>(W[j - 3],15)) ^ circular_shift_l<boost::uint32_t>(W[j - 13],7) ^ W[j - 6] ;
			}

			for (int j = 0; j < 64; j++) {
				W1[j] = W[j] ^ W[j + 4];
			}
			for (int j = 0; j < 64; j++) {
				SS1 =circular_shift_l<boost::uint32_t>(
					(circular_shift_l<boost::uint32_t>(A,12) + E + circular_shift_l<boost::uint32_t>(get_magic_number(j),j) )
					,7);
				SS2 = SS1 ^ circular_shift_l<boost::uint32_t>(A,12);
				TT1 = FF(A, B, C, j) + D + SS2 + W1[j];
				unsigned long ggh=GG(E,F,G,j);
				TT2 = GG(E, F, G, j) + H + SS1 + W[j];
				D = C;
				C = circular_shift_l<boost::uint32_t>(B,9);
				B = A;
				A = TT1;
				H = G;
				G = circular_shift_l<boost::uint32_t>(F,19);
				F = E;
				E = P0(TT2);
			}

			ctx_.hash32[0] ^=A;
			ctx_.hash32[1] ^=B;
			ctx_.hash32[2] ^=C;
			ctx_.hash32[3] ^=D;
			ctx_.hash32[4] ^=E;
			ctx_.hash32[5] ^=F;
			ctx_.hash32[6] ^=G;
			ctx_.hash32[7] ^=H;
		}
int main() {

  GlobalPoint P1(3., 4., 7.);
  GlobalPoint P2(-2., 5., 7.);

  oldCode(P1,P2);
  newCode(P1,P2);

  oldCode(P2,P1);
  newCode(P2,P1);


  return 0;
}
Пример #11
0
void test_mixed_of()
{
    typedef boost::geometry::model::polygon<P1> polygon_type1;
    typedef boost::geometry::model::polygon<P2> polygon_type2;
    typedef boost::geometry::model::box<P1> box_type1;
    typedef boost::geometry::model::box<P2> box_type2;

    polygon_type1 poly1, poly2;
    boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly1);
    boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly2);

    box_type1 box1(P1(1, 1), P1(4, 4));
    box_type2 box2(P2(0, 0), P2(5, 5));
    P1 p1(3, 3);
    P2 p2(3, 3);

    BOOST_CHECK_EQUAL(bg::covered_by(p1, poly2), true);
    BOOST_CHECK_EQUAL(bg::covered_by(p2, poly1), true);
    BOOST_CHECK_EQUAL(bg::covered_by(p2, box1), true);
    BOOST_CHECK_EQUAL(bg::covered_by(p1, box2), true);
    BOOST_CHECK_EQUAL(bg::covered_by(box1, box2), true);
    BOOST_CHECK_EQUAL(bg::covered_by(box2, box1), false);
}
Пример #12
0
void test_op()
{
    Point_E3d  P1(3.0,4.0,5.0);
    Point_E3d  P2(4.0,7.0,9.0);
    Vector_E3d V1(8.0,4.0,2.0);

    Point_E3d A1 = P1;
    A1 += V1;
    assert( Point_E3d(11.0,8.0,7.0) == A1 );
    A1 -= V1;
    assert( P1 == A1 );

    Vector_E3d V2(P1, P2);
    assert( Vector_E3d(1.0, 3.0, 4.0) == V2 );
}
Пример #13
0
Point Rectangle::Sample(float u, float v, Normal *Ns) const {

    // u and v are random samples on the surface of the light source
    Point P0(-x/2, y/2, height), P1(x/2, y/2, height);
    Point P2(-x/2, -y/2, height), P3(x/2, -y/2, height);

    Point p = P0 + (P1 - P0) * u + (P2 - P0) * v;

    Normal n = Normal(Cross(P2-P0, P1-P0));
    *Ns = Normalize(n);

    // NORMAL ON THE PLANE
    *Ns = Normalize((*ObjectToWorld)(n));
    if (ReverseOrientation) *Ns *= -1.f;
    return (*ObjectToWorld)(p);
}
Пример #14
0
void test_rotation()
{
    Point_E3d P1(1,2,3);

    Transformation_E3d T1(ROTATION,
                          Direction_E3d(3,4,5),
                          1.0);
    Point_E3d P2 = T1(P1);

    Transformation_E3d T2(ROTATION,
                          Direction_E3d(-3,-4,-5),
                          1.0);
    Point_E3d P3 = T2(P2);

    assert(P3 == P1);
}
Пример #15
0
void test_Transformation_E3()
{
    Point_E3d P1(5,7,9);
    Vector_E3d V1(11,13,17);

    Point_E3d P2 = P1 + V1;

    Transformation_E3d T(ORTHOGONAL, Point_E3d(4,5,6), Point_E3d(7,8,9));

    Point_E3d P1t = T(P1);
    Vector_E3d V1t = T(V1);

    Point_E3d P2t = T(P2);

    assert( P2t == P1t + V1t );
}
Пример #16
0
QPolygon KDChart::TextLayoutItem::rotatedCorners() const
{
    // the angle in rad
    const qreal angle = mAttributes.rotation() * PI / 180.0;
    QSize size = unrotatedSizeHint();

    // my P1 - P4 (the four points of the rotated area)
    QPointF P1( size.height() * sin( angle ), 0 );
    QPointF P2( size.height() * sin( angle ) + size.width() * cos( angle ), size.width() * sin( angle ) );
    QPointF P3( size.width() * cos( angle ), size.width() * sin( angle ) + size.height() * cos( angle ) );
    QPointF P4( 0, size.height() * cos( angle ) );

    QPolygon result;
    result << P1.toPoint() << P2.toPoint() << P3.toPoint() << P4.toPoint();
    return result;
}
Пример #17
0
void srTSpherMirror::SetupInAndOutPlanes(TVector3d* InPlane, TVector3d* OutPlane)
{// Assumes InPlaneNorm and transverse part InPlaneCenPo already defined !!!
	TVector3d &InPlaneCenPo = *InPlane, &InPlaneNorm = InPlane[1];
	TVector3d &OutPlaneCenPo = *OutPlane, &OutPlaneNorm = OutPlane[1];

	TVector3d LocInPlaneNorm = InPlaneNorm;
	FromLabToLocFrame_Vector(LocInPlaneNorm);

	double xP = -0.5*Dx, yP = -0.5*Dy;
	TVector3d P0(xP, yP, SurfaceFunction(xP, yP, 0));
	TVector3d P1(-xP, yP, SurfaceFunction(-xP, yP, 0));
	TVector3d P2(xP, -yP, SurfaceFunction(xP, -yP, 0));
	TVector3d P3(-xP, -yP, SurfaceFunction(-xP, -yP, 0));
	TVector3d EdgePoints[] = { P0, P1, P2, P3 };

	int LowestInd, UppestInd;
	FindLowestAndUppestPoints(LocInPlaneNorm, EdgePoints, 4, LowestInd, UppestInd);

	TVector3d PointForInPlane = EdgePoints[LowestInd];
	FromLocToLabFrame_Point(PointForInPlane);
	InPlaneCenPo.y = PointForInPlane.y;

	TVector3d LocInPlaneCenPo = InPlaneCenPo;
	FromLabToLocFrame_Point(LocInPlaneCenPo);
	TVector3d LocInPlane[] = { LocInPlaneCenPo, LocInPlaneNorm };

	TVector3d LocP, LocN;
	FindRayIntersectWithSurface(LocInPlane, 0, LocP);
	SurfaceNormalAtPoint(LocP.x, LocP.y, 0, LocN);

	TVector3d LocOutPlaneNorm = LocInPlaneNorm;
	ReflectVect(LocN, LocOutPlaneNorm);
	FindLowestAndUppestPoints(LocOutPlaneNorm, EdgePoints, 4, LowestInd, UppestInd);
	OutPlaneCenPo = (EdgePoints[UppestInd]*LocOutPlaneNorm)*LocOutPlaneNorm;
	*OutPlaneInLocFrame = OutPlaneCenPo; OutPlaneInLocFrame[1] = LocOutPlaneNorm;
	FromLocToLabFrame_Point(OutPlaneCenPo);
	OutPlaneNorm = LocOutPlaneNorm;
	FromLocToLabFrame_Vector(OutPlaneNorm);

	TVector3d LabN = LocN;
	FromLocToLabFrame_Vector(LabN);
	ExRefInLabFrameBeforeProp = TVector3d(1.,0.,0.);
	ReflectVect(LabN, ExRefInLabFrameBeforeProp);
	EzRefInLabFrameBeforeProp = TVector3d(0.,0.,1.);
	ReflectVect(LabN, EzRefInLabFrameBeforeProp);
}
Пример #18
0
static double BesselOrderOne(double x)
{
	double p, q;

	if (x == 0.0)
		return(0.0);
	p=x;
	if (x < 0.0)
		x=(-x);
	if (x < 8.0)
		return(p*J1(x));
	q=sqrt(2.0/(M_PI*x))*(P1(x)*(1.0/sqrt(2.0)*(sin(x)-cos(x)))-8.0/x*Q1(x)*
		(-1.0/sqrt(2.0)*(sin(x)+cos(x))));
	if (p < 0.0)
		q=(-q);
	return(q);
}
Пример #19
0
int
sc_main( int, char*[] )
{
    sc_signal<int> ack;
    sc_signal<int> ready;

    ack = 1;
    ready = 1;

    sc_clock clk( "Clock", 20, SC_NS, 0.5, 0.0, SC_NS );

    proc1 P1( "P1", clk, ack, ready );
    proc2 P2( "P2", clk, ready, ack );

    sc_start( 500, SC_NS );

    return 0;
}
Пример #20
0
rgpprob1::rgpprob1() : rgp_base(NUM_VARS)
{
  // Objective function: h^-1 w^-1 d^-1 (inverse of volume)
  { monomial<aaf> obj(NUM_VARS);
    obj._a[h] = aaf(-1.0); obj._a[w] = aaf(-1.0); obj._a[d] = aaf(-1.0);
    obj.set_coeff(aaf(1.0));
    rgp_base::_M.push_back( posynomial<aaf>(obj) ); }
  
  // (2/Awall)hw + (2/Awall)hd <= 1
  { monomial<aaf> T11(NUM_VARS);
    T11._a[h] = aaf(1.0); T11._a[w] = aaf(1.0);
    T11.set_coeff(2./Awall);
    monomial<aaf> T12(NUM_VARS);
    T12._a[h] = aaf(1.0); T12._a[d] = aaf(1.0);
    T12.set_coeff(2./Awall);
    posynomial<aaf> P1(T11);
    P1 += T12; 
    rgp_base::_M.push_back(P1); }
  
  { monomial<aaf> T2(NUM_VARS);
    T2._a[w] = aaf(1.0); T2._a[d] = aaf(1.0);
    T2.set_coeff(1./Aflr);
    rgp_base::_M.push_back( posynomial<aaf>(T2) ); }
  
  { monomial<aaf> T3(NUM_VARS);
    T3._a[h] = aaf(-1.0); T3._a[w] = aaf(1.0);
    T3.set_coeff(alpha);
    rgp_base::_M.push_back( posynomial<aaf>(T3) ); }
  
  { monomial<aaf> T4(NUM_VARS);
    T4._a[h] = aaf(1.0); T4._a[w] = aaf(-1.0);
    T4.set_coeff(1./beta);
    rgp_base::_M.push_back( posynomial<aaf>(T4) ); }
  
  { monomial<aaf> T5(NUM_VARS);
    T5._a[w] = aaf(1.0); T5._a[d] = aaf(-1.0);
    T5.set_coeff(gamma2);
    rgp_base::_M.push_back( posynomial<aaf>(T5) ); }
  
  { monomial<aaf> T6(NUM_VARS);
    T6._a[w] = aaf(-1.0); T6._a[d] = aaf(1.0);
    T6.set_coeff(1./delta);
    rgp_base::_M.push_back( posynomial<aaf>(T6) ); }
}
Пример #21
0
bool CSPrimUserDefined::Write2XML(TiXmlElement &elem, bool parameterised)
{
	CSPrimitives::Write2XML(elem,parameterised);

	elem.SetAttribute("CoordSystem",CoordSystem);

	TiXmlElement P1("CoordShift");
	WriteTerm(dPosShift[0],P1,"X",parameterised);
	WriteTerm(dPosShift[1],P1,"Y",parameterised);
	WriteTerm(dPosShift[2],P1,"Z",parameterised);
	elem.InsertEndChild(P1);

	TiXmlElement FuncElem("Function");
	TiXmlText FuncText(GetFunction());
	FuncElem.InsertEndChild(FuncText);

	elem.InsertEndChild(FuncElem);
	return true;
}
Пример #22
0
void Centerline::buildKdTree()
{
  FILE * f = Fopen("myPOINTS.pos","w");
  fprintf(f, "View \"\"{\n");

  int nbPL = 3;  //10 points per line
  //int nbNodes  = (lines.size()+1) + (nbPL*lines.size());
  int nbNodes  = (colorp.size()) + (nbPL*lines.size());

  ANNpointArray nodes = annAllocPts(nbNodes, 3);
  int ind = 0;
  std::map<MVertex*, int>::iterator itp = colorp.begin();
  while (itp != colorp.end()){
     MVertex *v = itp->first;
     nodes[ind][0] = v->x();
     nodes[ind][1] = v->y();
     nodes[ind][2] = v->z();
     itp++; ind++;
  }
  for(unsigned int k = 0; k < lines.size(); ++k){
   MVertex *v0 = lines[k]->getVertex(0);
   MVertex *v1 = lines[k]->getVertex(1);
   SVector3 P0(v0->x(),v0->y(), v0->z());
   SVector3 P1(v1->x(),v1->y(), v1->z());
   for (int j= 1; j < nbPL+1; j++){
     double inc = (double)j/(double)(nbPL+1);
     SVector3 Pj = P0+inc*(P1-P0);
     nodes[ind][0] = Pj.x();
     nodes[ind][1] = Pj.y();
     nodes[ind][2] = Pj.z();
     ind++;
   }
 }

 kdtree = new ANNkd_tree(nodes, nbNodes, 3);

 for(int i = 0; i < nbNodes; ++i){
   fprintf(f, "SP(%g,%g,%g){%g};\n",
	   nodes[i][0], nodes[i][1],nodes[i][2],1.0);
 }
 fprintf(f,"};\n");
 fclose(f);
}
Пример #23
0
int main() {

  GlobalPoint P1(3., 4., 7.);
  GlobalPoint P2(-2., 5., 7.);

  oldCode(P1,P2);
  newCode(P1,P2);

  oldCode(P2,P1);
  newCode(P2,P1);

  {
  ThirdHitPredictionFromInvParabola pred(P1,P2,0.2,0.05,0.1);
  std::cout << "ip min, max " <<  pred.theIpRangePlus.min() << " " << pred.theIpRangePlus.max()
	    << "  " <<  pred.theIpRangeMinus.min() << " " << pred.theIpRangeMinus.max()  << std::endl;
  std::cout << "A,B +pos " << pred.coeffA(0.1) << " " <<  pred.coeffB(0.1) << std::endl;
  std::cout << "A,B -pos " << pred.coeffA(-0.1) << " " <<  pred.coeffB(-0.1) << std::endl;

  auto rp = pred.rangeRPhi(5.,1);
  auto rn = pred.rangeRPhi(5.,-1);
  std::cout << "range " << rp.min() << " " << rp.max()
	    << " " << rn.min() << " " << rn.max() << std::endl;
  }

  ThirdHitPredictionFromInvParabola pred(-1.092805, 4.187564, -2.361283, 7.892722, 0.111413, 0.019043, 0.032000);
  std::cout << "ip min, max " <<  pred.theIpRangePlus.min() << " " << pred.theIpRangePlus.max()
	    << "  " <<  pred.theIpRangeMinus.min() << " " << pred.theIpRangeMinus.max()  << std::endl;
  {
  auto rp = pred.rangeRPhi(11.4356,1);
  auto rn = pred.rangeRPhi(11.4356,-1);
  std::cout << "range " << rp.min() << " " << rp.max()
	    << " " << rn.min() << " " << rn.max() << std::endl;
  }
  {
  auto rp = pred.rangeRPhi(13.2131,1);
  auto rn = pred.rangeRPhi(13.2131,-1);
  std::cout << "range " << rp.min() << " " << rp.max()
	    << " " << rn.min() << " " << rn.max() << std::endl;
  }

  return 0;
}
AREXPORT void ArForbiddenRangeDevice::processMap(void)
{
  std::list<ArMapObject *>::const_iterator it;
  ArMapObject *obj;

  myDataMutex.lock();
  ArUtil::deleteSet(mySegments.begin(), mySegments.end());
  mySegments.clear();

  for (it = myMap->getMapObjects()->begin();
       it != myMap->getMapObjects()->end();
       it++)
  {
    obj = (*it);
    if (strcmp(obj->getType(), "ForbiddenLine") == 0 &&
	obj->hasFromTo())
    {
      mySegments.push_back(new ArLineSegment(obj->getFromPose(), 
					     obj->getToPose()));
    }
    if (strcmp(obj->getType(), "ForbiddenArea") == 0 &&
	obj->hasFromTo())
    {
      double angle = obj->getPose().getTh();
      double sa = ArMath::sin(angle);
      double ca = ArMath::cos(angle);
      double fx = obj->getFromPose().getX();
      double fy = obj->getFromPose().getY();
      double tx = obj->getToPose().getX();
      double ty = obj->getToPose().getY();
      ArPose P0((fx*ca - fy*sa), (fx*sa + fy*ca));
      ArPose P1((tx*ca - fy*sa), (tx*sa + fy*ca));
      ArPose P2((tx*ca - ty*sa), (tx*sa + ty*ca));
      ArPose P3((fx*ca - ty*sa), (fx*sa + ty*ca));
      mySegments.push_back(new ArLineSegment(P0, P1));
      mySegments.push_back(new ArLineSegment(P1, P2));
      mySegments.push_back(new ArLineSegment(P2, P3));
      mySegments.push_back(new ArLineSegment(P3, P0));
    }
  }
  myDataMutex.unlock();
}
Пример #25
0
int test_main(int, char *[])
{
	/*
	BOOST_CHECK(Com::traits<Com::object< ::IUnknown> >::variant_type_id==::VT_UNKNOWN);
	BOOST_CHECK(Com::traits<Com::object< ::IDispatch> >::variant_type_id==::VT_DISPATCH);
	BOOST_CHECK(Com::traits<Com::object<IMy> >::variant_type_id==::VT_UNKNOWN);
	BOOST_CHECK(Com::traits<Com::object<IDMy> >::variant_type_id==::VT_DISPATCH);
	BOOST_CHECK(Com::traits<Com::object<IDMy2> >::variant_type_id==::VT_DISPATCH);
	*/

	Com::iunknown P;
	BOOST_CHECK(P.QueryInterface<My_IDMy>()==My::IDMy());

	Com::iunknown P1(new MyBase<Com::iunknown::interface_type>());
	BOOST_CHECK(P1.QueryInterface<IUnknown>()!=Com::iunknown());

	My::IDMy my(new DMy());
	BOOST_CHECK(my.A()==2005);
	return 0;
}
Пример #26
0
double rspfBesselOrderOneFilter::filter(double x, double /* support */)const
{
   double
      p,
      q;
   
   if (x == 0.0)
      return(0.0);
   p=x;
   if (x < 0.0)
      x=(-x);
   if (x < 8.0)
      return(p*J1(x));
   q=sqrt(2.0/(M_PI*x))*(P1(x)*(1.0/sqrt(2.0)*(sin(x)-cos(x)))-8.0/x*Q1(x)*
                         (-1.0/sqrt(2.0)*(sin(x)+cos(x))));
   if (p < 0.0)
      q=(-q);
   return(q);

}
Пример #27
0
void DrawVisibility(QPainter *p,pigalePaint *paint)
  {TopologicalGraph G(paint->GCP);
  Prop<Tpoint> P1(G.Set(tedge()),PROP_DRAW_POINT_1);
  Prop<Tpoint> P2(G.Set(tedge()),PROP_DRAW_POINT_2);
  Prop<int> x1(G.Set(tvertex()),PROP_DRAW_INT_1);
  Prop<int> x2(G.Set(tvertex()),PROP_DRAW_INT_2);
  Prop<int> y(G.Set(tvertex()),PROP_DRAW_INT_5);
  Prop<short> ecolor(G.Set(tedge()),PROP_COLOR);
  Prop<short> vcolor(G.Set(tvertex()),PROP_COLOR);

  double alpha=0.35;
  p->setFont(QFont("sans",Min((int)(1.8*alpha * Min(paint->xscale,paint->yscale) + .5),13)));
  Tpoint a,b;
  for(tvertex v=1;v<=G.nv();v++)
      paint->DrawText(p,x1[v]-alpha,y[v]+alpha, x2[v]-x1[v]+2*alpha,2*alpha,v,vcolor[v]);
  for (tedge e = 1;e <= G.ne();e++)
      {a.x() = P1[e].x(); a.y() = P1[e].y() + alpha;
      b.x() = P1[e].x();  b.y() = P2[e].y() - alpha;
      paint->DrawSeg(p,a,b,ecolor[e]);
      }
  }
Пример #28
0
BOOL KG3DTerrainRoad::CheckIncurvate(KG3DTerrainRoadPassage::TinyLine& L1,KG3DTerrainRoadPassage::TinyLine& L2)
{
	if((L1.vLeft2D == L2.vLeft2D)||(L1.vLeft2D == -L2.vLeft2D))
		return FALSE;
	
	D3DXVECTOR2 P1(L1.vPositionA[0].x,L1.vPositionA[0].z);
	D3DXVECTOR2 P2(L2.vPositionA[0].x,L2.vPositionA[0].z);

	float K1 = L1.vLeft2D.y/L1.vLeft2D.x;
	float K2 = L2.vLeft2D.y/L2.vLeft2D.x;
	D3DXVECTOR2 Inter;
	
	Inter.x = (P2.y - P1.y +  K1 * P1.x -  K2 * P2.x)/(K1 - K2);
	Inter.y = K1 * (Inter.x - P1.x) + P1.y;
	
	D3DXVECTOR2 dir = Inter - P1;
	if( dir.x * L2.vLeft2D.x >= 0 && dir.y * L2.vLeft2D.y >= 0)
		return TRUE;

	return FALSE;
}
Пример #29
0
void LabelItem::applyDataLockedDimensions() {
  PlotRenderItem *render_item = dynamic_cast<PlotRenderItem *>(parentViewItem());
  if (render_item) {
    qreal parentWidth = render_item->width();
    qreal parentHeight = render_item->height();
    qreal parentX = render_item->rect().x();
    qreal parentY = render_item->rect().y();
    qreal parentDX = render_item->plotItem()->xMax() - render_item->plotItem()->xMin();
    qreal parentDY = render_item->plotItem()->yMax() - render_item->plotItem()->yMin();

    QPointF drP1 = _dataRelativeRect.topLeft();
    QPointF drP2 = _dataRelativeRect.bottomRight();

    QPointF P1(parentX + parentWidth*(drP1.x()-render_item->plotItem()->xMin())/parentDX,
                       parentY + parentHeight*(render_item->plotItem()->yMax() - drP1.y())/parentDY);
    QPointF P2(parentX + parentWidth*(drP2.x()-render_item->plotItem()->xMin())/parentDX,
                       parentY + parentHeight*(render_item->plotItem()->yMax() - drP2.y())/parentDY);

    qreal theta = atan2(P2.y() - P1.y(), P2.x() - P1.x());
    qreal height = rect().height();
    qreal width = rect().width();

    if (_fixleft) {
      setPos(P1);
      setViewRect(0, -height, width, height);
    } else {
      setPos(P2);
      setViewRect(-width, -height, width, height);
    }
    QTransform transform;
    transform.rotateRadians(theta);

    setTransform(transform);
    updateRelativeSize();

  } else {
    qDebug() << "apply data locked dimensions called without a render item (!)";
  }
}
Пример #30
0
float Rectangle::Pdf(const Point &p, const Vector &wi) const
{
    // Intersect sample ray with area light geometry
    DifferentialGeometry dgLight;
    Ray ray(p, wi, 1e-3f);
    ray.depth = -1; // temporary hack to ignore alpha mask
    float thit, rayEpsilon;
    if (!Intersect(ray, &thit, &rayEpsilon, &dgLight)) return 0.;

    float pdf;
    Point pObject = (*WorldToObject)(p);

    // TODO: Check with the normal (n.p)
    if (!(pObject.x < x/2 && pObject.x > -x/2
            && pObject.y < y/2 && pObject.y > -y/2))
        return 0;

    // N & wi
    Point P0(-x/2, y/2, height);
    Point P1(x/2, y/2, height);
    Point P2(-x/2, -y/2, height);

    Point P0_W = (*WorldToObject)(P0);
    Point P1_W = (*WorldToObject)(P1);
    Point P2_W = (*WorldToObject)(P2);


    Normal n = Normal(Cross(P2_W-P0_W, P1_W-P0_W));
    Normal Ns = Normalize(n);

    Normal Nwi(wi.x, wi.y, wi.z);

    if (Dot(Ns,  Nwi) < 0.0010)
        pdf = 1.0;

    if (isinf(pdf)) pdf = 0.f;
        return pdf;
}