Esempio n. 1
0
std::vector<LineSegment> makeRay(const Ray& ray, float t)
{
  std::vector<LineSegment> result;
  Math::Vector3 endPoint = ray.mStart + (ray.mDirection * t);
  const float goldenRatio = 1.61803398875f;
  
  Math::Vector3 right;
  Math::Vector3 up;
  Math::GenerateOrthonormalBasis(ray.mDirection, &up, &right);

  Math::Vector3 circleCenter = endPoint - ray.mDirection * goldenRatio * goldenRatio * 0.2f;
  float radius = 0.5f * goldenRatio * 0.2f;


  result = makeCircle(circleCenter, ray.mDirection, radius);

  //connecting segments

  result.push_back(LineSegment(circleCenter + right * radius, endPoint));
  result.push_back(LineSegment(circleCenter - right * radius, endPoint));
  result.push_back(LineSegment(circleCenter + up * radius, endPoint));
  result.push_back(LineSegment(circleCenter - up * radius, endPoint));

  result.push_back(LineSegment(ray.mStart, endPoint));

  return result;
}
Esempio n. 2
0
b2Body* makeAxle(b2World* world, b2Body* base, xform_t xform)
{
    // creates a small square axle body and a revolute joint centered at the anchor
    b2Body * axle = makeDynamicBody(world, xform);
    b2CircleShape shape = makeCircle(.04);
    makeFixture(axle, &shape);
    makeRevoluteJoint(world, base, axle, b2Vec2(xform.x, xform.y));
    return axle;
}
Esempio n. 3
0
		void makeBoard(){
			    // draw outer board
				glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
				glColor3ub( 89, 62, 26);
				glRectf(-0.990f,0.990f, 0.990f, -0.990f);

			    //draw inner board
			    if(friction == 0)
					glColor3ub(210, 180, 140);
				else if(friction == 1)
					glColor3ub(182, 153, 117);
				else if(friction == 2)
					glColor3ub(128, 128, 0);
				glRectf(-innerBoard,innerBoard, innerBoard, -innerBoard);
			    //draw red inner lines
			    glColor3ub( 105 ,38,28 );
			    glBegin(GL_LINE_LOOP);
			    glVertex2f( -redBoard, redBoard );
			    glVertex2f( -redBoard, -redBoard );
			    glVertex2f( redBoard, -redBoard );
			    glVertex2f( redBoard, redBoard );
			    glEnd();

			    //draw red inner cirlces
			    makeEmptyCircle(-redCirclePos,redCircleRad,redCirclePos);
			    makeEmptyCircle(redCirclePos,redCircleRad,-redCirclePos);
			    makeEmptyCircle(redCirclePos,redCircleRad,redCirclePos);
			    makeEmptyCircle(-redCirclePos,redCircleRad,-redCirclePos);

			    //draw red center design
			    makeEmptyCircle(0,innerCircle,0);
			    makeEmptyCircle(0,innerCircle/4,0);
			    makeEmptyCircle(0,innerCircle/2,0);
			    makeEmptyCircle(0,3*innerCircle/4,0);

			    //draw pockets
			    glColor3f(0.5f, 0.5f, 0.5f);
			    makeCircle(-pocketPos,pocketCircle,pocketPos);
			    makeCircle(pocketPos,pocketCircle,-pocketPos);
			    makeCircle(pocketPos,pocketCircle,pocketPos);
			    makeCircle(-pocketPos,pocketCircle,-pocketPos);
		}
Esempio n. 4
0
void generateCone(GLuint program, ShapeData* coneData) {
    
    vec2 circlePoints[numConeDivisions];
    makeCircle(circlePoints, numConeDivisions);
    int Index = 0;
    makeCircleWall(coneData->points, coneData->normals, numConeDivisions, 1.0f, 1.0f, Index, 1);
    makeCircleWall(coneData->points, coneData->normals, numConeDivisions, 1.0f, -1.0f, Index, -1);
    
    // Create a vertex array object
    coneData->bind(program);
}
Esempio n. 5
0
DebugShape& DebugDrawer::DrawSphere(const Sphere& sphere)
{
  // To access the camera's position for the horizon disc calculation use mApplication->mCamera.mTranslation
  DebugShape& shape = GetNewShape();
  int it;

  std::vector<LineSegment> segments[4];

  segments[0] = makeCircle(sphere.mCenter, Math::Vector3(1.0f, 0.0f, 0.0f), sphere.mRadius);

  
  segments[1] = makeCircle(sphere.mCenter, Math::Vector3(0.0f, 1.0f, 0.0f), sphere.mRadius);


  segments[2] = makeCircle(sphere.mCenter, Math::Vector3(0.0f, 0.0f, 1.0f), sphere.mRadius);

  if(mApplication)
  {
    //horizon circle
    Math::Vector3 dVec = sphere.mCenter - mApplication->mCamera.mTranslation;
    Math::Vector3 dVecNorm = dVec.Normalized();
    float radSquared = sphere.mRadius * sphere.mRadius;
    float lLen = Math::Sqrt(dVec.LengthSq() - radSquared);
    float rPrime = (sphere.mRadius * lLen) / dVec.Length();
    float z = radSquared - (rPrime * rPrime);
    Math::Vector3 newCenter = mApplication->mCamera.mTranslation + (dVec - (dVecNorm * z));
    segments[3] = makeCircle(newCenter, dVecNorm, rPrime);
  }
  
  
  

  for(int i = 0; i < 4; ++i)
  {
    shape.mSegments.insert(shape.mSegments.end(), segments[i].begin(), segments[i].end());
  }

  return shape;
}
int main(){
	initializePrinter();
	drawCanvas(0,0,0,255);
	int x,y;
	y = getYRes()/2;
	x = getXRes()/2;
	circle C = makeCircle(0,0,0,255,20,x,y);
	for (i=0;i<=360;i++) {
		rotateCircle(C,i,x,y);
		drawCircle(C);
	}
	printToScreen();
	finishPrinter();
}
Esempio n. 7
0
		void displayCoinDock()
		{
			//Display the coins on the side of the board. You have to know what you hit in!;
			float y = 0;
			y = -innerBoard - 0.05;
			float coinRad = 0.035;
			float x = -0.8;
			for (int i = 0; i < blackHitIn; ++i)
			{
				glColor3ub(0,0,0);
				makeCircle(x+i*0.08,coinRad,y);
			}
			for (int i = 0; i < whiteHitIn; ++i)
			{
				glColor3ub(255,255,255);
				makeCircle(x+(i+blackHitIn)*0.08,coinRad,y);
			}
			for (int i = 0; i < redHitIn; ++i)
			{
				 glColor3ub( 105 ,38,28 );
				makeCircle(x+(i+whiteHitIn + blackHitIn)*0.08,coinRad,y);
			}
		}
Esempio n. 8
0
void makeCircleWall(vec4* destp, vec3* destn, float radius, const int numDivisions, float z1, float z2, int& Index, int dir) {
    vec2* circlePoints = (vec2*)malloc(sizeof(vec2) * numDivisions);
    makeCircle(circlePoints, numDivisions);
    for (int i = 0; i < numDivisions; i++) {
        vec3 p1(radius*circlePoints[i].x, radius*circlePoints[i].y, z1);
        vec3 p2(0.0f, 0.0f, z2);
        vec3 p3(radius*circlePoints[(i+1)%numDivisions].x, radius*circlePoints[(i+1)%numDivisions].y, z1);
        if (dir == -1) {
            vec3 temp = p1;
            p1 = p3;
            p3 = temp;
        }
        vec3 n = cross(p1-p2, p3-p2);
        destp[Index] = p1; destn[Index] = n; Index++;
        destp[Index] = p2; destn[Index] = n; Index++;
        destp[Index] = p3; destn[Index] = n; Index++;
    }
    delete circlePoints;
}
Esempio n. 9
0
void generateCone(GLuint program, ShapeData* coneData)
{
    makeCircle(circlePoints, numConeDivisions);
    int Index = 0;
    makeConeWall(conePoints, coneNormals, numConeDivisions, 1.0f, 1.0f, Index, 1);
    makeConeWall(conePoints, coneNormals, numConeDivisions, 1.0f, -1.0f, Index, -1);
    
    coneData->numVertices = numConeVertices;

    // Create a vertex array object
    glGenVertexArrays( 1, &coneData->vao );
    glBindVertexArray( coneData->vao );
    
    // Set vertex attributes
    setVertexAttrib(program,
                    (float*)conePoints,  sizeof(conePoints),
                    (float*)coneNormals, sizeof(coneNormals),
                    0, 0);
}
Esempio n. 10
0
void generateCylinder(GLuint program, ShapeData* cylData) {
    int Index = 0;
    vec3 tangent = vec3(0.0f, 0.0f, 1.0f);
    vec2 circlePoints[numCylDivisions];
    makeCircle(circlePoints, numCylDivisions);
    makeCircleWall(cylData->points, cylData->normals, numCylDivisions, 1.0f, 1.0f, Index, 1);
    makeCircleWall(cylData->points, cylData->normals, numCylDivisions, -1.0f, -1.0f, Index, -1);
    
    for (int i = 0; i < numCylDivisions; i++)
    {
        int i2 = (i+1)%numCylDivisions;
        float iAngle  = ( i  / (float)numCylDivisions );
        float i2Angle = ( (i+1) / (float)numCylDivisions );
        
        vec3 p1(circlePoints[i2].x, circlePoints[i2].y, -1.0f);
        vec3 p2(circlePoints[i2].x, circlePoints[i2].y,  1.0f);
        vec3 p3(circlePoints[i].x,  circlePoints[i].y,   1.0f);
        cylData->points[Index] = p1; cylData->normals[Index] = vec3(p1.x, p1.y, 0.0f); cylData->tangents[Index] = tangent;
        cylData->UVs[Index] = vec2(i2Angle, 1); Index++;
        cylData->points[Index] = p2; cylData->normals[Index] = vec3(p2.x, p2.y, 0.0f); cylData->tangents[Index] = tangent;
        cylData->UVs[Index] = vec2(i2Angle, 0); Index++;
        cylData->points[Index] = p3; cylData->normals[Index] = vec3(p3.x, p3.y, 0.0f); cylData->tangents[Index] = tangent;
        cylData->UVs[Index] = vec2(iAngle, 0); Index++;
        
        p1 = vec3(circlePoints[i2].x, circlePoints[i2].y, -1.0f);
        p2 = vec3(circlePoints[i].x,  circlePoints[i].y,   1.0f);
        p3 = vec3(circlePoints[i].x,  circlePoints[i].y,  -1.0f);
        cylData->points[Index] = p1; cylData->normals[Index] = vec3(p1.x, p1.y, 0.0f); cylData->tangents[Index] = tangent;
        cylData->UVs[Index] = vec2(i2Angle, 1); Index++;
        cylData->points[Index] = p2; cylData->normals[Index] = vec3(p2.x, p2.y, 0.0f); cylData->tangents[Index] = tangent;
        cylData->UVs[Index] = vec2(iAngle, 0); Index++;
        cylData->points[Index] = p3; cylData->normals[Index] = vec3(p3.x, p3.y, 0.0f); cylData->tangents[Index] = tangent;
        cylData->UVs[Index] = vec2(iAngle, 1); Index++;
    }
    
    // Create a vertex array object
    cylData->enableTangentArray( program, true );
    cylData->enableUVArray( program, true );
    cylData->bind(program);
}
Esempio n. 11
0
void generateCylinder(GLuint program, ShapeData* cylData)
{
    makeCircle(circlePoints, numCylDivisions);
    int Index = 0;
    makeConeWall(cylPoints, cylNormals, numCylDivisions, 1.0f, 1.0f, Index, 1);
    makeConeWall(cylPoints, cylNormals, numCylDivisions, -1.0f, -1.0f, Index, -1);
    
    for (int i = 0; i < numCylDivisions; i++)
    {
        int i2 = (i+1)%numCylDivisions;
        point3 p1(circlePoints[i2].x, circlePoints[i2].y, -1.0f);
        point3 p2(circlePoints[i2].x, circlePoints[i2].y, 1.0f);
        point3 p3(circlePoints[i].x,  circlePoints[i].y,  1.0f);
        //point3 n = cross(p3-p2, p1-p2);
        cylPoints[Index] = p1; cylNormals[Index] = point3(p1.x, p1.y, 0.0f); Index++;
        cylPoints[Index] = p2; cylNormals[Index] = point3(p2.x, p2.y, 0.0f); Index++;
        cylPoints[Index] = p3; cylNormals[Index] = point3(p3.x, p3.y, 0.0f); Index++;
        p1 = point3(circlePoints[i2].x, circlePoints[i2].y, -1.0f);
        p2 = point3(circlePoints[i].x,  circlePoints[i].y,  1.0f);
        p3 = point3(circlePoints[i].x,  circlePoints[i].y,  -1.0f);
        //n = cross(p3-p2, p1-p2);
        cylPoints[Index] = p1; cylNormals[Index] = point3(p1.x, p1.y, 0.0f); Index++;
        cylPoints[Index] = p2; cylNormals[Index] = point3(p2.x, p2.y, 0.0f); Index++;
        cylPoints[Index] = p3; cylNormals[Index] = point3(p3.x, p3.y, 0.0f); Index++;
    }
    
    cylData->numVertices = numCylVertices;
    
    // Create a vertex array object
    glGenVertexArrays( 1, &cylData->vao );
    glBindVertexArray( cylData->vao );
    
    // Set vertex attributes
    setVertexAttrib(program,
                    (float*)cylPoints,  sizeof(cylPoints),
                    (float*)cylNormals, sizeof(cylNormals),
                    0, 0);
}
void TeleopCOBMarker::createMarkers()
{
  InteractiveMarker marker_driver;
  marker_driver.name = MARKER_DRIVER_NAME;
  marker_driver.header.frame_id = "/base_link";
  marker_driver.header.stamp = ros::Time::now();
  marker_driver.pose = initial_pose_;
  marker_driver.scale = 1.5;

  InteractiveMarkerControl control;
  control.name = CONTROL_ROTATE_NAME;
  control.orientation_mode = InteractiveMarkerControl::FIXED;
  control.interaction_mode = InteractiveMarkerControl::ROTATE_AXIS;
  control.orientation.x = 0;
  control.orientation.y = 1;
  control.orientation.z = 0;
  control.orientation.w = 1;
  marker_driver.controls.push_back(control);

  control.name = CONTROL_MOVE_NAME;
  control.interaction_mode = InteractiveMarkerControl::MOVE_AXIS;
  control.orientation.x = 1;
  control.orientation.y = 0;
  control.orientation.z = 0;
  control.orientation.w = 1;
  marker_driver.controls.push_back(control);

  control.name = CONTROL_STRAFE_NAME;
  control.interaction_mode = InteractiveMarkerControl::MOVE_AXIS;
  control.orientation.x = 0;
  control.orientation.y = 0;
  control.orientation.z = 1;
  control.orientation.w = 1;
  marker_driver.controls.push_back(control);

  InteractiveMarker marker_navigator;
  marker_navigator.name = MARKER_NAVIGATOR_NAME;
  marker_navigator.header.frame_id = "/base_link";
  marker_navigator.header.stamp = ros::Time::now();
  marker_navigator.pose = initial_pose_;
  marker_navigator.scale = 1.5;

  InteractiveMarkerControl floorControl;
  floorControl.name = CONTROL_NAVIGATION_NAME;
  floorControl.orientation_mode = InteractiveMarkerControl::INHERIT;
  floorControl.interaction_mode = InteractiveMarkerControl::MOVE_PLANE;
  floorControl.orientation.x = 0;
  floorControl.orientation.y = 1;
  floorControl.orientation.z = 0;
  floorControl.orientation.w = 1;
  std_msgs::ColorRGBA c;
  c.r = 1.0;
  c.g = 1.0;
  c.b = 0.0;
  c.a = 1.0;
  makeCircle(floorControl, 0.1, 10.0, c);
  marker_navigator.controls.push_back(floorControl);

  server_->insert(marker_driver, boost::bind(&TeleopCOBMarker::processFeedback, this, _1));
  server_->insert(marker_navigator, boost::bind(&TeleopCOBMarker::processFeedback, this, _1));
  server_->applyChanges();
}
Esempio n. 13
0
 Render(const UVViewHelper& helper, const float centerRadius, const float outerRadius, const bool highlight) :
 m_helper(helper),
 m_highlight(highlight),
 m_center(makeCircle(helper, centerRadius, 10, true)),
 m_outer(makeCircle(helper, outerRadius, 32, false)) {}
Esempio n. 14
0
void NurbsCurve<float,2>::makeCircle(const Point_nD<float,2>& O, float r, double as, double ae){
  makeCircle(O,Point_nD<float,2>(1,0),Point_nD<float,2>(0,1),r,as,ae) ;
}
Esempio n. 15
0
  template<> void NurbsCurve<double,2>::makeCircle(const Point_nD<double,2>& O, double r, double as, double ae){
  makeCircle(O,Point_nD<double,2>(1,0),Point_nD<double,2>(0,1),r,as,ae) ;
}
Esempio n. 16
0
void makeCircle(vec2* dest, int numDivions) {
    makeCircle(dest, numDivions, 1.0f);
}
Esempio n. 17
0
Circle makeCircleFromDrag(Drag drag, CvScalar color, int thickness) {
	int X = drag.end.x - drag.start.x;
	int Y = drag.end.y - drag.start.y;
	int radius = (int)sqrt(X * X + Y * Y);
	return makeCircle(cvPoint(drag.start.x, drag.start.y), radius, color, thickness);
}
Esempio n. 18
0
int main(int argc, char *argv[])
{
    GraphType graphType;
    edgefn ef;

    opts.pfx = "";
    opts.name = "";
    opts.cnt = 1;
    graphType = init(argc, argv, &opts);
    if (opts.directed) {
	fprintf(opts.outfile, "digraph %s{\n", opts.name);
	ef = dirfn;
    }
    else {
	fprintf(opts.outfile, "graph %s{\n", opts.name);
	ef = undirfn;
    }

    switch (graphType) {
    case grid:
	makeSquareGrid(opts.graphSize1, opts.graphSize2,
		       opts.foldVal, opts.isPartial, ef);
	break;
    case circle:
	makeCircle(opts.graphSize1, ef);
	break;
    case path:
	makePath(opts.graphSize1, ef);
	break;
    case tree:
	if (opts.graphSize2 == 2)
	    makeBinaryTree(opts.graphSize1, ef);
	else
	    makeTree(opts.graphSize1, opts.graphSize2, ef);
	break;
    case trimesh:
	makeTriMesh(opts.graphSize1, ef);
	break;
    case ball:
	makeBall(opts.graphSize1, opts.graphSize2, ef);
	break;
    case torus:
	if ((opts.parm1 == 0) && (opts.parm2 == 0))
	    makeTorus(opts.graphSize1, opts.graphSize2, ef);
	else
	    makeTwistedTorus(opts.graphSize1, opts.graphSize2, opts.parm1, opts.parm2, ef);
	break;
    case cylinder:
	makeCylinder(opts.graphSize1, opts.graphSize2, ef);
	break;
    case mobius:
	makeMobius(opts.graphSize1, opts.graphSize2, ef);
	break;
    case sierpinski:
	makeSierpinski(opts.graphSize1, ef);
	break;
    case complete:
	makeComplete(opts.graphSize1, ef);
	break;
    case randomg:
	makeRandom (opts.graphSize1, opts.graphSize2, ef);
	break;
    case randomt:
	{
	    int i;
	    treegen_t* tg = makeTreeGen (opts.graphSize1);
	    for (i = 1; i <= opts.cnt; i++) {
		makeRandomTree (tg, ef);
		if (i != opts.cnt) closeOpen ();
	    }
	    freeTreeGen (tg);
	}
	makeRandom (opts.graphSize1, opts.graphSize2, ef);
	break;
    case completeb:
	makeCompleteB(opts.graphSize1, opts.graphSize2, ef);
	break;
    case hypercube:
	makeHypercube(opts.graphSize1, ef);
	break;
    case star:
	makeStar(opts.graphSize1, ef);
	break;
    case wheel:
	makeWheel(opts.graphSize1, ef);
	break;
    default:
	/* can't happen */
	break;
    }
    fprintf(opts.outfile, "}\n");

    exit(0);
}