Jump to content
  • Advertisement
Sign in to follow this  
billyyu

Ask a question about transform Bounding Spheres

This topic is 4399 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have built some bounding shperes for an articulated robot, and when the robot moves, the angles of each link change as well. I use the OpenGL to build the model, the shafts are built by the command glCylinder(), then I transform the cylinders into some set of points, the code is as follow:(PI is defined as 3.1415926) void CModel::Vertex_Cylinder(point points[], float radius, float height) { for(int i=0;i<36;i++) { points.x=radius*sin(10*i*PI/180); points.y=0; points.z=radius*cos(10*i*PI/180); points[i+36].x=points.x; points[i+36].y=-height; points[i+36].z=points.z; } } And then I use the typical method to find the center and the radius for the sphere. Till now everything is ok and the spheres are bounded these shafts, but as the angles change, the center is in the right position and the radius magnifies from time to time. At first i thought maybe it's the accuracy of the data type and i replaced the 'float' with 'double', and the result is the same. The rotate code is as follow: void CModelView::RotateX(Vector3 *ptr,float angle) { float x,y,z; x=ptr->x; y=ptr->y; z=ptr->z; ptr->x= x; ptr->y= y*cos(angle*PI/180)+z*sin(angle*PI/180); ptr->z=-y*sin(angle*PI/180)+z*cos(angle*PI/180); } void CModelView::RotateY(Vector3 *ptr,float angle) { float x,y,z; x=ptr->x; y=ptr->y; z=ptr->z; ptr->x= x*cos(angle*PI/180)-z*sin(angle*PI/180); ptr->y= y; ptr->z=x*sin(angle*PI/180)+z*cos(angle*PI/180); } void CModelView::RotateZ(Vector3 *ptr,float angle) { float x,y,z; x=ptr->x; y=ptr->y; z=ptr->z; ptr->x=float(x*cos(angle*PI/180)-y*sin(angle*PI/180)); ptr->y=float(x*sin(angle*PI/180)+y*cos(angle*PI/180)); ptr->z=float(z); } Can anyone help me?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by n0rmanfreak
if you are using 180 and not 180.0 or 180f then the value might get cast to integer implictly.

hope that helps


I used the 180.0 instead of 180, but things didnot turn well, the problem is still there, is there any other suggestion? Thank you for you patience.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!