示例#1
0
Vector6F resolveTorsoAcceleration()
{
	Vector6F desired_torso_acceleration = Vector6F::Zero();
	// Desired torso position and orientation (ICS)
	Vector6F poseError;

	Vector3F ref_torso_p_ICS;
	Matrix3F ref_torso_R_ICS;
	Vector3F ref_torso_R_ICS_c1, ref_torso_R_ICS_c2, ref_torso_R_ICS_c3;// columns of ref_torso_R_ICS
	Vector3F c1,c2,c3;

	//ref_torso_p_ICS<< 3.0, 5.08, 0.46;

	//ref_torso_R_ICS_c1 << 0, 0, 1;
	//ref_torso_R_ICS_c2 << 1, 0, 0;
	//ref_torso_R_ICS_c3 << 0, 1, 0; //upright

	ref_torso_p_ICS = popTorsoPositionSetPoint();
	ref_torso_R_ICS = popTorsoOrientationSetPoint();
	ref_torso_R_ICS_c1 = ref_torso_R_ICS.block(0,0,3,1);
	ref_torso_R_ICS_c2 = ref_torso_R_ICS.block(0,1,3,1);
	ref_torso_R_ICS_c3 = ref_torso_R_ICS.block(0,2,3,1);


	poseError(3) = ref_torso_p_ICS[0] - G_robot_linkinfo_list[2]->link_val2.p_ICS[0];
	poseError(4) = ref_torso_p_ICS[1] - G_robot_linkinfo_list[2]->link_val2.p_ICS[1];
	poseError(5) = ref_torso_p_ICS[2] - G_robot_linkinfo_list[2]->link_val2.p_ICS[2];

	for (int g = 0; g<3;g++)
	{
		c1(g) = G_robot_linkinfo_list[2]->link_val2.R_ICS[g][0];
		c2(g) = G_robot_linkinfo_list[2]->link_val2.R_ICS[g][1];
		c3(g) = G_robot_linkinfo_list[2]->link_val2.R_ICS[g][2];
	}

	Matrix6F XI2 = G_robot->computeSpatialTransformation(2);
	poseError.head(3) = XI2.block(0,0,3,3) * (0.5*(cr3(c1)* ref_torso_R_ICS_c1 + cr3(c2)* ref_torso_R_ICS_c2 + cr3(c3)* ref_torso_R_ICS_c3)); // there is a bias... lwp
	poseError.tail(3) = XI2.block(0,0,3,3)* poseError.tail(3); //in torso coordinate

	Float kp, kd;// PD gain
	kd = 15;
	kp = 100;  //
	desired_torso_acceleration(2) = 0.02*kp * poseError(2) + 0.02*kd * ( - TorsoVel_curr(2)); // soft gain on torso pitch
	desired_torso_acceleration(3) = 0.8*kp * poseError(3) +  0.8*kd * ( - TorsoVel_curr(3));
	desired_torso_acceleration(4) = 0.5*kp * poseError(4) + 0.5*kd * ( - TorsoVel_curr(4));

	#ifdef BIPED_DEBUG
	cout<<"desired spatial torso acceleration is: "<<endl<<desired_torso_acceleration<<endl<<endl;
	#endif
	return desired_torso_acceleration;
}
示例#2
0
void Plotter::doPaint(QPainter &painter)
{
    QColor c1(127, 0, 0);
    QColor c2(0, 127, 0);
    QColor c3(0, 0, 127);
    QPen p(c1);
    p.setWidth(2);
    painter.setPen(p);

    QPainterPath path_sign;
    QPainterPath path_res;

    //////////////////////////////////
    door_.setMainData(E_, tlim_);
    //////////////////////////////////

    //for rand()
    QTime time = QTime::currentTime();
    qsrand((uint)time.msec());

    //for signal
    QPointF p_sign;
    float sig_end = 6*M_PI;
    float sig_count = width()/2;
    float sig_step = sig_end/sig_count;
    float count = 0;

    for (float i=sig_step; i<sig_end; i+=sig_step) {
        int k = randInt(noise_,-1*noise_);

        //drawing signal
        p_sign.setX(count++);
        p_sign.setY(MyFunc(i)+k);
        path_sign.lineTo(p_sign);

        door_.hadlePoint(p_sign);
        if (door_.storePointChanged()) {
            path_res.lineTo(door_.getLastStoredPoint());
            painter.drawPoint(door_.getLastStoredPoint());
        }
    }

    p.setColor(c2);
    p.setWidth(0.5);
    painter.setPen(p);
    painter.drawPath(path_sign);
    p.setColor(c3);
    p.setWidth(0.5);
    painter.setPen(p);
    painter.drawPath(path_res);
}
示例#3
0
void TestSorterOwnerContainer::singleNode()
{
	csjp::Object<Char> ch(NULL);

	CharContainer c1, c2;

	c1.add(new Char('s'));

	VERIFY(c1.size() == 1);
	VERIFY(c1.empty() == false);

	IN_SAFEMODE(c1.validity());

	VERIFY(c1 != c2);

	VERIFY(c1.has(Char('s')));

	VERIFY(c1.index(Char('s')) == 0);

	VERIFY(c1.queryAt((unsigned)0) == Char('s'));

	/* assignement */
	c2 = c1;

	VERIFY(c1 == c2);

	IN_SAFEMODE(c2.validity());

	/* remove */
	c2.removeAt(0);

	VERIFY(c2.size() == 0);
	VERIFY(c2.empty() == true);

	IN_SAFEMODE(c2.validity());

	/* copy constructing */
	CharContainer c3(c1);

	VERIFY(c1 == c3);

	IN_SAFEMODE(c3.validity());

	/* clear */
	c3.clear();

	VERIFY(c3.size() == 0);
	VERIFY(c3.empty() == true);

	IN_SAFEMODE(c3.validity());
}
示例#4
0
void Chaser_Test::copyFrom()
{
	Chaser c1(m_doc);
	c1.setName("First");
	c1.setDirection(Chaser::Backward);
	c1.setRunOrder(Chaser::PingPong);
	c1.setBus(15);
	c1.addStep(2);
	c1.addStep(0);
	c1.addStep(1);
	c1.addStep(25);

	/* Verify that chaser contents are copied */
	Chaser c2(m_doc);
	QVERIFY(c2.copyFrom(&c1) == true);
	QVERIFY(c2.name() == "First");
	QVERIFY(c2.busID() == 15);
	QVERIFY(c2.direction() == Chaser::Backward);
	QVERIFY(c2.runOrder() == Chaser::PingPong);
	QVERIFY(c2.steps().size() == 4);
	QVERIFY(c2.steps().at(0) == 2);
	QVERIFY(c2.steps().at(1) == 0);
	QVERIFY(c2.steps().at(2) == 1);
	QVERIFY(c2.steps().at(3) == 25);

	/* Verify that a Chaser gets a copy only from another Chaser */
	Scene s(m_doc);
	QVERIFY(c2.copyFrom(&s) == false);

	/* Make a third Chaser */
	Chaser c3(m_doc);
	c3.setName("Third");
	c3.setBus(8);
	c3.setDirection(Chaser::Forward);
	c3.setRunOrder(Chaser::Loop);
	c3.addStep(15);
	c3.addStep(94);
	c3.addStep(3);

	/* Verify that copying TO the same Chaser a second time succeeds and
	   that steps are not appended but replaced completely. */
	QVERIFY(c2.copyFrom(&c3) == true);
	QVERIFY(c2.name() == "Third");
	QVERIFY(c2.busID() == 8);
	QVERIFY(c2.direction() == Chaser::Forward);
	QVERIFY(c2.runOrder() == Chaser::Loop);
	QVERIFY(c2.steps().size() == 3);
	QVERIFY(c2.steps().at(0) == 15);
	QVERIFY(c2.steps().at(1) == 94);
	QVERIFY(c2.steps().at(2) == 3);
}
TYPED_TEST(CycleSpaceTest, CycleSpace1)
{
  using Graph = TypeParam;
  Graph g;

  //        e2
  //    v0 ---- v2
  //    |  \     |
  // e3 | e0 \   | e1
  //    |      \ |
  //    v3 ---- v1
  //        e4
  //

  auto v0 = ocgl::addVertex(g);
  auto v1 = ocgl::addVertex(g);
  auto v2 = ocgl::addVertex(g);
  auto v3 = ocgl::addVertex(g);

  auto e0 = ocgl::addEdge(g, v0, v1);
  auto e1 = ocgl::addEdge(g, v1, v2);
  auto e2 = ocgl::addEdge(g, v2, v0);
  auto e3 = ocgl::addEdge(g, v0, v3);
  auto e4 = ocgl::addEdge(g, v3, v1);

  ocgl::EdgeCycle<Graph> c1({e0, e1, e2});
  ocgl::EdgeCycle<Graph> c2({e0, e3, e4});
  ocgl::EdgeCycle<Graph> c3({e1, e2, e3, e4});

  ocgl::CycleSpace<Graph> sp(g);

  EXPECT_FALSE(sp.containsEdgeCycle(c1));
  EXPECT_FALSE(sp.containsEdgeCycle(c2));
  EXPECT_FALSE(sp.containsEdgeCycle(c3));
  EXPECT_FALSE(sp.isBasis());

  sp.addEdgeCycle(c1);

  EXPECT_TRUE(sp.containsEdgeCycle(c1));
  EXPECT_FALSE(sp.containsEdgeCycle(c2));
  EXPECT_FALSE(sp.containsEdgeCycle(c3));
  EXPECT_FALSE(sp.isBasis());

  sp.addEdgeCycle(c2);

  EXPECT_TRUE(sp.containsEdgeCycle(c1));
  EXPECT_TRUE(sp.containsEdgeCycle(c2));
  EXPECT_TRUE(sp.containsEdgeCycle(c3));
  EXPECT_TRUE(sp.isBasis());

}
示例#6
0
int main() {
  int c1res = sizeof(array);
  int c2res = c2();
  int c3res = c3();

  if(c1res != c3res) E(1);

  if(c2res != sizeof(int [10]) + sizeof(int)) E(2);

  if(var != 7) E(3);
                 
  printf("Success\n");
  return 0;
}
示例#7
0
void check_equal()
{
  bool are_equal;

  Polycurve_conic_traits_2 traits;
  Polycurve_conic_traits_2::Equal_2 equal = traits.equal_2_object();
  Polycurve_conic_traits_2::Construct_x_monotone_curve_2
    construct_x_monotone_curve_2 = traits.construct_x_monotone_curve_2_object();

  //create some curves
  Conic_point_2 ps1(Rational(1,4), 4);
  Conic_point_2 pt1(2, Rational(1,2));
  Conic_curve_2 c1(0, 0, 1, 0, 0, -1, CGAL::COUNTERCLOCKWISE, ps1, pt1);

  Conic_point_2 ps2(Rational(1,4), 4);
  Conic_point_2 pt2(2, Rational(1,2));
  Conic_curve_2 c2(0, 0, 1, 0, 0, -1, CGAL::COUNTERCLOCKWISE, ps2, pt2);

  Rat_point_2 ps3(Rational(1,4), 4);
  Rat_point_2 pmid3(Rational(3,2), 2);
  Rat_point_2 pt3(2, Rational(1,3));
  Conic_curve_2 c3(ps3, pmid3, pt3);

  Rat_point_2 ps4(1, 5);
  Rat_point_2 pmid4(Rational(3,2), 3);
  Rat_point_2 pt4(3, Rational(1,3));
  Conic_curve_2 c4(ps4, pmid4, pt4);

  // //make x_monotone
  Polycurve_conic_traits_2::X_monotone_curve_2 xmc1 =
    construct_x_monotone_curve_2(c1);
  Polycurve_conic_traits_2::X_monotone_curve_2 xmc2 =
    construct_x_monotone_curve_2(c2);
  Polycurve_conic_traits_2::X_monotone_curve_2 xmc3 =
    construct_x_monotone_curve_2(c3);
  Polycurve_conic_traits_2::X_monotone_curve_2 xmc4 =
    construct_x_monotone_curve_2(c4);

  are_equal = equal(xmc1, xmc2);
  std::cout << "Two equal conic arcs are computed as:  "
            << ((are_equal) ? "equal" : "Not equal") << std::endl;

  are_equal = equal(xmc3, xmc2);
  std::cout << "Two un-equal conic arcs are computed as:  "
            << ((are_equal) ? "equal" : "Not equal") << std::endl;

  are_equal = equal(xmc3, xmc4);
  std::cout << "Two un-equal conic arcs are computed as:  "
            << ((are_equal) ? "equal" : "Not equal") << std::endl;
 }
示例#8
0
    void createCategory()
    {
        Category c1 (AUDIO);
        Category c2 (VIDEO,"bin1");
        Category c3 (VIDEO,"bin1/subbin");
        Category c4 (EFFECT,"some_kind");

        _Fmt fmt ("Category: %s");

        cout << fmt % c1 << "\n";
        cout << fmt % c2 << "\n";
        cout << fmt % c3 << "\n";
        cout << fmt % c4 << "\n";
    }
示例#9
0
a2de::Matrix3x3 Matrix3x3::operator*(const Matrix3x3& rhs) {

    a2de::Vector3D r1(this->GetRowOne());
    a2de::Vector3D r2(this->GetRowTwo());
    a2de::Vector3D r3(this->GetRowThree());

    a2de::Vector3D c1(rhs.GetColumnOne());
    a2de::Vector3D c2(rhs.GetColumnTwo());
    a2de::Vector3D c3(rhs.GetColumnThree());

    return Matrix3x3(a2de::Vector3D::DotProduct(r1, c1), a2de::Vector3D::DotProduct(r1, c2), a2de::Vector3D::DotProduct(r1, c3),
                     a2de::Vector3D::DotProduct(r2, c1), a2de::Vector3D::DotProduct(r2, c2), a2de::Vector3D::DotProduct(r2, c3),
                     a2de::Vector3D::DotProduct(r3, c1), a2de::Vector3D::DotProduct(r3, c2), a2de::Vector3D::DotProduct(r3, c3));
}
示例#10
0
 double ColorPairDescriptor::distanceTo(const Descriptor &d) const
 {
   NUKLEI_TRACE_BEGIN();
   const ColorDescriptor* cd = dynamic_cast<const ColorDescriptor*>(&d);
   if (cd != NULL)
   {
     HSVConeColor c1(getLeftColor());
     HSVConeColor c2(getRightColor());
     HSVConeColor c3(cd->getColor());
     return std::min(c1.distanceTo(c3),
                     c2.distanceTo(c3));
   }
   NUKLEI_THROW("Not implemented.");
   NUKLEI_TRACE_END();
 }
示例#11
0
int main()
{
    {
        typedef int T;
        typedef std::forward_list<T> C;
        const T t1[] = {13, 12, 7, 6, 5, 3};
        const T t2[] = {15, 14, 11, 10, 9, 8, 4, 2, 1, 0};
        const T t3[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
        C c1(std::begin(t1), std::end(t1));
        C c2(std::begin(t2), std::end(t2));
        c1.merge(c2, std::greater<T>());
        C c3(std::begin(t3), std::end(t3));
        assert(c1 == c3);
    }
}
void
test()
{
    std::complex<T> c;
    assert(c.real() == 0);
    assert(c.imag() == 0);
    std::complex<T> c2(1.5, 2.5);
    c = c2;
    assert(c.real() == 1.5);
    assert(c.imag() == 2.5);
    std::complex<X> c3(3.5, -4.5);
    c = c3;
    assert(c.real() == 3.5);
    assert(c.imag() == -4.5);
}
示例#13
0
TEST_F(HashTableTest, TestMapRehashWithObjects)
{
    capu::HashTable<SomeClass, capu::uint32_t> table(2);
    SomeClass c1(1);
    SomeClass c2(2);
    SomeClass c3(3);
    SomeClass c4(4);

    table.put(c1, 1);
    table.put(c2, 2);
    table.put(c3, 3);
    table.put(c4, 4); // rehashing

    SomeClass cTest(3); // same i value as c3 -> 3 must get returned
    EXPECT_EQ(3u, table.at(cTest));
}
示例#14
0
/**
	TestRgb::TestComp
	Test operator overrides for TRgb class
*/
void TestRgb::TestComp()
	{
	TRgb c1(iR,iG,iB);
	TRgb c2(iR,iG,iB);
	TRgb c3(255-iR,iG,iB);
	iTest->TEST(c1==c2);
	iTest->TEST(c1!=c3);
	iTest->TEST(c2!=c3);
	iTest->TEST(c1==c2);
	c1&=c3;
	iTest->TEST(c1==TRgb(0,iG,iB));
	c2|=c3;
	iTest->TEST(c2==TRgb(255,iG,iB));
	c1^=c2;
	iTest->TEST(c1==TRgb(255,0,0));
	}
示例#15
0
bool Service::LoadConfig( ConfigBase &config )
{
  config.ReadConfig( "ServiceID", service_id );
  config.ReadConfig( "PID", pid );
  config.ReadConfig( "Type", (int &) type );
  std::string t;
  config.ReadConfig( "Name", t );
  SetName( t );
  config.ReadConfig( "Provider", provider );
  int channel_id;
  config.ReadConfig( "Channel", channel_id );
  if( channel_id != -1 )
  {
    channel = TVDaemon::Instance( )->GetChannel( channel_id );
    if( channel )
    {
      channel->AddService( this );
      transponder.HasChannels( true );
    }
    else
    {
      LogError( "Service '%s': channel %d not found", name.c_str( ), channel_id );
      channel_id == -1;
    }
  }

  Setting &n = config.ConfigList( "Streams" );
  for( int i = 0; i < n.getLength( ); i++ )
  {
    ConfigBase c2( n[i] );
    Stream *s = new Stream( *this );
    s->LoadConfig( c2 );
    streams[s->GetKey( )] = s;
  }

  Setting &n2 = config.ConfigList( "CA" );
  for( int i = 0; i < n2.getLength( ); i++ )
  {
    ConfigBase c3( n2[i] );
    uint16_t ca_id, ca_pid;
    c3.ReadConfig( "CA_id", ca_id );
    c3.ReadConfig( "CA_pid", ca_pid );
    SetCA(ca_id, ca_pid);
  }

  return true;
}
示例#16
0
int main(int argc, char * argv[]){
	Triangle t1(3,3,3,1,1);
	Square s1(6,2,2);
	Circle c1(7,3,3);
	Sphere sp1(10,4,4,4);
	Cube cu1(10,5,5,5);
	Tetrahedron te1(5,6,7,8,9,10,6,6,6);
	Cube cu2(5,7,7,7);
	Square s2(16,8,8);
	Circle c2(1,9,9);
	Circle c3(55,10,10);
	Square s3(3,11,11);
	Tetrahedron te2(3,3,3,3,3,3,12,12,12);
	
	Shape * arr = new Shape[12];
	arr[0] = t1;
	arr[1] = s1;
	arr[2] = c1;
	arr[3] = sp1;
	arr[4] = cu1;
	arr[5] = te1;
	arr[6] = cu2;
	arr[7] = s2;
	arr[8] = c2;
	arr[9] = c3;
	arr[10] = s3;
	arr[11] = te2;

	for(int i = 0; i < 11; ++i){
		cout << endl;
		if(arr[i].getT() == 2){
			cout << "2-D Shape Found" << endl;
			cout << "Points are: (" << arr[i].getX() << ", " << arr[i].getY() << ")" << endl;
			cout << "Area is: " << arr[i].getArea() << endl;
		}
		else{
			cout << "3-D Shape" << endl;
			cout << "At Pt: (" << arr[i].getX() << ", " << arr[i].getY() << ", " << arr[i].getZ() <<")" << endl;
			cout << "Surface Area is: " << arr[i].getSurface() << endl;
			cout << "Volume is: " << arr[i].getVolume() << endl;
		}
	}

	delete[] arr;

	return 0;
}
示例#17
0
int main(void){
	std::cout << "HI" << std::endl;
	Complex c1(1,2), c2(3,1), c3(4,2), c4(2,2);
	std::vector<Complex> coeff;
	coeff.push_back(c1); coeff.push_back(c2); coeff.push_back(c3);
	ComplexPoly poly(coeff, 2);
	Complex res = poly.evaluate(c4);
	std::cout << res << std::endl;
	
	Complex c5(2,3), c6(3,4), c7(8,2);
	Complex data[3] = {c5,c6,c7};
	ComplexPoly cp(data, 2);
	Complex result = cp.evaluate(c4);
	std::cout << result << std::endl;
	std::cout << cp << std::endl;
	return 0;
}
示例#18
0
int main( int argc, char *argv[] )
 {
  // Here is how to initialize color from constant lavander
  ::color::rgb<::color::type::split422_t>   c1( ::color::constant::lavender_type{} );
  ::color::rgb<::color::type::split655_t >  c2( ::color::constant::lavender_type{} );
  ::color::rgb<std::uint8_t>                c3( ::color::constant::lavender_type{} );
  ::color::rgb<std::uint64_t>               c4( ::color::constant::lavender_type{} );
  ::color::rgb<float>                       c5( ::color::constant::lavender_type{} );

  std::cout << c1[0] << ", " << c1[1] << ", " << c1[2] << std::endl;
  std::cout << c2[0] << ", " << c2[1] << ", " << c2[2] << std::endl;
  std::cout << c3[0] << ", " << c3[1] << ", " << c3[2] << std::endl;
  std::cout << c4[0] << ", " << c4[1] << ", " << c4[2] << std::endl;
  std::cout << c5[0] << ", " << c5[1] << ", " << c5[2] << std::endl;

  return EXIT_SUCCESS;
 }
int main(){
    BoundedBuffer buffer(200);

    std::thread c1(consumer, 0, std::ref(buffer));
    std::thread c2(consumer, 1, std::ref(buffer));
    std::thread c3(consumer, 2, std::ref(buffer));
    std::thread p1(producer, 0, std::ref(buffer));
    std::thread p2(producer, 1, std::ref(buffer));

    c1.join();
    c2.join();
    c3.join();
    p1.join();
    p2.join();

    return 0;
}
示例#20
0
    void containmentQuery()
    {
        Category c1 (VIDEO);
        Category c2 (VIDEO,"bin1");
        Category c3 (VIDEO,"bin1/subbin");
        Category c4 (EFFECT,"some_kind");

        CHECK ( c1.hasKind(VIDEO) );
        CHECK (!c1.hasKind(AUDIO) );
        CHECK ( c2.isWithin(c1) );
        CHECK ( c3.isWithin(c2) );
        CHECK ( c3.isWithin(c1) );
        CHECK (!c1.isWithin(c2) );
        CHECK (!c2.isWithin(c3) );
        CHECK (!c1.isWithin(c3) );
        CHECK (!c3.isWithin(c4) );
        CHECK (!c4.isWithin(c3) );
    }
示例#21
0
文件: list_rgb.cpp 项目: dmilos/color
int main( int argc, char *argv[] )
 {
  ::color::rgb<::color::type::split422_t>   c1( { 7, 6 , 3} );
  ::color::rgb<::color::type::split655_t >  c2( { 6, 12 , 19} );
  ::color::rgb<std::uint8_t>                c3( { 64, 127 , 192 } );
  ::color::rgb<std::uint64_t>               c4( { 64000, 1270 , 1920 } );
  ::color::rgb<float>                       c5( { 0.5, 0.6, 0.7} );
  ::color::rgb<double>                      c6( { 0.5, 0.6, 0.7} );

  std::cout << c1[0] << ", " << c1[1] << ", " << c1[2] << std::endl;
  std::cout << c2[0] << ", " << c2[1] << ", " << c2[2] << std::endl;
  std::cout << c3[0] << ", " << c3[1] << ", " << c3[2] << std::endl;
  std::cout << c4[0] << ", " << c4[1] << ", " << c4[2] << std::endl;
  std::cout << c5[0] << ", " << c5[1] << ", " << c5[2] << std::endl;
  std::cout << c6[0] << ", " << c6[1] << ", " << c6[2] << std::endl;

  return EXIT_SUCCESS;
 }
示例#22
0
文件: list_cmy.cpp 项目: dmilos/color
int main( int argc, char *argv[] )
 {
  ::color::cmy<std::uint8_t>     c1( { 64, 127 , 192 } );
  ::color::cmy<std::uint16_t>    c2( { 280, 350 , 1000 } );
  ::color::cmy<std::uint32_t>    c3( { 640, 127 , 192 } );
  ::color::cmy<std::uint64_t>    c4( { 64000, 1270 , 1920 } );
  ::color::cmy<float>            c5( { 0.5, 0.6, 0.7} );
  ::color::cmy<double>           c6( { 0.5, 0.6, 0.7} );

  std::cout << c1[0] << ", " << c1[1] << ", " << c1[2] << std::endl;
  std::cout << c2[0] << ", " << c2[1] << ", " << c2[2] << std::endl;
  std::cout << c3[0] << ", " << c3[1] << ", " << c3[2] << std::endl;
  std::cout << c4[0] << ", " << c4[1] << ", " << c4[2] << std::endl;
  std::cout << c5[0] << ", " << c5[1] << ", " << c5[2] << std::endl;
  std::cout << c6[0] << ", " << c6[1] << ", " << c6[2] << std::endl;

  return EXIT_SUCCESS;
 }
示例#23
0
void object::test<2>()
{
    Coordinate c1(1.0000000000004998, -7.989685402102996);
    Coordinate c2(10.0, -7.004368924503866);
    Coordinate c3(1.0000000000005, -7.989685402102996);

    CoordinateArraySequence pts;
    pts.add(c1);
    pts.add(c2);
    pts.add(c3);

    int const a = CGAlgorithms::computeOrientation(pts[0], pts[1], pts[2]);
    int const b = CGAlgorithms::computeOrientation(pts[0], pts[1], pts[2]);
    int const c = CGAlgorithms::computeOrientation(pts[0], pts[1], pts[2]);

    ensure_equals( a, b );
    ensure_equals( a, c );
}
示例#24
0
文件: Main.cpp 项目: bseznec/TP4INFO
/**
* \fn main
* \brief fonction main permettant de creer les chaines et de tester les fonctions
*
*/
int main (int agc, char* argv[]){
	printf("Debut de la fonction main\n");

	// Creation de tableaux de caractères

	char test[] = "test test";
	char test2[] = "test";
	char test3[] = "ananas";
	char test4[] = "hello world";
	char c = 's';

	// creation de chaines de caractères avec les différents constructeurs
	Chaine c1;
	Chaine c2(test);
	Chaine c3(c2);
	Chaine c4(test2);
	Chaine c5(test3);
	Chaine c6(test4);

	// test des fonctions de chaine.cpp
	c1.afficherChaine(); // empty chaine
	c2.afficherChaine(); // "test test"
	c3.afficherChaine(); // test test"
	cout << (c1 == c3) <<endl;  // false
	cout << (c2 == c3) <<endl;  // true 
	cout << (c4 == c3) <<endl;  // false
	cout << (c4 > c5) <<endl;   // true
	cout << (c4 < c5) <<endl;   // false
	cout << (c5 < c4) <<endl;   // true

	(c4+c5).afficherChaine(); // "testananas"
	(c2 += c5).afficherChaine(); // c2 : "test testananas"
	c2.afficherChaine(); // "test testananas"

	cout << "Indexe du caractere s dans la chaine ";
	c5.afficherChaine();  // "ananas"
	cout << " : " ;
	cout << c5.index_char(c) <<endl; // the first occurence of s is at the position 6

	c6.sous_chaine(6,10).afficherChaine(); // "word"

	printf("fin du main\n");

}
示例#25
0
void renderPolygons(void) {
	// set clearing color 
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glClear(GL_COLOR_BUFFER_BIT);

	// first polygon - triangle - yellow
	Point c1(100,50,0);
	Color fc1(1.0, 1.0, 0.0, 0.0);
	Polygon tri(40, c1, 3, 1, GL_LINE_LOOP, fc1);
	tri.draw();

	// square - hollow - light blue(cyan)
	Point c2(100,150,0);
	Color fc2(0.0, 1.0, 1.0, 0.0);
	Polygon squ(40, c2, 4, 8, GL_LINE_LOOP, fc2);
	squ.draw();

	// pentagon - hollow - gray
	Point c3(100,250,0);
	Color fc3(0.5, 0.5, 0.5, 0.0);
	Polygon pent(40, c3, 5, 3, GL_LINE_LOOP, fc3);
	pent.draw();

	//hexagon - not hollow - red
	Point c4(200,50,0);
	Color fc4(1.0, 0.0, 0.0, 0.0);
	Polygon hex(40, c4, 6, 3, GL_POLYGON, fc4);
	hex.draw();

	// nonagon - hollow - green
	Point c5(200,150,0);
	Color fc5(0.0, 1.0, 0.0, 0.0);
	Polygon nin(40, c5, 9, 5, GL_LINE_LOOP, fc5);
	nin.draw();

	// tridecagon - hollow - purple
	Point c6(300,300,0);
	Color fc6(1.0, 0.0, 1.0, 0.0);
	Polygon thri(90, c6, 13, 3, GL_LINE_LOOP, fc6);
	thri.draw();

	glutSwapBuffers();
}
示例#26
0
mycomplex Expression::Compute2(vector<string>& vec, string& str)
{
	stack<string> s;
	for(int i = 0; i != vec.size(); ++i)
	{
		if(vec[i].size() == 3)
		{
			s.push(vec[i]);
		} else
		{
			mycomplex c1 = m_mapComplex[s.top()];
			s.pop();
			mycomplex c2 = m_mapComplex[s.top()];
			s.pop();
			mycomplex c3(0, 0);
			switch(vec[i][0])
			{
			case '+':
				c3 = c1+c2;
				break;
			case '-':
				c3 = c2-c1;
				break;
			case '*':
				c3 = c1*c2;
				break;
			case '/':
				c3 = c2/c1;
				break;
			}

			s.push(AddMapComplexMember(c3));

		}
	}
	mycomplex result = m_mapComplex[s.top()];
	s.pop();
	if(!s.empty())
	{
		str = "error";
	}
	return result; 
}
示例#27
0
/**
@SYMTestCaseID          SYSLIB-DBMS-CT-0586
@SYMTestCaseDesc        Tests for TDbCol class
@SYMTestPriority        Medium
@SYMTestActions        	Tests for column name and type after creating them.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void TestTDbCol()
	{
	test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0586 Testing TDbCol "));
	TDbCol c1(KColName,EDbColText8);
	test(c1.iName==KColName);
	test(c1.iType==EDbColText8);
	test(c1.iMaxLength==KDbDefaultTextColLength);
	test(c1.iAttributes==0);
	TDbCol c2(KColName,EDbColText8,1234);
	test(c2.iName==KColName);
	test(c2.iType==EDbColText8);
	test(c2.iMaxLength==1234);
	test(c2.iAttributes==0);
	TDbCol c3(KColName,EDbColBit);
	test(c3.iName==KColName);
	test(c3.iType==EDbColBit);
	test(c3.iMaxLength==KDbUndefinedLength);
	test(c3.iAttributes==0);
	}
示例#28
0
SE_Spatial* SE_ElementManager::createSpatial()
{
    if(!mRoot)
        return NULL;
    SE_Spatial* spatial = mRoot->createSpatial(NULL);
    spatial->setLocalTranslate(SE_Vector3f(0, 0, 0));
    spatial->setLocalScale(SE_Vector3f(1, 1, 1));
    SE_Vector4f c1(1, 0, 0, 0);
    SE_Vector4f c2(0, -1, 0, 0);
    SE_Vector4f c3(0, 0, 1, 0);
    SE_Vector4f c4(-mRoot->getWidth() / 2, mRoot->getHeight() / 2, 0, 1);
    SE_Matrix4f localM;
    localM.setColumn(0, c1);
    localM.setColumn(1, c2);
    localM.setColumn(2, c3);
    localM.setColumn(3, c4);
    spatial->setPostMatrix(localM);
    return spatial;
}
示例#29
0
int main(int argc, char* argv[]) {

		Complex c1;
		std::cout << "c1: " << c1 << std::endl;

		Complex c2(42.f, 23.f);
		std::cout << "c2: " << c2 << std::endl;
		
		Complex c3(10.f);
		std::cout << "c3: " << c3 << std::endl;
		
		// won't work (explicit constructor!)
		//Complex c4 = 1.f;
		//std::cout << "c4: " << c4 << std::endl;

		std::cout << c1 << " -> " << ++c1 << std::endl;
		// wtf??std::cout << c1 << " -> " << c1++ << std::endl;
		++c1;
}
示例#30
0
    void constraints() {
      function_requires< AssociativeContainerConcept<SortedAssociativeContainer> >();
      function_requires< ReversibleContainerConcept<SortedAssociativeContainer> >();

      SortedAssociativeContainer 
        c(kc),
        c2(first, last),
        c3(first, last, kc);

      p = c.upper_bound(k);
      p = c.lower_bound(k);
      r = c.equal_range(k);
      
      c.insert(p, t);
      
      ignore_unused_variable_warning(c);
      ignore_unused_variable_warning(c2);
      ignore_unused_variable_warning(c3);
    }