Jump to content
  • Advertisement
Sign in to follow this  
Medo Mex

Calculating Cylinder Width and Radius

This topic is 917 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 vertices array which contains the positions for a cylinder mesh.

 

How do I calculate the cylinder width and radius from this vertices?

Share this post


Link to post
Share on other sites
Advertisement

Is the mesh already standing upright? If so you can find the height/diameter with length( max - min ) of the verts. Otherwise I suppose you could do PCA to find a basis to aligned the cylinder along the cartesian axes, and do the same length( max - min ) where max and min are calculated along the basis axes.

 

From wikipedia:

 

 

220px-GaussianScatterPCA.png
The vectors shown are the eigenvectors of the 
covariance matrix scaled by the square root of the corresponding eigenvalue, and shifted so their tails are at the mean.
Edited by Randy Gaul

Share this post


Link to post
Share on other sites

On the same road as Randy Gaul said, if I understand correctly what you ask :

1) Simply for loop each vertice and find the min/max on the x axis and y axis.

2) Radius = 0.5f * (m_Max.x - m_Min.x)

3) Height = m_Max.y - m_Min.y

Edited by Alundra

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!