# Calculating Cylinder Width and Radius

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

## 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 on other sites

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.

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 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

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634059
• Total Posts
3015292
×